Right so I have a folder full of other folders, which are compressed into .gz files. Inside these folders is text files.
I want to have a program that loops through these text files to see if they contain a specific string, but to do so I need to uncompress them first. I don't want to start messing about with files (unless I can just make them temporarily and delete after), i just want to perform operations on the contents of the .gz folder. I've tried zlib.Gunzip()._outBuffer.toString() which gives a load of gibberish when used on a compressed folder.
How should I proceed?
Had to to something quite similar recently, here's what worked for me: Basically you just read in the file into a
bufferwhich you then can pass to thegunzipfunction. This will return another buffer on which you can invoketoString('utf8')in order the get the contents as a string, which is exactly what you need:EDIT:
If you want to gunzip and extract a directory, you can use
tar-fswhich will extract the contents to a specified directory. Once your done processing the files in it you could just remove the directory. Here's how you wouldgunzipand extract a.tar.gz: