CZip/CUnzip Classes for Zipping and Unzipping Files
This article describes classes to zip and unzip files. The classes use the gzip GNU source code (gzip-1.2.4a). This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License. See the file COPYING included in the source code.
The target DLL exports two classes:
- CZip (for zipping files)
- CUnzip (for unzipping files)
Description:
A CZip or CUnzip object is built with a file name. Then, the SwapSize() method must be called on that object (with one argument which is the target file name) in order to zip/unzip the file. SwapSize() may throw a CZipException exception. A message bound to the exception can be retrieved using the GetString() method. Exceptions are thrown when:
- the source file does not exists or cannot be opened for reading
- the target file cannot be created (for example, this file already exists)
- the gzip code is returns an error; in this case, the message bound to the exception contains the message returned by the gzip source code via stderr
To use CZip or CUnzip, do the following:
- include czip.h in your project
- link your project with zipdll.dll using zipdll.lib
- move zipdll.dll to the same directory as your executable
Note: You can also dynamically link to zipdll.dll (I haven't tested that, though).
Here's an example of how to zip a file:
try
{
CZip myFileToZip ("file_to_zip_name");
myFileToZip.SwapSize ("file_zipped_name");
}
catch (CZipException e)
{
cout << "problem while zipping : " << e.GetString() << endl;
delete pExcep;
}
Notes:
- The CZipped files can be unzipped using WinZip if its name doesn't have a ".zip" extension.
If the zipped file has a ".zip" extension, WinZip won't be able to open the file.
- An archive constructed with WinZip can be extracted using a CUnzip object if it contains only
a single file.
- In order to know the error messages written by gzip code on stderr, a temp file is built and attached to stderr. If this temp file cannot be built (no way to write to the current directory for example), the error messages from gzip code (if any) will not be known, but the zip/unzip operations can still be achieved.
Date Updated: 2 March 1999

Comments
Jordan shoes mentioned Gene to buy the variety, a margin of Nike
Posted by TaddyGaffic on 04/20/2013 03:50pmBut in an e mail concerning the LSU activity from South Carolina on October 13, the faculty included the image but digitally erased the cross. The picture was in any other case untouched. A minimum of 15 folks have already been injured as Polish and Russian football enthusiasts clashed in Warsaw forward of your teams' 1-1 attract.. Once I have said, the soccer cleats by [url=http://markwarren.org.uk/goodbuy.cfm]nike free run[/url] Adidas have the similar characteristics, therefore in order to know all of them, then expect to have a lengthy list. Obviously, those are the same in ways that Adidas is the one brand that they carry. The lightness of the weight of the materials used in making the Adidas soccer cleats is definitely the main reason why the soccer cleats the manufacture and they are sold in the market are lightweight too. Pokhara is our base for this aerial playground. The [url=http://northernroofing.co.uk/roofins.cfm]nike free uk[/url] choppy green hills all around offer a lifetime's worth of glorious flying possibilities, many of them still virgin. I Alpine (forward) launch, leaning forward, pulling my lines taut, with my glider laid out in an arc behind me. That is, you want something whose design is similar to that of a ski boot. That means that the inside removable liner, is a moldable type. ( it forms to the contours of your foot, providing maximum comfort and support.) You want the boot itself, made of a stiff plastic, or waterproof outer shell, again for support and insulation. Self defense purposes purposes dealing with #3 * Having the ability to contemplate [url=http://northernroofing.co.uk/roofins.cfm]nike free run[/url] gets and in addition leg techinques will not likely typically injure. I propose you will get out there applying reside training goods and rehearse fighting and also staying get to that has a close friend and even martial arts university undergraduate. Physical exercise diffusing strikes, using images, supplying photos, and in addition keeping crystal clear focused although becoming bombarded with plenty hits in addition to tennis shoes
ReplyUNZIP to a buffer or memory
Posted by Legacy on 10/10/2003 12:00amOriginally posted by: Rajesh Sonti
Using c or c++ program while uncopressing encountered zip file inside a zip file,how to read the contents of the inner zip file without extracting it to hard disk .
I could read the metadata(File name,size,creation time etc.,) for the outer zip contents since it is on hard disk and absolute path for its contents are known.But the inner zip file does not have any absolute path to read metadata for its contents, moreover i do not want it to extract to temp folder to read the metadata instead i want it to explode in memory and read the metadata of its contents.How I can do that using c or c++.
It is as good as uncompressing the inner zip file to a buffer.
please provide me code or info regarding this..
thanks,
ReplyRajesh Sonti
Compression Level?
Posted by Legacy on 09/15/2003 12:00amOriginally posted by: MindBlaster
Just wondering about the compression level.
Is it set to default or maximum?
If it is changeable, then where?
Thanks for a superb source! :)
// MindBlaster
Replyvery good..!!
Posted by Legacy on 03/27/2003 12:00amOriginally posted by: Seo won
thanks very much!!
your class is very helpful to me..!!
have a nice day~
ReplyHow to zip a folder
Posted by Legacy on 02/24/2003 12:00amOriginally posted by: Silvere
Any code to zip a complete folder. Is there a better solution instead of using CInfoZip class.
ReplyNeed C++based code(.dll)
Posted by Legacy on 10/09/2002 12:00amOriginally posted by: rani
Its is completly c based code ,Can u provide me c++ based code!
Replyyou can open the zipped file with winzip when it has a .gz extension
Posted by Legacy on 05/20/2002 12:00amOriginally posted by: icestar
you can open the zipped file with winzip when it has a .gz extension,for it only be deflated,while not been archived!
ReplyHow to zip directory
Posted by Legacy on 12/09/2001 12:00amOriginally posted by: Kurt
Hi
Does anybody know how to zip files in directory in one zip file with CZip
Reply
What about a static library?
Posted by Legacy on 10/16/2001 12:00amOriginally posted by: Rimantas
Hello, all,
Is there a static library, or could anybody help making one?
Thanks for help
ReplyRimantas
How can I uncompress a memeroy data in "deflate" format? Who can help me?
Posted by Legacy on 03/27/2001 12:00amOriginally posted by: Bright
I have got the compressed data block in deflate format,such as "0x2b,0x49,0x2d,0x2e,0x51,0xa8,0xca,0x2c,0x50,0x28,0x49,0xad,0x28,0x29,0x31,0x42,0x03,0x00". Who can help me uncompress it?
ReplyLoading, Please Wait ...