Uncompressing zlib data using boost::iostreams::filtering_streambuf trouble
- by GuitaringEgg
I'm trying to write a small class that will load the chunk data from part of a minecraft world file. I'm to the point where I have stored some data in a char array which was compressed with zlib and need to decompress it.
I'm trying to use the boost filtering_streambuf to do this.
char * rawChunk = new char[length - 1];
// Load chunk data
stringstream ssRawChunk(rawChunk);
boost::iostreams::filtering_istream in;
in.push(boost::iostreams::zlib_decompressor());
in.push(ssRawChunk);
stringstream ssOut;
boost::iostreams::copy(in, ssOut);
My problem is that rawChunk contains null data, so when coping data from (char*) rawChunk to (stringstream) ssRawChunk, it terminates at ~257 instead of the expected length 2154.
Is there any way to use filtering_streambuf without stringstream to allow for null data or is there a way to stop stringstream to not terminate on null data?