Uncompressing zlib data using boost::iostreams::filtering_streambuf trouble

Posted by GuitaringEgg on Stack Overflow See other posts from Stack Overflow or by GuitaringEgg
Published on 2012-03-19T20:42:36Z Indexed on 2012/03/20 11:29 UTC
Read the original article Hit count: 363

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about c++

Related posts about boost