I'm currently wrestling with zlib, trying to write a program that extracts gzip archives containing a single (large) text file. I was wondering if anyone here is more familiar with the library and could give me some advice.
I have succeeded in loading an archive wholly into memory and then decompressing the data piece-wise into a target byte stream. I don't do the latter in a single swoop, because the decompressed data becomes very big; hence my plan to process (and discard) it in steps.
I noticed that zlib's inflate function appears to ensure that sequential calls to it leave no gaps in the decompressed data, even though I stop the output at an arbitrary number of bytes (my buffer size). So far, so good.
My question is, can I accomplish the same with an input stream that's read in steps rather than all at once? So far inflate always had the whole stream to work with, allowing it to stop and resume where feasible, probably looking ahead a bit, while giving me a straight forward interface to use.