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

Jun 2, 2009 at 12:28 AM

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 12:45 PM
Edited Jun 4, 2009 at 12:46 PM

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 4: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 5, 2009 at 12:41 AM

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.