This project is read-only.

GZipStream does not decompress concatenated GZIP data

Apr 20, 2015 at 6:08 PM
Edited Apr 20, 2015 at 6:17 PM

I'm using the latest version DotNetZip in order to decompress some text that is GZIP compressed. I'm using Ionic.Zlib for that, with the GZipStream class.

The problem is that the GZIP data contains multiple GZIP files, which have been concatenated. The data is decompressed correctly when using the gzip command-line tool (the GNU version.)

I tried to iterate manually over the data, but it doesn't work, because GZipStream.Read() will advance the position of the input stream to the end; it doesn't just put it where the data of the first GZIP file ends. (And yes, I've specified true for the leaveOpen argument of the GZipStream constructor.)

I assume this is a bug? Can you think of any other way to decompress the data without knowing the offsets of the beginning of each file inside the concatenated data?

Concatenated GZIP data can be produced very easily. On Unix (Linux, Mac, etc):
cat file1.gz file2.gz > concatenated.gz
On Windows:
copy /b file1.gz+file2.gz concatenated.gz
In both cases, the file "concatenated.gz" will contain both gz files, in the order given in the command-line.

Edit: This forum seems bugged. The above Windows CLI command is supposed to have a plus sign between file1.gz and file2.gz. Do a:
copy /?
For more details on the syntax.