Does zlib allow decompressing from the middle of a file?
What I mean is, if I call inflate
with a stream that points to the middle of compressed data without calling inflate
to the data preceding the middle, would it work?
Copy from the zlib FAQ (the emphasis is mine):
28. Can I access data randomly in a compressed stream?
No, not without some preparation. If when compressing you periodically use
Z_FULL_FLUSH
, carefully write all the pending data at those points, and keep an index of those locations, then you can start decompression at those points. You have to be careful to not useZ_FULL_FLUSH
too often, since it can significantly degrade compression. Alternatively, you can scan a deflate stream once to generate an index, and then use that index for random access. See examples/zran.c.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With