I am trying to export a ValueTree as Xml and compressed to a file and the import back decompressed. I get a crash at the gzipDecompressorInputStream stage.
this is the part which does the compression and export;
MemoryOutputStream SeqBinData;
ScopedPointer <XmlElement> SeqDataXml (SeqDatabase.createXml()); //SeqDatabase is the ValueTree object
GZIPCompressorOutputStream gzipOutputStream(&SeqBinData,5,0);
SeqDataXml->writeToStream(gzipOutputStream,"");
thefile.replaceWithData (SeqBinData.getData(), SeqBinData.getDataSize()); //theFile is a File object with defined path.
gzipOutputStream.flush();
Also if you indent your code by 4 spaces on the forum (or surround with triple backticks) you’ll get syntax highlighting, which makes it much easier to read.
No, don’t discard the flush! You need to flush before writing the data elsewhere.
JUCE also uses zlib for compression, so you should select GZIPDecompressorInputStream::zlibFormat as the format type. Or better yet, just omit specifying anything! Those format types should be used when decompressing data created by other programs.