访问 zip 文件中的文件的最快方法是什么?
从 zip 文件中读取单个文件(以随机方式)的最快方法是什么?
据我了解,zip 文件有一个存储各个文件条目的目录,我可以扫描该目录以构建外部索引。是否有任何标准化方法(即现有的库)已经做到了这一点?或者我可以使用特殊类型的 zip 文件吗?
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 (i.e. existing libraries) that already do that? Or could I use a specialized type of zip file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
扫描目录并构建索引是提供对 zip 文件中存档的压缩条目进行随机访问的最快且最佳的方法。该目录通常很小并且位于存档的末尾。如果您有可搜索的媒体,那么这就是您想要的。
zip 格式有很好的文档记录;这并不难做到。然而,细节决定成败。如果您的 zip 文件使用 ZIP64 扩展名、加密、分割存档......那就会变得棘手。对于简单的 zip 文件,做你想象的事情并不那么困难。
不过使用外部库会更容易。
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.
Minizip 似乎是一个很好的读取或写入 zip 文件的库。它使用 zlib 库。
http://www.winimage.com/zLibDll/minizip.html
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