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
bigFile.json.zip: 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?