Reputation: 1487
I am using the minizip package that is distributed as part of Zlib to unzip files in memory. I would like to be able to seek to an arbitrary position in the uncompressed data in the file that is currently open in the archive. What is the best way of doing this?
In the API I see the following:
extern int ZEXPORT unzSetOffset ( unzFile file, uLong pos );
But that appears to seek to a raw position in the archive file itself, not in the currently open file. In the absolute worst case I could close and reopen the file and then discard x bytes until I get to the right position, but that would be terrible. Is there a better way?
Upvotes: 2
Views: 722
Reputation: 2179
I have had a similar issue and wrote a patch a while back for minizip. If you had searched for unzSeek you would have found it.
https://github.com/nmoinvaz/minizip/pull/30
Upvotes: 2
Reputation: 56
The issue is that the compressed flow is not context-free: You need to decompress all previous data in order too get to a proper given state.
It is unfortunate but look at how WinZip or WinRAR are handling this: They decompress all your data behind the scenes in order to be able to transparently handle any piece of data.
I hope this helps.
Upvotes: 2