#1 Re: Low level and performance » TZipReader Unzip zip with empty folder trouble » 2013-01-11 18:26:40

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.

#2 Re: Low level and performance » TZipReader Unzip zip with empty folder trouble » 2013-01-11 07:09:28

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

#3 Re: Low level and performance » TZipReader Unzip zip with empty folder trouble » 2013-01-10 18:50:08

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.

#4 Low level and performance » TZipReader Unzip zip with empty folder trouble » 2013-01-09 11:54:54

Replies: 8


I have 1.zip file with some files and 1 empty (!) folder:
_1/1  (it is empty folder)
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;
  zr: TZipReader;
  i: integer;
  stream: TFileStream;
  s: string;
  t: integer;
  _fname: string;

  result := false;
  if (not FileExists(ZipName)) then

  t := Length(PathName);
  if (t > 0) then
    if (PathName[t] <> PathDelim) then
      PathName := PathName + PathDelim;

  if (not DirectoryExists(PathName)) then

  zr := nil;
    zr := TZipReader.Create(ZipName);
    for i := 0 to zr.Count - 1 do
      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
        stream := TFileStream.Create(PathName + _fname, fmCreate);
        zr.GetData(i, stream);
        if (Assigned(stream)) then

    result := true

    if (Assigned(zr)) then
end; //ZEZipUnpackSyn

Board footer

Powered by FluxBB