Problems decompressing zip file from binary data using GZIPDecompressorInputStream

I have a larger json file that has been zipped using the macOS finder embedded as binary data. Now I want to use juce::GZIPDecompressorInputStream to decompress it. The output of


in the terminal is Zip archive data, at least v2.0 to extract, compression method=deflate

My approach on decompressing looks as straightforward as this:

juce::MemoryInputStream zippedStream (BinaryData::bigFile_json_zip, BinaryData::bigFile_json_zipSize, false);
juce::GZIPDecompressorInputStream decompressedStream (& zippedStream, false, juce::GZIPDecompressorInputStream::Format::deflateFormat);

juce::MemoryBlock json;
decompressedStream.readIntoMemoryBlock (json);

However this results in a memory block of size zero. Under the debugger I see that GZIPDecompressHelper::error in the stream is true, so I assume this is because of some error occurring. However there is no further error reporting, no assertion (which I find extremely untypical for a JUCE class by the way) so I have no clue what’s going wrong here.

I have chosen Format::deflateFormat based on the output of the file command but I also tried Format::zlibFormat with a similar result. I have basically no knowledge about zip file format details, so I’m not sure if for some reasons the file format generated by the finder is incompatible with the JUCE implementation.

Has anyone achieved decompressing a file compressed on macOS successfully before and can share some insights on how to do it or at least how to get some insight about what’s going wrong?

Nevermind, found the solution myself and it’s pretty embarrassing :smiley:

GZip is not Zip. Well, should have done some really basic research before posting, but still leaving it here for others that might come across the same problem :wink: When using a gzip compressed file, everything works as expected. And I think juce::ZipFile is the right tool for handling a Zip.

Problem solved!


If I remember correctly, juce::ZipFile uses internally GZIPCompressorOutputStream and GZIPDecompressorInputStream, so also GZip instead of Zip…