简体   繁体   中英

What is the fastest way to access files in a zip file?

What is the fastest way to read individual files (in a random fashion) from a zip file?

As I understand it, zip files have a directory that stores the individual file entries, and I could scan this directory to build an external index. Are there any standardized ways (ie existing libraries) that already do that? Or could I use a specialized type of zip file?

Minizip seems to be a good library for reading or writing zip files. It uses the zlib library.

http://www.winimage.com/zLibDll/minizip.html

Scanning the directory and building the index is the fastest and best way to provide random access to the compressed entries archived in a zip file. The directory is usually small and lies at the end of the archive. If you have seekable media, then this is what you want.

The zip format is documented pretty well; it's not too hard to do. The devil is in the details, though. If your zip files use ZIP64 extensions, encryption, split archives.. that's when it gets tricky. For simple zip files, doing what you imagine is not so difficult.

Still it would be easier to use an external library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM