I’m building an app which requires reading a file inside a zipfile without extracting the file. Is there any library out there with this kind of function or can you give me some ideas on how to solve it?
I’m building an app which requires reading a file inside a zipfile without extracting
Share
You can unzip one buffer-ful of data at a time, and read through that, assuming that the file is text and is structured in a way that you can parse it incrementally (for example, XML data that is processed with a SAX parser).
Here is a routine I wrote that extracts data from a zip-stream and prints out a line at a time. You could modify it to print out or parse
Ncharacters, instead. Or you could add the lines to a line buffer, and process/parse a chunk of lines at once.This uses
zlib, and if this code is useful to you, feel free to use it: