Click here to Skip to main content
Click here to Skip to main content

Zip Utils - clean, elegant, simple, C++/Win32

By , 19 Sep 2012
 

zipping and unzipping in action!

Introduction

WARNING: This code has known bugs. It doesn't deal with non-ASCII filenames correctly. It doesn't deal with passwords correctly. I don't have time to fix it, unfortunately. But I've marked it so that other gold members can edit it, in case anyone wants to make the fix.

This source code shows how to add zip/unzip functionality to your programs. Lots of people have written their own wrappers around Zip, and indeed there are several articles on CodeProject that are based on earlier versions of my own code. How is this version different?

  • Clean packaging. There's one pair of files zip.cpp, zip.h to add to your project if you want Zip. Another pair unzip.cpp, unzip.h if you want unzip (or both if you want both!). There are no additional libraries or DLLs to worry about.
  • Clean API. Most other APIs around zip/unzip are terrible. This one is the best. The API is short, clean, and in a familiar Win32 style. Most other APIs wrap things up in classes, which is ugly overkill for such a small problem and always turn out to be too inflexible. Mine doesn't. See the code snippets below.
  • Flexibility. With this code, you can unzip from a zip that's in a disk file, memory-buffer, pipe. You can unzip into a disk file, memory-buffer or pipe. The same for creating Zip files. This means that at last you don't need to write out your files to a temporary directory before using them! One noteworthy feature is that you can unzip directly from an embedded resource into a memory buffer or onto a disk file, which is great for installers. Another is the ability to create your Zip in dynamically growable memory backed by the system page file. Despite all this power, the API remains clean and simple. The power didn't come from just writing wrappers around other people's code. It came from restructuring the internals of zlib and info-zip source code. My code is unique in what it does here.
  • Encryption. This version supports password-based Zip encryption. Passwords are absent from many other Zip libraries, including gzip.
  • Unicode. This version supports Unicode filenames.
  • Windows CE. This version works as it is under Windows CE. No need to alter makefiles or #defines, or worry about compatibility of any LIB/DLL.
  • Bug fixes. This code is based on gzip 1.1.4, which fixes a security vulnerability in 1.1.3. (An earlier version of my code used 1.1.3, and has crept into other CodeProject articles...).

At its core, my code uses zlib and info-zip. See article end for acknowledgements & license.

Using the code

To add Zip functionality to your code, add the file zip.cpp to your project, and #include "zip.h" to your source code.

Similarly for unzipping, add the file unzip.cpp to the project and #include "unzip.h" to your source code. Zip and unzip can co-exist happily in a single application. Or you can omit one or the other if you're trying to save space.

The following code snippets show how to use zip/unzip. They are taken from one of the demo applications included in the download. It also has project files for Visual Studio .NET and Borland C++ Builder6 and Embedded Visual C++ 3. The code snippets here use ASCII. But the functions all take arguments of type TCHAR* rather than char*, so you can use it fine under Unicode.

Example 1 - create a Zip file from existing files

  // We place the file "simple.bmp" inside, but inside
  // the zipfile it will actually be called "znsimple.bmp".
  // Similarly the textfile.

  HZIP hz = CreateZip("simple1.zip",0);
  ZipAdd(hz,"znsimple.bmp",  "simple.bmp");
  ZipAdd(hz,"znsimple.txt",  "simple.txt");
  CloseZip(hz);

Example 2 - unzip a Zip file using the names it has inside it

  HZIP hz = OpenZip("\\simple1.zip",0);
  ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index;
  // -1 gives overall information about the zipfile
  for (int zi=0; zi<numitems; zi++)
  { ZIPENTRY ze; GetZipItem(hz,zi,&ze); // fetch individual details
    UnzipItem(hz, zi, ze.name);         // e.g. the item's name.
  }
  CloseZip(hz);

Example 3- unzip from resource directly into memory

This technique is useful for small games, where you want to keep all resources bundled up inside the executable, but restricting the size.

Suppose we used a .rc with 1 RCDATA "file.zip" to embed the Zip file as a resource.

  HRSRC hrsrc = FindResource(hInstance,MAKEINTRESOURCE(1),RT_RCDATA);
  HANDLE hglob = LoadResource(hInstance,hrsrc);
  void *zipbuf = LockResource(hglob);
  unsigned int ziplen = SizeofResource(hInstance,hrsrc);
  hz = OpenZip(zipbuf, ziplen, 0);
  ZIPENTRY ze; int i; FindZipItem(hz,"sample.jpg",true,&i,&ze);
  // that lets us search for an item by filename.
  // Now we unzip it to a membuffer.
  char *ibuf = new char[ze.unc_size];
  UnzipItem(hz,i, ibuf, ze.unc_size);
  ...
  delete[] ibuf;
  CloseZip(hz);
  // note: no need to free resources obtained through Find/Load/LockResource

Example 4 - unzip chunk by chunk to a membuffer

Normally when you call UnzipItem(...), it gives the return-code ZR_OK. But if you gave it too small a buffer so that it couldn't fit it all in, then it returns ZR_MORE.

  char buf[1024]; ZRESULT zr=ZR_MORE; unsigned long totsize=0;
  while (zr==ZR_MORE)
  { zr = UnzipItem(hz,i, buf,1024);
    unsigned long bufsize=1024; if (zr==ZR_OK) bufsize=ze.unc_size-totsize;
    ... maybe write the buffer to a disk file here
    totsize+=bufsize;
  }

Common Questions

STRICT? I think you should always compile with STRICT (in project-settings/preprocessor/defines), and full warnings turned on. Without STRICT, the HZIP handle becomes interchangeable with all other handles.

How to show a progress dialog? One of the included examples, "progress", shows how to do this.

How to add/remove files from an existing Zip file? The zip_utils currently only allows you to OpenZip() for unzipping, or CreateZip() for adding, but don't allow you to mix the two. To modify an existing Zip (e.g.: adding or removing a file), you need to create a new Zip and copy all the existing items from the old into the new. One of the included examples, "modify", shows how to do this. It defines two functions:

  ZRESULT RemoveFileFromZip(const TCHAR *zip, const TCHAR *name);
  ZRESULT AddFileToZip(const TCHAR *zip, const TCHAR *name, const TCHAR *fn);
  // eg. AddFileToZip("c:\\archive.zip","znsimple.txt","c:\\docs\\file.txt");
  // If the zipfile already contained that thing (case-insensitive), it is removed.
  // These two functions are defined in "modify.cpp"

"fatal error C1010: unexpected end of file while looking for precompiled header directive". To fix this, select zip.cpp and unzip.cpp and change Project > Settings > C++ > PrecompiledHeaders to NotUsingPrecompiledHeaders.

Discussion

Efrat says: "I think the design is very bad", and so objects when I say that my API is clean and others are not. (Actually, he says my documentation is the most conceited he's seen and my design is the worst that he's seen!) I've reproduced his comments here, with my responses, so you can make a more informed decision whether to use my library.

  • [Efrat] Better instead to use the boost IOStream library.

    [Response] I love the boost library. If people can figure out how to add it to their projects and zip/unzip with it, they should definitely use boost rather than my code. (I'm still trying to figure it out, though, and couldn't get it to compile under CE.)

  • [Efrat] A compressed archive has internal state; it's a classic object; the author's criticisms of OOP are unjustified. "OOP doesn't mean placing your code in a CPP file."

    [Response] I'm trying not to be OOP.

    1. you'll never inherit from an archive, nor invoke virtual methods from it: we only use encapsulation, not any of the other pillars of OOP. By using an opaque handle HZIP rather than a class, I indicate this clearly to the programmer. Also,
    2. C++ classes don't work cleanly across DLLs. Handles like HZIPs do.
  • [Efrat] For instance, progress-notifications should be done by virtual functions in a derived class, not by callbacks.

    [Response] To get progress, you invoke UnzipItem in a while loop, and each iteration unzips a little bit more of the file. This is clean, re-entrant, and has a simple API. I think this is an easier API than inheriting from a class. I think inheritance from library classes is bad, in general.

  • [Efrat] Compression should go in a DLL.

    [Response] I disagree. DLLs are always pain, for developers as well as users. Unzip only adds 40K in any case.

  • [Efrat] The API doesn't use the type system to differentiate between an HZIP for zipping and an HZIP for unzipping.

    [Response] This was intentional. The difference between zipping and unzipping is a current implementation drawback. I think an API should be clean, "inspirational", and you shouldn't encode current implementation limitations into the type system.

  • [Efrat] The API uses error-codes, rather than exceptions, but anyone who has graduated Programming 101 knows exceptions are better.

    [Response] I think exceptions are not welcomed anywhere nearly as widely as Efrat suggests. Also, they don't work cleanly across DLL boundaries, and they don't work on Pocket PC.

  • [Efrat] The API is inflexible; it should be coded for change, not just coded for all the options that were conceived while designing (handles, files, memory). Most users will think of sources and targets which this design can't support.

    [Response] The original Zip uses FILE*s, which are effectively the same as Windows pipes. I also provided memory-buffers which add an enormous amount of flexibility that's easy to use and requires no additional programming. For any user who needs sources and targets which can't be reached via a memory buffer, they shouldn't use these zip_utils.

  • [Efrat] The is unnecessarily Windows-specific. The original zlib works great and is portable; zip_utils offers no advantages. Compression is memory-manipulation and IO and so should not be platform-specific.

    [Response] In the olden days before STL, "cross-platform" code inevitably meant:

    1. peppered with so many #ifdefs that you couldn't read it,
    2. didn't work straight away under Windows.

    I started from an old code-base, and so Efrat's proposed bottom-up rewrite was not possible. The advantage this code offers over zlib is that it's just a single file to add to your project, it works first time under Windows, you can add it easily as a CPP module to your project (not just dll/lib), and the API is simpler.

In general, Efrat wants code to be a clean extensible framework. I don't; I want small compact code that works fine as it is. Furthermore, I think that "framework-isation" is the biggest source of bugs and code overruns in the industry.

Acknowledgements

This version of article was updated on 28th July 2005. Many thanks to the readers at CodeProject who found bugs and contributed fixes to an earlier version. There was one terrible bug where, after a large file had been unzipped, the next one might not work. Alvin77 spotted this bug.

My work is a repackaged form of extracts from the zlib code available at www.gzip.org by Jean-Loup Gailly and Mark Adler and others. Also from the info-zip source code at www.info-zip.org. Plus a bunch of my own changes. The original source code can be found at the two mentioned websites. Also the original copyright notices and licenses can be found there, and also inside the files zip.cpp and unzip.cpp of my code. As for licensing of my own contributions, I place them into the public domain.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication

About the Author

ljw1004
Technical Lead
United States United States
Lucian studied theoretical computer science in Cambridge and Bologna, and then moved into the computer industry. Since 2004 he's been paid to do what he loves -- designing and implementing programming languages! The articles he writes on CodeProject are entirely his own personal hobby work, and do not represent the position or guidance of the company he works for. (He's on the VB/C# language team at Microsoft).

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
AnswerRe: Copression level (Little solution)memberboris_l12-Aug-09 7:51 
A better solution would be passing it as additional param to the CreateZip functions, from there to CreateZipInternal, from there to TZip constructor, storing the value in a TZip member. Later, in TZip::ideflate, init state->level from that member.
 
In addition, you may want to alter the compression method selection in TZip::Add, setting it to STORE when level is set to 0, letting you use no compression whatsoever, if required.
 
You may also want to add a level parameter to ZipAdd, passing it down to ZipAddInternal and then to TZip::Add, this way you should be able to set a compression level per file.
Generalit works well on windows ce 6.0memberMember 6158843-Mar-09 3:59 
it worked great for me.
I created a simple zip archive in a snap.
Thanks! Thumbs Up | :thumbsup:
QuestionI don't know why!!!memberDaniele B9-Feb-09 5:14 
Thank you very very much!!!! Big Grin | :-D
Extraordinarily useful for me!!!
 
But I have experienced many errors during compiling process with Visual Studio 9,
I solved the problem simply writing:
#include "unzip.cpp"
instead of:
#include "unzip.h"
Can anyone explain to me why?
Sorry but I'm a novice! D'Oh! | :doh:
AnswerRe: I don't know why!!!memberMember 345744810-Feb-09 12:32 
When you say #include "unzip.h" you are declaring so many functions whose definitions are in "unzip.cpp"
Now if you are using #include "unzip.h" and not adding "unzip.cpp" to you project than compiler doesnot find those definition and that might be the reason for so many errors.
But when u say #include "unzip.cpp", compiler finds both the things and it is happy.
GeneralMy vote of 1 [modified]memberulyanov28-Jan-09 19:59 
I upped my vote to a 4, my lack of skill shouldn't affect the rating.
 
After wresting with it for a day, I got it to work to my satisfaction.
 
modified on Friday, January 30, 2009 8:31 AM

GeneralWhitespacememberdarkchrono21-Jan-09 12:10 
Do you just not like whitespace?
GeneralUnzipping binary data from zip into memory fails!memberasda3qrw3rw4rw4rw4rw4rw12-Jan-09 4:25 
When I load for example an PNG file from a zip file directly into memory, then this
library loads the data correctly into the memory.
 
BUT: As we are using char pointers, the char pointer only saves content till the first WRONG end of file. Binary formats does have wrong interpreted zero characters, but I am not able to load this full data correctly.
 
Does anyone has an idea?
 
Here the code:
 
int iResultIndex;
ZIPENTRY zeResultEntry;
 
ZRESULT result = FindZipItem( currentHandle, "pic.png", true, &iResultIndex, &zeResultEntry);
 
if( result != -1 )
{
	ZRESULT result;
	char *tmpBuf = new char[ zeResultEntry.unc_size ];
 
	// Memory buffer version
	result = UnzipItem( currentHandle, iResultIndex, tmpBuf, zeResultEntry.unc_size);
}
 
The tmpBuf only shows the first 4 or 5 characters, because of the wrong eof characters.
P.S.: When I load this PNG directly to the harddisc, everything is fine...
Generalfilesize over 4gbmemberMember 266531411-Jan-09 3:05 
would be nice - but not work with filesize over 4gb ...
 
sascha
GeneralRe: filesize over 4gbmemberpupkin1233211-Sep-09 8:28 
Make sure your file system support files that are over 4gb (FAT32 doesnt, but NTFS does).
How to Convert FAT Disks to NTFS - http://technet.microsoft.com/en-us/library/bb456984.aspx[^]
GeneralJust in case (zero size files are not recovering its correct dat when unzippig)memberpablodg9-Jan-09 4:28 
Great packaging for a zip library!!
 
One little issue... At line 4035 of unzip.cpp, I changed:
 
if (haderr != 0)
SetFileTime(h,&ze.ctime,&ze.atime,&ze.mtime); // may fail if it was a pipe
 
to:
 
if (h != NULL)
SetFileTime(h,&ze.ctime,&ze.atime,&ze.mtime);
 
I am not sure it is the right fix, but otherwise files of size zero where skipping the SetFileTime function (which was disturbing for folder comparison).
 
Thanks again for the cool library! PDG.
GeneralA little errormemberDark_eye22-Dec-08 6:19 
I am getting this when compiling with MingW, in Dev-Cpp
 
3728 C:\*****\unzip.cpp integer constant is too large for "long" type
GeneralMy vote of 2memberMax Meier30-Nov-08 18:50 
really ugly code
GeneralRe: My vote of 2memberrj456-Jul-09 11:43 
agreed
GeneralRe: My vote of 2memberrj456-Jul-09 11:43 
I forgot to mention, I am glad it is simple though... Good contribution but ugly c++.
Questionquestion: AddZip?membersharolsh24-Nov-08 23:26 
Hello!
 
I write application(in wxWidgets)that zip folders and files.
I want to know, while zipping the files, how much did I process already (I need it estimated, not really really accurate - I need to show the user
the progress, and if the files are big , that can take some time).
so - is there a way I can get from the code, what's the length of the
part I already read from the file?
 
thanks
Sharon
QuestionQuestion: how do I know estimated time - or what percentage of the data that was finished - when I zip file?membersharolsh24-Nov-08 23:07 
Hello!
 
I write application(in wxWidgets)that zip folders and files.
I want to know, while zipping the files, how much did I process already (I need it estimated, not really really accurate - I need to show the user
the progress, and if the files are big , that can take some time).
so - is there a way I can get from the code, what's the length of the
part I already read from the file?
 
thanks
Sharon
GeneralLink with zlibmemberRicky Lung19-Nov-08 21:30 
Great job! Simple and elegant.
It would be wonderful if there is a compile-time option to let user link with the official zlib, to reduce duplicated code within the project.
Generalzip line by line/append text to file zipped already [modified]memberizotov14-Oct-08 6:10 
Hi,
is there a way to create the zip file adding contents line by line to it? Or in other words: is it possible to append some text to a file that is already zipped? I create my plain text files adding text line by line (using fprintf) and I would like to follow the same procedure when zipping becouse I do not agree with allocating large memory blocks. Is it possible with this library?
Thanks!
(K)
 
modified on Wednesday, October 15, 2008 2:26 AM

GeneralError ZR_FLATE when unzipping an empty file.memberjohndoeuf2-Oct-08 2:46 
Hi all,
 
First of all I would like to thank the author of this small & very usefull piece of code.
 
I think there is a bug when unzipping an empty file (in function unzReadCurrentFile(...)).
If you unzip an empty file (that can happend) you get the ZR_FLATE error code.
Even if the empty file is correctly unzipped and no error should be returned.
 
I've locally corrected this bug by adding the following line at line 3634 (in the uzReadCurrentFile function) of unzip.cpp file, just before the "while (pfile_in_zip_read_info->stream.avail_out>0)...":
 
if ((pfile_in_zip_read_info->stream.avail_out==0) && (reached_eof!=0)) *reached_eof= true;
 
For me that solves the problem. But maybe I am wrong.
What do you think of this bug, and this possible bug correction?
 

Another question I would like to ask is:
Is there a way or a plan to build multi-volumes zip?
 

PS: Being french I apologize by advance for my possible bad english. Smile | :)
 
Thanks,
Gg
Questioni am getting following errors. - i included zip.h file in my source codemembernishu_nishant25-Sep-08 20:11 
error LNK2019: unresolved external symbol "unsigned long __cdecl CloseZipZ(struct HZIP__ *)" (?CloseZipZ@@YAKPAUHZIP__@@@Z) referenced in function __catch$?walk@@YAXABUArgs@@@Z$0
 

error LNK2019: unresolved external symbol "unsigned long __cdecl ZipAdd(struct HZIP__ *,char const *,char const *)" (?ZipAdd@@YAKPAUHZIP__@@PBD1@Z) referenced in function __catch$?walk@@YAXABUArgs@@@Z$0
 

error LNK2019: unresolved external symbol "struct HZIP__ * __cdecl CreateZip(char const *,char const *)" (?CreateZip@@YAPAUHZIP__@@PBD0@Z) referenced in function __catch$?walk@@YAXABUArgs@@@Z$0
AnswerRe: i am getting following errors. - i included zip.h file in my source codememberdeveloper263-Oct-08 15:45 
You'll need to include zip.cpp as well.
General'Newer' sources and old/new bugsmemberT800G14-Sep-08 13:06 
I'm trying "more recent" sources (18.9.2005!) from author's homepage link (these at CP are older, and have more bugs), but it still doesn't adress password unzip error.
Quick fix (collected from posts, but god knows what bug lurks underneath):
It appears that the problem stems from an incorrect adjustment to the length of the unzipped file due to extra 12 bytes in compressed images for password keys.
 
Corrected Code in function unzReadCurrentFile by commenting out the adjustment of rest_read_uncompressed. This keeps final file size correct and allows the last 12 bytes to be decompressed:
 
unsigned int uDoEncHead = pfile_in_zip_read_info->encheadleft;
if (uDoEncHead>pfile_in_zip_read_info->stream.avail_in) uDoEncHead=pfile_in_zip_read_info->stream.avail_in;
if (uDoEncHead>0)
{ char bufcrc=pfile_in_zip_read_info->stream.next_in[uDoEncHead-1];
// pfile_in_zip_read_info->rest_read_uncompressed-=uDoEncHead;
pfile_in_zip_read_info->stream.avail_in -= uDoEncHead;
pfile_in_zip_read_info->stream.next_in += uDoEncHead;
pfile_in_zip_read_info->encheadleft -= uDoEncHead;
if (pfile_in_zip_read_info->encheadleft==0)
{ if (bufcrc!=pfile_in_zip_read_info->crcenctest) return UNZ_PASSWORD;
}
}

I also got this linker error in zip.cpp:
fatal error LNK1120:1 unresolved externals
Error	18	error LNK2019: unresolved external symbol __imp__GetDesktopWindow@0 referenced
in function "public: unsigned long __thiscall TZip::Add(wchar_t const *,
void *,unsigned int,unsigned long)" (?Add@TZip@@QAEKPB_WPAXIK@Z)	zip.obj
Explicit linking with user32.lib solved it.
 
Btw, Info-zip shelled out new zip3.0 sources (zip64, bzip2 support), and they work on unzip6.0 .
Will we ever have simple, useful (giving people just makefiles and no binaries makes no sense) zip/unzip codeConfused | :confused:
Questioncan I get filenames in the zip flie before I unzip the zip file ????memberlw84011-Sep-08 18:08 
thanks
AnswerRe: can I get filenames in the zip flie before I unzip the zip file ????membercrino2-Sep-08 21:40 
HZIP hz = OpenZip("\\simple1.zip",0);
  ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index;
  // -1 gives overall information about the zipfile
  for (int zi=0; zi<numitems; zi++)
  { ZIPENTRY ze; GetZipItem(hz,zi,&ze); // fetch individual details
    //ze.name         // the item's name.
  }
  CloseZip(hz);
Wink | ;)
GeneralPassword protected files not fully extracted.memberJohn Ritzenthaler29-Aug-08 10:17 
I zipped up files using a password.
When I unzip them I used this logic:
Open the zip file without a password
Try to extract the first file
If it fails with a passord error
Close the zip file
Ask for the password
Open the zip file WITH the password
 
I find that the last few bytes are missing from the extracted files.
GeneralLinker error :/memberMember 361251328-Aug-08 12:18 
Hello. I am using zip_utils with mingw.
 
I added unzip.cpp and unzip.h to my project.
In another file I added unzip.h and made this:
 
    HZIP hz = OpenZip("Data.zip",0);
    ZIPENTRY ze;
    int i;
    FindZipItem(hz,"test.bmp",true,&i,&ze);
    char *ibuf = new char[ze.unc_size];
    UnzipItem(hz,i, ibuf, ze.unc_size);
    delete[] ibuf;
    CloseZip(hz);
 
I compiled and got this errors:
 
undefined reference to `UnzipItem(HZIP__*, int, void*, unsigned int)'|
undefined reference to `CloseZipU(HZIP__*)'|
 
Whats wrong Confused | :confused:
GeneralRe: Linker error :/memberKim Moung Soo25-Apr-10 11:50 
I got same link problem on VS2008 MFC program. Cry | :((
Final I got way to avoid that problem.
Adjust location of include files.
 
#include "stdafx.h"
 
/// Put those two file just after "stdafx.h" to avoid link problem.
#include "unzip.h"
#include "zip.h"
GeneralGetting "ZR_FLATE - an internal error in the de/inflation code" while unzippingmemberGreen Fuze7-Aug-08 6:42 
Hey
 
I zipped/unzipped with the code perfectly, now I'm trying to unzip a file I zipped using ZipLib in c#, and I'm getting this error.
 
Any ideas what seems to be the problem?
 

 

Thanks!
GeneralLinking problems in examplesmemberGreen Fuze4-Aug-08 23:11 
Hey,
 
First of all - Great job!
That is the first zip API that is really easy to use!
 

But, I'm having a linking problem.
 
I'm getting a linking problem in my project, and when I couldn't solve it I tries to compile the examples, and I got linking problems as well.
This error message comes from the "simpleVS" solution:
Error	2	error LNK2019: unresolved external symbol "unsigned long __cdecl FindZipItem(struct HZIP__ *,char const *,bool,int *,struct ZIPENTRY *)" (?FindZipItem@@YAKPAUHZIP__@@PBD_NPAHPAUZIPENTRY@@@Z) referenced in function _main	simple.obj	
 
I'm getting the same error for all the functions.
In the article it says that there are not libs to add, so I'm pretty stuck with that...
 
Any ideas???
 
Thanks!!!
GeneralRe: Linking problems in examplesmemberGreen Fuze5-Aug-08 1:49 
Oops, never mind, my mistake!
 
long day.... Smile | :)
General!(clean, elegant, simple, C++)memberAAO30-Jul-08 5:31 
clean, elegant, simple, C++/ - none of the above. Code is close to unreadable, does not qualify as good c++, it is horrific c code. I am surprised it gets such a high review points. Functional - defiantly, but nothing else.
QuestionHow to pack a folder with files?memberPopugay28-Jul-08 4:22 
How to pack a folder with files?
ZipAddFolder (hz, " lolo \\ ");
only a folder, without files
GeneralAppendZipmemberbenericrice7-Jul-08 9:54 
Might anyone have implemented or tried to implement an AppendZip to go along with OpenZip and CreateZip? That way it doesn't take so long to just add a file to a large zip?
GeneralThank you!memberjipai8-Jun-08 4:14 
I just want to say thank you to the author for his work. I spent many days trying to add info-zip C library into my MFC C++ app, and it was hell! Look at the bulk of ifdefs and variables names in one single letter in info-zip. These 4 files here work for me within minutes, yes I mean minutes! Whoever doesn't like it should either come up with something better, or shutup and go screw your arrogant self.
GeneralRe: Thank you!membertday507-Aug-08 13:28 
I agree 100%.
I like the -Keep it simple- approach.
 
-tday.
GeneralRe: Thank you!membersergiocody13-Aug-08 5:13 
I tottaly agree.
thank you!!!!
GeneralRe: Thank you!memberdeveloper263-Oct-08 15:43 
Agreed - its very useful and works GREAT on Windows Mobile
GeneralPassword and UNICODEmemberwilliam.gonzales26-May-08 5:16 
Hi Lucian, your article is great!! Smile | :)
I have an UNICODE app but the password for zip is non UNICODE, as we can see in the TZip class constructor:
 
TZip(const char *pwd)
 
What could happen if my app is used in Japanesse or another language with no ANSI chars? Does it mean that we only have to use ANSI chars for the pwd?
 
William GS
Generalcan't compile with vc9memberMember 45670619-May-08 23:13 
f:\projects\crypto\Rijandael\aestest\../../ZIP/zip.h(192) : error C2061: Syntaxfehler: Bezeichner 'IsZipHandleZ'
 
can anybody help ? Whats wrong ?Unsure | :~
GeneralRe: can't compile with vc9membertiancaiak15-Apr-09 23:20 
your project must include
 
#include
#include
#include

QuestionInfo-zip -&gt; zip utils cookbook?memberMillieMoo2-May-08 3:24 
Hi there,
 
Lets start with the thank you - your lib has been very useful to lots of people including me, so thanks - it greatly reduced the "learning curve" that needs to be followed to get zip-unzip functionality into an application.
 
However - the sources you have derived this project have moved on since you first created it - and I see that info-zip-unzip has a major release coming up to support large files, with some other fixes.
 
So I wonder if you feel like sharing the process that you used to produce this project - i.e. what bits of code came from where, why did you have to change the bits that you changed, what bits are irrelevant etc. I don't want to completely steal your ideas - think of this more as an offer of assistance. Ideally I'd like to update to the latest version, and then post the result (plus any info on how I did it) back to this project.
 
Thanks again,
 
MillieMoo
Generalusing the GCC compilermemberiain williams19-Apr-08 4:27 
i'm getting the error
line : 3728
File : unzip.cpp
Message : integer constant is too long for "long" type.
 
i've tried this code in visual studio and it worked perfectly. but i need to get it to work in GCC any tips?
 
thanks
Iain
GeneralRe: using the GCC compilermemberChiirong Yang4-May-08 16:04 
return (lutime_t)((i-116444736000000000LL)/10000000);

gcc must has specific LONGLONG type "LL"
Generalunzip failurememberredliu17-Apr-08 5:16 
if you unzip a zip file with password,it will lose the last 12 WORD in binary.maybe you are unaware of it when you unzip .txt file or .doc or picutures because it doesn't matter if you lose the last few words,but if you unzip .exe ,the result is annoying. is there anybody know what to do?
GeneralRe: unzip failurememberredliu17-Apr-08 5:35 
yes,i've got the answer by MetsoGuy 16 Mar 06.
many thx to metsoguy and lucian
GeneralRe: unzip failuremembermousam.dubey25-Apr-08 0:09 
Hi,
Can you please share the answer/fix for this problem with the others?
I am also facing the same issue and it would be of great help if you can please let me know the fix for this issue.
 
Thanks & Regards,
Mousam Dubey
GeneralRe: unzip failurememberustcSongLei26-May-08 21:39 
here is the answer.
http://www.codeproject.com/KB/files/zip_utils.aspx?msg=1410683#xx1410683xx[^]
GeneralRe: unzip failuremembermousam.dubey3-Jun-08 3:07 
Thanks a ton Smile | :)
GeneralRe: unzip failurememberalex777775-Nov-08 0:23 
Replace in line 3516 pfile_in_zip_read_info->rest_read_uncompressed-=uDoEncHead;
to //pfile_in_zip_read_info->rest_read_uncompressed-=uDoEncHead;
GeneralModify ZIPmemberKarl Runmo17-Apr-08 4:50 
If one want to delete a file from a zip archive, it seems unnecessary having to unzip the files in the archive and then rezipping them again, doesn't it?
Isn't there any way to disassemble the zip archive and reassemble again with the wanted files only?
/Karl

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 19 Sep 2012
Article Copyright 2004 by ljw1004
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid