You are not logged in.
Hi!
I have 1.zip file with some files and 1 empty (!) folder:
_1/1 (it is empty folder)
_1/file1.txt
_1/file2.txt
...
Archive is valid (created with PeaZip and successfully unpacked with 7z and PeaZip).
When i trying to unzip this zip, i take error -3. Undef USEINLINEASM not help (code=-3 gets in function inflate as i understood).
When zip archive created without empty folders (created with 7z, PeaZip or TZipWriter) there are no trouble to unpack.
In experiments i see, that this trouble is coming when empty folder in zip.
What i do wrong?
(Delphi XE, Win7 64bit)
//uses SynZip, SynZipFiles;
// ZEZipUnpackSyn('c:\1.zip', 'c:\temp\1\'); //c:\temp\1\ is exist
function ZEZipUnpackSyn(ZipName: string; PathName: string): boolean;
var
zr: TZipReader;
i: integer;
stream: TFileStream;
s: string;
t: integer;
_fname: string;
begin
result := false;
if (not FileExists(ZipName)) then
exit;
t := Length(PathName);
if (t > 0) then
if (PathName[t] <> PathDelim) then
PathName := PathName + PathDelim;
if (not DirectoryExists(PathName)) then
exit;
zr := nil;
try
zr := TZipReader.Create(ZipName);
for i := 0 to zr.Count - 1 do
begin
stream := nil;
_fname := zr.Entry[i].ZipName;
s := ExtractFilePath(_fname);
if (length(s) > 0) then
ForceDirectories(PathName + s);
s := ExtractFileName(_fname);
if (length(s) > 0) then
try
stream := TFileStream.Create(PathName + _fname, fmCreate);
zr.GetData(i, stream);
finally
if (Assigned(stream)) then
FreeAndNil(stream);
end;
end;
result := true
finally
if (Assigned(zr)) then
FreeAndNil(zr);
end;
end; //ZEZipUnpackSyn
Offline
Could be an issue in our class, in fact.
It does not handle "empty folders".
It handle folders, as part of file names.
You can create a ticket at http://synopse.info/fossil
Offline
Unfortunately this fix not work: zip file with empty folder unpack, but unpacked files are corrupted and zip without empty folder take error -3.
I make small test console application tstsynunpack.zip (~4Kb) with 3 zip files:
1.zip - have empty folder "1" and file "somefile.txt"
2.zip - have empty folder "SOME_DIR" and file "1.txt"
3.zip - no empty files, just 2 files: "1.txt" and "SOME_DIR/somefile.txt"
1.zip and 2.zip unpackeds, but unpacked files are corrupted. 3.zip take error -3.
Offline
The supplied file has a "extra field length" entry in its header not equal to zero, BUT it should be zero, according to the layout.
See http://www.pkware.com/documents/casestudies/APPNOTE.TXT and "local file header" definition.
If I recompress the file using TotalCommander, for instance, this TFileHeader.extraLen=0, and the decompression works as expected!
Are you sure PeaZip do not have a problem of file layout?
Offline
It is strange. We use far manager + pkzip 4.0 (old, but work) and PeaZip 4.3 (for now migrate from pkzip to pea) and we have not troubles with zips (as i remember).
I repeat unpack experement tstsynunpack2.zip:
1.zip, 2.zip and 3.zip created with pkzip 4.0.
1pea.zip, 2pea.zip and 3pea.zip - with peazip.
1total.zip 2total.zip and 3total.zip - with TotalCommander.
Results:
1. TZipReader TotalCommander zips unpack successed!
2. TZipReader pkzip and peazip zips: files are corrupted.
3. TZipReader unpacked corrupted files from pkzip and peazip not equal.
4. pkzip successed unpack pea and totalcommander zips.
5. peazip successed unpack pkzip and totalcommander zips.
6. TotalCommander successed unpack pea and pkzip zips.
I am confused. It is seen like PeaZip and PkZip are similar and TotalCommander not similar.
Offline
I suspect our TZipRead class use the "extra len" field value from the directory entries, whereas it should use the value in the local header instead.
Most zippers have both fields equal 0, but your 1.zip file does not.
I'll check and fix that.
Offline
I've changed the code to use the local file header "extra len" field to position the reading cursor.
Some code refactoring was needed (some new methods added).
Seems to fix the issue.
See http://synopse.info/fossil/info/bb09abeb24
Thanks a lot for your feedback.
Offline
Good news:
1. Previous zips unpacks successful!
2. Tested big (3Gb logs packed into ~200mb) zip unpacked successful!
But when i trying unpack chart1.ods (it is zip) created with LibreOffice calc 3.4.3 then got infinite loop: tstsynunpack3.zip (~24Kb).
Get infinite loop on 2 entry:
Entry=2 ("ObjectReplacements\Object 1"):
GetData (SynZipFiles.pas line 550) =>
UnCompressStream (SynZip.pas line 4511) =>
in repeat loop get code = Z_BUF_ERROR
May be it is happens because first entries have another compression?
Entry=0 ("mimetype") without compression
Entry=1 ("meta.xml") without compression
When this document uncompress by TotalCommander and repack then unpacks fine.
Offline