问题
I'm looking for a wrapper that distills zlib to:
- OpenZipFile()
- GetItemInfo(n)
- UnzipItem(n) // Bonus points for unzipping recursively if item n is a directory.
I see a lot of wrappers around the zlib library on, say, codeproject.com but they are all platform-specific in order to provide the added platform-specific functionality of unzipping to file/memory buffer/pipe.
回答1:
In boost::iostreams there is the possibility to use zlib, gzip and bzip2 formats.
You find it from http://www.boost.org/
回答2:
In the zlib source archive, there is a contribution named "minizip".
"minizip" is a set of files you can use to play with .zip files. Basic services you need are already there :
- unzOpen
- unzLocateFile
- unzOpenCurrentFile
- unzGetCurrentFileInfo
- unzCloseCurrentFile
- unzClose
Of course, this is not object oriented (and I'm sure that was not the goal of the creator of minizip), but writing a simple object oriented wrapper should be easy.
回答3:
firstobject's easy zlib stays cross-platform; it has zlib in a single file easyzlib.c and exposes only ezcompress and ezuncompress functions with the added feature of determining the memory requirement before allocating the exact size.
回答4:
You could try to grab the code from another FOSS project. ScummVM, for example, has a highly portable Zlib wrapper (implementation, header) with all the functions you need, plus an OO layer for interfacing generically with any other kind of archive.
Maybe that's a good starting point? The wrapper functions are totally standalone and portable (heck, they even work on a Nintendo DS), but the OO layer depends on many custom classes which may be hard to add to your own project.
回答5:
GZStream is worth a look. This is a nice cross-platform wrapper round ZLib which extend the STL iostream classes.
http://www.cs.unc.edu/Research/compgeom/gzstream/
What is good about this wrapper over some of the others is that if you're working with very large archives you don't need to load the whole dataset into memory.
回答6:
This is an old thread, but I thought I'd throw in Boost's ZLib wrapper:
http://www.boost.org/doc/libs/1_47_0/libs/iostreams/doc/classes/zlib.html
回答7:
If you will use minizip -- pay attention, thet version shipped with zlib 1.2.3 has 2GB resulting zip file limitation. IT will produce zip with size >2GB - but you won't be able to open them...
来源:https://stackoverflow.com/questions/267455/c-cross-platform-zlib-simplifer-wrapper