Is it possible to filter input files with a package?


#1

I recently encountered a lot of small text files that were compressed with gzip, with filenames ending with .gz. Would it be possible to write a package that can decompress these files on the fly? And when you save, it would compress it transparently.

Is this possible in a package? If so, what APIs do I use?

Thank you!


#2

Node’s ZLIB can handle compression and decompression. I think your best bet would be to decompress the file into a normal text file for editing, recompress it whenever it gets saved, then have Atom delete the temporary file when that TextEditor closes (you can throw in a method on activation to clean up any old files that get left behind).


#3

It sure is possible, naively I’d say it involves the following:

  1. Writing an opener for *.gz files that creates a model to handle the gz -> text editor and text editor -> gz conversions
  2. Writing a custom pane item for that model that will embed a text editor, listens to its save events, prevents them and dispatches the call to the model

#4

An opener, that seems to be what I was looking for. Thank you, I will try it out.

My first goal is simply to be able to read these files, second goal is to also be able to save them. One step at a time. :slight_smile: