How to decompress a specific file in a tar.gz archive on the fly.

Jun 1, 2009 at 11:28 PM

I am trying to decrompress a specific file in a tar.gz archive using streams (nothing should be written to disk).
can anybody help be on how to do this?


Jun 4, 2009 at 11:45 AM
Edited Jun 4, 2009 at 11:46 AM

Hi, sorry for a late reply, I was busy in my university.

Try this code:

            SevenZipExtractor extr = new SevenZipExtractor(GzipInputStream);
            MemoryStream TarMemoryStream = new MemoryStream();
            extr.ExtractFile(0, TarMemoryStream);
            extr = new SevenZipExtractor(TarMemoryStream);
            extr.ExtractFile("your_file_name.txt", YourFileStream);



Jun 4, 2009 at 3:24 PM

So I need to pass it through two different extractors (one for GZip, one for Tar). We can't use a Memory stream because of the sheer size of a single file (> 80GB uncompressed).
I guess we have to use separate threads to write/read from the middle stream.

There is really no way to read a file in a tar.gz using one single extractor?

Jun 4, 2009 at 11:41 PM

Unfortunately, no.

Try to unpack a 10 GB tgz file with the 7-zip original program. If it extracts, so SevenZipSharp somehow can.

The only way for you seems to split your 80 gb tar archive into lots of 0.5 gb volumes and then gzip them, but volumes are not supported at the moment.