|
void pointers are considered a no no in c++ code, but rather than complain about it, I'm thinking I might do something about it.
I would like to go through all the code and get rid of the void pointers by overloading functions, etc...
Now, I wouldn't want to do this if it means that I would only be doing it for myself, as it will probably be a little bit of work.
Do you, Hans Dietrich, mind if I do this, and then give you back the code?
|
|
|
|
|
No, I don't mind. I would ask that you test all of the functions that are affected by your changes.
|
|
|
|
|
The original (PK)ZIP format does not support Unicode filenames, but I saw that you mentioned porting Create() to Unicode and was wondering if you changed any of the internal structure to accomodate unicode filenames.
I did some testing on a japanese windows xp platform with your demo project. I renamed some of the files in the demo to have german umlaut characters in them - they were automagically replaced by their non-umlaut equivalent. However, using japanese characters worked like a charm, so I am thinking that ANSI filenames are used. Am I terribly mistaken?
Also, if it is not trivial to implement ZIP archives with Unicode filenames, do you know of any other freely available archive/compression library that I could use? I'd appreciate any input.
Thanks!
|
|
|
|
|
I have these lines in my code :
#include"XUnzip.cpp"
using namespace std;
void phase1(){
HZIP hz = OpenZip("c:\test.zip",0, ZIP_FILENAME);
ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index;
for (int i=0; i
|
|
|
|
|
Wow, that's strange it gives you that error becuase it doesn't give me that error.
But it's fairly simple to fix. Just make your string a non const pointer.
char FileName[_MAX_PATH];
strcpy( FileName, "C:\\test.zip" };
HZIP hz = OpenZip(FileName, 0, ZIP_FILENAME);
Incidently, make sure you use \\ instead of \ because \t is a tab.
|
|
|
|
|
Thanks for your answer.
My problem was that I used "\" instead of the "\\" !!
JJ
|
|
|
|
|
I tried to add new files to zip that was already created with this class. I was able to open the zip but was unable to add anything to it. I also tried adding edited versions of files already in the zip and had the same problem. My only alternative (so far) is to pull all the files out of the zip, add or edit the files and then zip them into a new zip. Anybody else have a better way?
|
|
|
|
|
in function TZip::ideflate()
You allocate the TState object in heap instead of stack, in order to avoid stack overflow. But the TState object only allocate once and its state will not be cleared in second time ideflate() is called.
So, if there are big files added into zip, and the big file was not the first one in zip, error will occur...it is terrible.
|
|
|
|
|
The destination of a file/directory can be specified in UnzipItem, but directories are always extracted to the current directory regardless of destination.
|
|
|
|
|
|
The ugly code makes me a bit sad. Considered rewriting it to be a bit more object oriented? Using void* when it's not nessecary just sucks.
Apart from that, I like it.
|
|
|
|
|
When you try to unzip files from a .ZIP with subdirs the unzipping returns an error 0x200 NO FILE. I have found a bug in Xunzip.cpp here:
void EnsureDirectory(const TCHAR *rootdir, const TCHAR *dir)
....
if (lastslash!=dir)
{
TCHAR tmp[MAX_PATH];
_tcsncpy(tmp, dir, lastslash-dir);
tmp[lastslash-dir] = _T('\0');
EnsureDirectory(rootdir,tmp);
name++;
}
TCHAR cd[MAX_PATH];
_tcscpy(cd,rootdir);
// 20-06-2005 COSMOS
// Here was: _tcscat(cd,name); Which isn't correct
// We have to create the last level directory like this:
_tcscat(cd,dir);
CreateDirectory(cd,NULL);
....
Hope this helps.
|
|
|
|
|
Who know how to delete a file from zip archive with these codes, or how to replace an existing file?
thanks .:->
|
|
|
|
|
hi!
i have created two zip files of same test.png file. when i check both zipped files with windiff.exe, they were different. but files inside the zip are same. whereas i did same with WinRAR and created two zip files of same test.png file. when i compared them with windiff.exe they were identical. could u plz tell me why this happens.
Thanks in advance.
Ahmad Jalil Qarshi
|
|
|
|
|
Hi.
I have the need to open an existing zip file, and add files to it...
Is this possible, since OpenZip(..) then ZipAdd(..) fails.
J
|
|
|
|
|
OK -- My bad!
Needed to include windows.h before the xzip.h file(s)
#include <windows.h>
#include "XZip.h"
#include "XUnzip.h"
Soz,
Joe
|
|
|
|
|
Hi Hans,
Good work. We use your class in our software and it works good. I found however that the files inside the ZIP are stamped with UTC time instead of local time.
GetFileInformationByHandle returns UTC times for a file, so they must be converted to local time before writing to Zip file. BTW, contrary to MSDN, my tests showed that GetFileInformationByHandle returns file time in UTC for both FAT and NTFS file system.
So here's a little code that needs to be added to XZip in order to convert file time from UTC to local time. Add it in GetFileInfo function, after GetFileInformationByHandle call. (Line 2189 in XZip.cpp of May 7th, 2003 release).
Thanks.
Damir Valiulin
BY_HANDLE_FILE_INFORMATION bhi;
BOOL res=GetFileInformationByHandle(hf,&bhi);
if (!res)
return ZR_NOFILE;
{
SYSTEMTIME stUTC, stLocal;
GetSystemTime(&stUTC);
GetLocalTime(&stLocal);
FILETIME ftUTC, ftLocal;
SystemTimeToFileTime(&stUTC, &ftUTC);
SystemTimeToFileTime(&stLocal, &ftLocal);
LONG64 uiUTC, uiLocal;
memcpy (&uiUTC, &ftUTC, min(sizeof(LONG64), sizeof(FILETIME)));
memcpy (&uiLocal, &ftLocal, min(sizeof(LONG64), sizeof(FILETIME)));
LONG64 uiTimeDiff = uiUTC - uiLocal;
FILETIME* pFileTimes[3] = { &bhi.ftLastWriteTime, &bhi.ftLastAccessTime, &bhi.ftCreationTime };
for (int i=0; i<3; i++){
LONG64 uiUTC_file;
memcpy (&uiUTC_file, pFileTimes[i], min(sizeof(LONG64), sizeof(FILETIME)));
LONG64 uiLocal_file = uiUTC_file - uiTimeDiff;
memcpy (pFileTimes[i], &uiLocal_file, min(sizeof(LONG64), sizeof(FILETIME)));
}
}
|
|
|
|
|
This is a very useful module! However:
When I add 50,000 small textfiles to a new zip-file, the resulting zip is about 25MB and contains 50,000 files, everything is fine.
When I add 60,000 small textfiles, the resulting zip file is about 8MB contains only 8,000 files, and no errors where reported from the ZipAdd function...
BR/Karl
|
|
|
|
|
Just want to say thanks for a change Good library, very easy to implement in my own and works without problems for my purposes
|
|
|
|
|
|
How to use XZip and XUnzip with password?
|
|
|
|
|
I just started useing the XZip and XUnzip code and ive been unable to find a way to change the compression level is there a way or is it just static? i found a struct that was named configuration_table and it seems to deal with compression levels but i cant figure out where i would change it in the code to make the compression level change.
thanks in advance
Greg
|
|
|
|
|
How do you set it to not readonly when unzipping files?
|
|
|
|
|
Here's solution.
In the file XUnzip.cpp line: 4100 replace:
h = ::CreateFile((const TCHAR*)dst, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, <br />
ze.attr, NULL);
for:
h = ::CreateFile((const TCHAR*)dst, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, <br />
ze.attr ^= FILE_ATTRIBUTE_READONLY, NULL);
|
|
|
|
|
hi !
i used XZip in my project , and its compiling properly.CreateZip is also working fine.However when i try to add a file to it using ZipAdd the program crashes.
its crashing on the following line in ZipAdd :
lasterrorZ = zip->Add(szDest, src, len, flags);
it gave a stack overflow error and crashed.
Any idea what might have gone wrong ?
Thanks for the help in advance
Regards
Kane
"Some guys hack just to get themselves a girlfriend.what a pathetic reason , huh ? "
|
|
|
|
|