samedi 18 avril 2015

Getting number of bytes read in zlib stream

I am using a zlib.Inflate to inflate a chunk of data. The problem I have now is that all I know is how many bytes of uncompressed data there are but not how many that is in the compressed stream. Im currently just writing the entire input buffer to the inflater and then read the amount of uncompressed bytes from it. That gives me the correct output data but I have to know how many bytes were consumed to continue parsing the remaining data.


So right now I did the following for testing:



var inflater = zlib.createInflate();
inflater.write(strm.buffer.slice(strm.position));
inflater.on("readable", (function(inflater, len) {
return function() {
console.log(inflater);
var decompData = inflater.read(len);
console.log(inflater);
var output = fs.createWriteStream("output.bin");
output.write(decompData);
}
})(inflater, len));


I checked all members of the inflater before and after the read but nothing changes, every single value is the same. Is there a way to determine how many bytes were read from the compressed buffer?


Thank you in advance, Cromon


Aucun commentaire:

Enregistrer un commentaire