Zlib C ++ and file extraction

I started using zlib 1.2.5 and I do not see any program to extract from a zip file? I read about the minizip application included in the distribution.

Is this how it should be done?

+8
source share
3 answers

Yes this good. (But if you ever don't like C code, you should take a look at the 7-zip SDK, which has code in C ++ and C #.)

  • All functions for viewing and unpacking files from the zip archive are located in: unzip.h
  • All functions for compressing and adding files to the zip archive are located in: zip.h

(see contrib \ minizip \ unzip.h and contrib \ minizip \ zip.h )

for example unpacking: the unzOpen() functions of your mail file return unzFile

then use unzGoToFirstFile() and unzGoToNextFile() on that unzFile to view all files in the archive.

then you will get file information for each file using unzGetCurrentFileInfo() , namely its size,

unzOpenCurrentFile() course you should call unzOpenCurrentFile() at some point.

and call unzReadCurrentFile() using the size from fileinfo to get the binary contents of the archive file.

optionally, there is an opaque structure that you can provide for using your own I / O function, but obviously there is a default win32 implementation for accessing the file, so you don’t even have to worry about that.

PS: and don't forget to call unzCloseCurrentFile ()

+24
source

From: http://www.zlib.net/zlib_faq.html#faq11 : 11. Can zlib handle .zip archives?

Not on its own, no. See the contrib / minizip directory in the zlib distribution.

There is no tutorial, but the source of minizip zip.c is for IO (presumably compression and decompression) in zip files using zlib.

And there is no tutorial yet, but http://www.winimage.com/zLibDll/minizip.html gives more detailed information.

+7
source

I built a wrapper around minizip, adding some features that I need, and making it more usable. Is uses the latest C ++ 11 and is being developed using Visual Studio 2013 (should be portable, but I have not tested it on unix)

Here's the full description: https://github.com/sebastiandev/zipper

you can fasten entire folders, streams, vectors, etc. Also a nice feature does everything entirely in memory.

+3
source

All Articles