tags:

views:

1501

answers:

7

I'm looking for a wrapper that distills zlib to:

  1. OpenZipFile()
  2. GetItemInfo(n)
  3. 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.

A: 

Write one yourself.
It should be only a couple of lines of code.
And then put it on sourceforge for the rest of the world to enjoy.

shoosh
+3  A: 

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.

Nicolas
Wow the files are 8 years old! heheh!
leeand00
It's in cvs; well yeah I guess that's what they had for version control back then..
leeand00
Hey I don't care if it's 8 years old, if it'll still compile I'll use it!
leeand00
+1  A: 

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.

Vicent Marti
+1  A: 

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.

Ben Bryant
+4  A: 

In boost::iostreams there is the possibility to use zlib, gzip and bzip2 formats.

You find it from http://www.boost.org/

+1  A: 

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.

Gavin Maclean
Hey, that one looks nice! 7 years old... I'll try to compile it.
craesh
A: 

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...

Anatoliy