|
|
Comments and Discussions
|
|
 |

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

|
it worked great for me.
I created a simple zip archive in a snap.
Thanks!
|
|
|
|
|

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

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

|
Do you just not like whitespace?
|
|
|
|

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

|
would be nice - but not work with filesize over 4gb ...
sascha
|
|
|
|
|

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

|
I am getting this when compiling with MingW, in Dev-Cpp
3728 C:\*****\unzip.cpp integer constant is too large for "long" type
|
|
|
|
|
|

|
I forgot to mention, I am glad it is simple though... Good contribution but ugly c++.
|
|
|
|

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

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

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

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

|
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.
Thanks,
Gg
|
|
|
|

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

|
You'll need to include zip.cpp as well.
|
|
|
|

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

|
HZIP hz = OpenZip("\\simple1.zip",0);
ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index;
for (int zi=0; zi<numitems; zi++)
{ ZIPENTRY ze; GetZipItem(hz,zi,&ze); }
CloseZip(hz);
|
|
|
|

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

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

|
I got same link problem on VS2008 MFC program.
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"
|
|
|
|

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

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

|
Oops, never mind, my mistake!
long day....
|
|
|
|

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

|
How to pack a folder with files?
ZipAddFolder (hz, " lolo \\ "); only a folder, without files
|
|
|
|

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

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

|
I agree 100%.
I like the -Keep it simple- approach.
-tday.
|
|
|
|

|
I tottaly agree.
thank you!!!!
|
|
|
|

|
Agreed - its very useful and works GREAT on Windows Mobile
|
|
|
|

|
Hi Lucian, your article is great!!
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
|
|
|
|

|
f:\projects\crypto\Rijandael\aestest\../../ZIP/zip.h(192) : error C2061: Syntaxfehler: Bezeichner 'IsZipHandleZ'
can anybody help ? Whats wrong ?
|
|
|
|

|
your project must include
#include
#include
#include
|
|
|
|

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

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

|
return (lutime_t)((i-116444736000000000LL)/10000000);
gcc must has specific LONGLONG type "LL"
|
|
|
|

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

|
yes,i've got the answer by MetsoGuy 16 Mar 06.
many thx to metsoguy and lucian
|
|
|
|

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

|
Thanks a ton
|
|
|
|

|
Replace in line 3516 pfile_in_zip_read_info->rest_read_uncompressed-=uDoEncHead;
to //pfile_in_zip_read_info->rest_read_uncompressed-=uDoEncHead;
|
|
|
|

|
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 News Suggestion Question Bug Answer Joke Rant Admin
|
Adding zip/unzip easily, no LIBS or DLLs, with an elegant and powerful API.
| Type | Article |
| Licence | Public Domain |
| First Posted | 25 Jun 2004 |
| Views | 1,437,527 |
| Downloads | 18,796 |
| Bookmarked | 371 times |
|
|