Does zlib provide the ability to decompress from the middle of the file

Does zlib allow unpacking from the middle of the file?
I mean, if I call inflate with a stream that points to the middle of the compressed data, without calling inflate for the data preceding the middle, will this work?

+6
source share
1 answer

Copy from zlib FAQ (emphasis mine):

28. Can I accidentally get data in a compressed stream?

No, not without any preparation. If during compression you periodically use Z_FULL_FLUSH , carefully write all the pending data at these points and save the index of these locations, then you can start decompression at these points. You must be careful not to use Z_FULL_FLUSH too often, as this can significantly degrade compression. In addition, you can scan the deflation flow once to create an index, and then use this index for random access. See Examples /zran.c.

+8
source

Source: https://habr.com/ru/post/888984/


All Articles