ZLib unzip a zip containing multiple files
Asked Answered
D

2

6

I am using delphi 7 and need to uncompress a compressed zip file which contains multiple files, I have found examples of how to unzip a single file using ZLib but cannot find any examples of this with muliple files in the zip, would it be possible for someone to either give me an example or point me in the direction of one

thanks

Colin

Dextrosinistral answered 16/5, 2012 at 15:19 Comment(1)
ZLib <> Zip. ZLib is a generic data compression library, while Zip is a compression and file format library. Just because they both start with Z doesn't make them compatible. :) For working with Zip files, use a Zip library, like Abbrevia (mentioned by @ErikKnowles below). If you want to use ZLib, you'll have to find a library that wraps it with Zip-compatible file I/O anyway, since ZLib knows nothing about Zip headers and multiple files.Dialogist
I
13

If you're having problems with zlib, maybe you might want to consider TurboPower's Abbrevia (available on SourceForge). With Abbrevia, here's our multiple-file extract code:

zip.ArchiveType := atZip ;
zip.ForceType := true ;
zip.OpenArchive({...your .zip archive name});

zip.BaseDirectory :=  {...your extract path...} ;
zip.OnConfirmOverwrite := Overwrite
zip.ExtractFiles('*');

There's options to handle extraction failure, confirmation of overwrites, etc. It's a pretty nice library to work with, and it's free.

Infatuation answered 16/5, 2012 at 15:44 Comment(0)
E
2

There is an example in the zlib source distribution on zlib.net. Take a look at contrib/minizip/miniunz.c .

Eadith answered 16/5, 2012 at 19:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.