1

我有一个visual c项目,我想在一个目录结构中包含一个包含多个文件的存档我想以编程方式将它提取到磁盘上的某个地方,使用一个最好的小型库(在small下我的意思是几个.c和.h 文件 - 大小并不重要),但我似乎只找到直接解压缩或压缩数据的库(我查看了 lzo-lzop-minilzo,但我似乎没有找到任何说它可以解压整个目录树的东西虽然我已经使用 lzop 来压缩包含文件的存档)

谢谢

4

1 回答 1

1

zlib and accompanying (in the contrib) minizip library support .zip format decompression.

You can pack the .zip file as a resource in your executable. To get the raw data from .exe use the FindResource, SizeofResource, LoadResource, LockResource APIs.

Then see minizip's samples to see how to decompress and read zlib's documentation to overload the I/O callbacks.

Disclaimer: I did this for Linderdaum Engine's virtual file system and there is now support for .zip, .tar, .rar (uncompressed) and .tar.gz formats. The code for VFS is in Src/Linderdaum/Core/VFS and it is under MIT license for non-commercial use. It's C++, but the I/O wrappers for zlib use C-style API and the code is pretty straightforward.

于 2012-07-31T21:32:14.470 回答