|
|
Comments and Discussions
|
|
 |

|
I'm surprised nobody reported that ZippAddDirW (unicode version) doesn't work.
Even the ZipDir.c example doesn't work : it only creates an empty zip file. I'm using Windows 7.
Also replace_slashesW should not cast wchar_t to short and then compare short to char...
|
|
|
|

|
Usefull and REALLY portable library, just updated for a C development on pos ingenico
Thank you!
|
|
|
|

|
Thank You Supply This Code,Thank You
China HappyTrace!
|
|
|
|

|
The code works for multiple filed zip files.
Has anyone successfully extracted anything from a zip file which contained only one compressed file?
Thanks,
Rich
|
|
|
|

|
I think... Your Zip Source Support Level between 1 to 8. but I need Level 0.
So, i tried edit your source in zip.cpp.
ZRESULT TZip::ideflate(TZipFileInfo *zfi)
{
state->param=this; state->level=8; state->seekable=iseekable; state->err=NULL;
}
Level 8 is max level. I tried to change level from 8 to 0.
but not working.
i want to just store to zip file. not compress.
Please Help Me.
|
|
|
|

|
Is it possible to store a text comment inside archive?
|
|
|
|

|
the sample is wrong!!
wrong:
ZipAddFile(hz, "simple.bmp");
ZipAddFile(hz, "simple.txt");
OK:
ZipAddFile(hz, "file name", "file path");
ZipAddFile(hz, "file name", "file path");
|
|
|
|
|

|
Hi there,
I have a requirement thus here..
I already have a file in memory, so do not want to load it in again. The file was encrypted, so the decrypted ZIP is already in memory, and i dont wish it to reside on the hard drive.
Is this possible with LiteUnzip, therefore no files involved. If so, which functions in the API do i use?
Cheers
|
|
|
|

|
BUG: UnzipGetItemW Get Chinese FileName Error
if a zip file include a file of filename is chinese
use UnzipGetItemW will get a BAD file name.
|
|
|
|

|
exactly
so,I changed other method----zlib.
zlib is OK. But thanks the author all the same.
|
|
|
|

|
LiteZip has many bugs , but it is very eary for using ! thank you jeff!
|
|
|
|
|

|
I can't find ZipAddDir Function in LiteZip.h file.
So I can't compress some folders.
my development environment is visual Studio 2008.
and i'm developing MFC Application.
|
|
|
|

|
yes,I can only find a 'ZipAddFolder' in it.So we can make it ourselves!
|
|
|
|

|
Hi,
first of all great work! Very easy to use.
But if i am using UnzipOpenFile() to open an password protected zip with a wrong password it does not return ZR_PASSWORD, instead it returns ZR_OK. Than I can extract the files but they're empty.
I think this is a bug?
Greetings,
0xFF
|
|
|
|

|
At the top of LiteUnzip.c is a set of preprocessor switches for WIN32 vs Linux, and the WIN32 section includes a test for CP_UTF8. I'm using Visual Studio 2008 SP1 on WinXP SP3 and I'm finding that WIN32 is defined and so is CP_UTF8, this means that DIRSLASH_CHAR is not defined, which fails the compilation. Here is the code indented for readability:
#ifdef WIN32
...
#ifndef CP_UTF8
#define CP_UTF8 65001
#define DIRSLASH_CHAR
#endif
#else
...
Question: Why is the definition of DIRSLASH_CHAR nested within the CP_UTF8 test?
Question: Did the state of CP_UTF8 being defined/not defined change? All three settings of "Character Set" in Visual Studio ("Not Set", "Use Unicode Character Set", "Use Multi-Byte Character Set") have CP_UTF8 defined, to the value of 65001.
-Jason
|
|
|
|

|
As a test of LiteZip I tried running UnzipFile on the file LiteZip.zip renamed to test.zip (therefore no changes were needed to be added to the code).
Unfortunately UnzipFile fails when it tries to unzip:
C:\Documents and Settings\harrison\Desktop\LiteZip\UnzipFile\Debug\ZipDir\MyDir\
as it "Can't create/open file"
Has anyone else come across this problem? (I don't see any reports on it.)
I'll take a closer look at this problem but thought you all should know. This is the 40th entry in the zipfile, and all previous entries in the LiteZip.zip file are files, not directories.
-Jason
|
|
|
|

|
Did you get this resolved?
|
|
|
|

|
I do not recall if I did. Unfortunately it was at a previous employer so any changes to the source that I might have made are no longer available to me.
|
|
|
|

|
I have used the ZipAddDir function to create my zip, which seems to create the zip but when I try to open the archive I get the following error message from windows: "Windows cannot open the folder. The Compressed (zipped) Folder 'C:\Temp\Dump\MyTest.zip' is invalid.
I followed the exmaple you provided with the source, I wonder if you could tell me where I am going wrong.
Here is my source:
ZipCreateFilePtr *lpZipCreateFile;
ZipAddDirPtr *lpZipAddDir;
ZipClosePtr *lpZipClose;
ZipFormatMessagePtr *lpZipFormatMessage;
//get the zip dll
zipDll = LoadLibrary("LiteZip.dll");
if (zipDll !=NULL)
{
// Get the addresses of 4 functions in LiteZip.dll -- ZipCreateFile(), ZipAddDir()
// ZipClose(), and ZipFormatMessage.
lpZipCreateFile = (ZipCreateFilePtr *)GetProcAddress(zipDll, ZIPCREATEFILENAME);
lpZipAddDir = (ZipAddDirPtr *)GetProcAddress(zipDll, ZIPADDFOLDERNAME);
lpZipClose = (ZipClosePtr *)GetProcAddress(zipDll, ZIPCLOSENAME);
lpZipFormatMessage = (ZipFormatMessagePtr *)GetProcAddress(zipDll, ZIPFORMATMESSAGENAME);
TCHAR buffer[MAX_PATH];
TCHAR buffer2[MAX_PATH];
CString strZipPath("C:\\Temp\\Dump");
SetCurrentDirectory(strZipPath);
result = GetCurrentDirectory(MAX_PATH, buffer);
if (!(result = lpZipCreateFile(&hz, _T("MyTest.zip"), 0 )))
{
strZipPath = "C:\\Temp\\Dump\\MiscFiles";
SetCurrentDirectory(strZipPath);
result = GetCurrentDirectory(MAX_PATH, buffer2);
if((result = lpZipAddDir(hz, &buffer2[0], result+1)))
{
lpZipClose(hz);
AfxMessageBox("Directory zip failed");
}
}
}
I'd appreciate any help you could give.
Keith
|
|
|
|

|
Realized what I had done wrong, forgot to close the archive doh!
|
|
|
|

|
In the function dosdatetime2filetime there is a bug for the seconds.
*dostime |= (WORD)((st.wSecond*2)&0x1f);
should be
*dostime |= (WORD)((st.wSecond/2)&0x1f);
Without this change, I have sometime bugs when reading generated zip file. (with the liteUnzip or winrar)
|
|
|
|

|
LiteUnzip don't support in unicode...
|
|
|
|

|
Well, I've seen a *.lib is there, however, it will only produce *.so files which to my knowledge are Linux (and derivatives) only; only Cygwin works with .so files, but afaik MinGW doesn't.
Has anyone built a liblite.a or some sort?
This will probably make it easier to compile the library into MinGW projects. Zip-Utils does what I need, however, it's C++ but I'm coding ANSI-C.
------------
Andreas
|
|
|
|

|
This is awesome work, thank you!
Been looking for some time to get the zlib code persuaded to unzip to a _memory buffer_ instead of a file!
All my attempts resulted in some data, but arbitrarily put into location! (i. e. the 1767. byte was at location 258 etc., probably due to the original code only reading 8K chunks - contrib/miniunz.c, line 372)
OK, tested it:
UnzipToMemRaw did NOT work when compiled with MinGW/GCC. In the language of the Windows locale, it says "The specified module was not found".
It cannot be a missing DLL because I have it in both the UnzipToMemRaw/ directory and the root directory of the package.
[EDIT]
Found it out myself!
It's a bug in the code, which should be fixed.
The debug code was left in, and so is the directory! Smile
[unziptomemraw.c:49]
if ((unzipDll = (HMODULE)LoadLibrary(_T("../LiteUnzip/Debug/LiteUnzip.dll"))))
must be
if ((unzipDll = (HMODULE)LoadLibrary(_T("../LiteUnzip.dll"))))
and all of a sudden it works!
|
|
|
|

|
your zip project is much eary for user, but more bugs is posted on codeproject.
Thank you.
|
|
|
|

|
Hi,
Great job.... but I have one problem. I am using your \ZipFile example and when I zip files it I get Error Message: Aborted. The file iz zipped correctly though. What could be the problem???
Thanks,
DIno
|
|
|
|

|
I have some problem in using UnzipOpenBuffer()interface,my routine is as follows:
use ZipCreateBuffer() to create zipbuffer,
use ZipAddBufferA() to add string to zipbuffer through HZIP;
use ZipGetMemory() to get archived data memeory address (TZIP distination member)and data length;
all the above is ok;
But when i use the archived memory address got by ZipGetMemory()interface in UnzipOpenBuffer(), the retcode is 6,means corrupt data; I dont know why? Anyone has the same problem or anyone would help me?
retCode = ZipGetMemory(huz,(void **)&AfterCompressedBuffer,&AfterCompressed,(HANDLE *)&xp);
retCode = UnzipOpenBuffer(&hunzip,AfterCompressedBuffer,AfterCompressed,0);
|
|
|
|

|
1. the bug is belong in unzip.
2. the size of origin file must bigger than 16348.
3. unzip will lead failed!
4. line 3094 //tunzip->EntryReadVars.RemainingUncompressed -= uDoEncHead; ----> error
|
|
|
|

|
HOw are you jeff?
-천재원주-
|
|
|
|

|
I found a bug that causes a file to be unzipped minus the last n bytes, where n = the length of your password + 1. In my case, the file being unzipped was itself a zip file.
I commented out this line ( unzip.cpp, line 3517 ):
//pfile_in_zip_read_info->rest_read_uncompressed-=uDoEncHead;
and it now works properly.
|
|
|
|

|
It appears not to be the password length, but the length of the encryption header. By coincidence my password length was 11
|
|
|
|

|
Sorry, posted to wrong site - the bug is in the code this project was derived from.....
|
|
|
|

|
in liteunZip.c
struct ZIPENTRYINFO holds
unsigned long dosDate; // last mod file date in Dos fmt 4 bytes
Why only last modification date ?
Why not Last Access or creation time.
Is this reason why we do not get creation and last accesstime of unzipped file which is zipped with LiteZip.
Thanking in anticipation
sachin
|
|
|
|

|
Can the program preserve date timestamps when zip and unzip using LiteZip ..
e.g. if i used litezip and compress a file and use liteunzip to decompress will it preserve original creation, modification, access dates ?
thanks
sachin
|
|
|
|

|
Thank you for posting such a nice work. I want to use the function ZipAddDir() which has its header as given below:
//////////////////////////////////////////////////////
#define ZipAddDir ZipAddDirW
DWORD WINAPI ZipAddDirW(HZIP, const WCHAR *, DWORD);
I want to know about third argument which is offset value. I found that if I use offset value -1 then it is working properly. What is the correct value ?
Could you please explain? Also, any help to use Progress Bar during zipping ?
Thanking you in advance.
Regards,
Johnarg
Johnarg
|
|
|
|

|
Yes. ZipDir demo source code shows ZipAddDir should be used in this way:
result = strlen(&buffer[0]);
ZipAddDir(hz, &buffer[0], result + 1);
The offset can be used to control relative path in Zip file. Aobe code keep the original whole path.
|
|
|
|

|
I modded LiteZip.c/.h to support deletes and adds to an existing zipfile without having to decompress & recompress. If the author is interested, let me know.
modified on Saturday, June 7, 2008 5:19 PM
|
|
|
|

|
Hi,
I am interested in your changes. Can you please forward them to my email via fuqian@gmail.com? Thanks.
Best,
Fu Qian
|
|
|
|

|
When I try to add a file, using the example code:
ZipAddFile(hz, "simple.bmp");
I get a build error:
error C2660: 'ZipAddFileA' : function does not take 2 parameters
which is consistent with the declaration in LiteZip.h
DWORD WINAPI ZipCreateFileA(HZIP *, const char *, const char *);
Am I missing something obvious here?
Thanks to whoever can help..
|
|
|
|

|
when i add local compress(zip/rar) file into created zip file, no error occurred, but open this created zip file with WinRar, an error message displayed that created zip file is broken, why?? and i add other type file to this created zip file, open it with WinRar, no error. can not add compress file(zip/rar) into created zip file?
jacky_zz
2008-4-30
|
|
|
|

|
Litezip/Liteunzip is great packaging aroung JL. Gailly's original code (that widely available), especially fast/samll foorptint compared to other wrappers around.
However, I VERY STRONGLY SUSPECT a quite major difficulty, that is:
LiteZip compressing algorithm is hopelessly confused with files that are already in compressed (ie. PKZIP) format: whenever you request LiteZip to make an archive from a mix of "regular" and compressed (such as Windows .zip and/or Linux .gz files), the resulting archive cannot be retrieved by other unzipping programs: the zipped files contents seem to be compressed to ZERO size, with a zero CRC value); that' s, at least, what industry ZIP programs report (Winzip 9 ...).
I am afraid I don't have the time to go down tracing the code to see what' s going wrong, I might suggest that Litezip should discover that source file is already compressed (just by detecting the various "PKxx" record markers), copy file to output stream without any attempt to compress any further, while marking file's header as uncompressed, not deflated; does it make sense ?
Besides this, a very good piece of work.
Jean-Henri
|
|
|
|

|
I just figured out that the problem is because a bug inside the code.
The library will just "STORE" the already compressed file into the package. Inside the istore function, you need put "tzip->csize += cin;" inside the while loop too, which is only put outside the loop right now. That is why it always gets 0 size.
|
|
|
|

|
First of all, thanks for the excellent library.
Is there any way to avoid storing the path in the ZIP file? For ex, if the zip is "C:\Somewhere\Sample.zip" and I add two files to it, "C:\Another Place\First.doc" and "C:\One more place\Second.doc", the archive stores the paths within the zip archive. Is there a flag or setting to avoid that and not store a path, i.e., the un-zip (using say WinZip) will just unzip to selected folder. I know there is a flag within WinZip to ignore the file paths, but I wanted to know if it can be done while zipping.
|
|
|
|

|
Is it allowed to use your Code in a commercial application if yes how are the licensing details?
|
|
|
|

|
The licensing details are the same as the code it is based upon, zlib at http://www.gzip.org/zlib by Jean-Loup Gailly and Mark Adler.
|
|
|
|

|
Hi Jeff, Great article and equally great work. What I was trying to find out is how one could get the CRC values for the zip archive file and each file individually. I really actually only need the CRC of the archive file itself. It appears the code is in place but this information is not exposed or maybe I'm just missing it. We store the CRC value in a database along with the archive file itself so I'll need to get this value prior to incorporating you efforts into my small program. Thanks again Jeff or to whomever replies to this message. Craig
|
|
|
|

|
Been looking for a mature and flexible compression solution. Standard C is the way to go to reduce bloat, increase flexibility, and ease porting code. While I have noticed readers commenting on specific bugs and issues, I think LiteZip is a candidate for further development.
However, I would prefer a static library, instead of a dynamic one, so that will be my primary focus delving into it...
Thank you for your efforts, they are much appreciated.
|
|
|
|

|
Hello,
thanks for this library.
I have a little problem when i unzip a file with liteunzip.
Some files (a lot) are not complete, some bytes are missing.
I tried to unzip the file with izarc and everything is ok.
So the archive file is correct and maybe there is a bug in the function.
Can you help me ?
Thanks very much.
Alexandre GAMBIER
here my code :
// Ouvre le fichier zip
if( UnzipOpenFile( &hZIP, szZIPFile, GLB_ZIPPASSWORD )!=ZR_OK )
return( FALSE );;
// Définit le répertoire de sortie
if( UnzipSetBaseDir( hZIP, szDstDir )!=ZR_OK )
{
UnzipClose( hZIP );
return( FALSE );
}
// Extrait tous les fichiers
memset( &tZipEntry, 0, sizeof( tZipEntry ) );
// Combien de fichier ?
tZipEntry.Index = -1;
if( UnzipGetItem( hZIP, &tZipEntry )!=ZR_OK )
{ UnzipClose( hZIP );
return( FALSE );;
}
dwEntryCount = tZipEntry.Index;
// Extrait les fichier un par un
wErr = FALSE;
for( tZipEntry.Index = 0; tZipEntry.IndexAdd( tZipEntry.Name );
}
}
// ferme le zip
UnzipClose( hZIP );
if( wErr!=FALSE ) return( FALSE );
return( TRUE );
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Easy to use, small-footprint DLLs to let your app create zip archives, and extract the contents of them. Useful for C, C++, VB, and other languages. Works for Win32 and Linux
| Type | Article |
| Licence | LGPL3 |
| First Posted | 9 Mar 2006 |
| Views | 205,213 |
| Downloads | 3,496 |
| Bookmarked | 141 times |
|
|