#1 2016-04-30 09:07:49

5050
Member
Registered: 2016-04-30
Posts: 2

SynZip archive file displays as empty in windows explorer

Hi,

I'm using for first time SynZip unit V1.18 to generate zip files including full pathes for backup archive.

Generated zip files have content displayed correctly by 7Zip, but windows explorer (Win7, Win Server 2012) displays them as empty !


I wrote a tool with with php to explore zip contents, and I noticed that zip generated by synzip unit have table of content like:

C:\Users\Me\MyData\document1.txt
C:\Users\Me\Config\document2.txt
...

while zip generated by 7zip (for same content) have table of content like:

C:/Users/Me/MyData/
C:/Users/Me/MyData/document.txt
C:/Users/Me/Config/
C:/Users/Me/Config/document2.txt
...

It seems that
=> directory separator might be '/' instead of '\'
=> a directory path seems to be expected (before ?) its content

Am I right ?
Did I missed something ?



I tried to replace directory separator, using:

ZF.AddDeflated(Path, false, OptNivCompress, StringReplace(Path,'\','/',[rfReplaceAll]));

instead of:

ZF.AddDeflated(Path, false, OptNivCompress);

It works, but it is not enough, or not the problem: the zip file is always displayed as empty by windows...  :-(


As AddDeflated(Path, ...) fails with exception if Path is not a file, I tried a "brute" add with a new routine added in SynZip class:

procedure TZipWrite.AddDirName(const aDirName: TFileName);
Begin
  if Count>=length(Entry) then
    SetLength(Entry,length(Entry)+20);
  InternalAdd(aDirName,nil,0);
  Inc(Count);
End;

and a bit of glue in my unit to extract path and check if it is not already recorded:

    S := StringReplace(ExtractFilePath(Path),'\','/',[rfReplaceAll]);
    If PathsList.IndexOf(S) < 0 then
    Begin
      PathsList.Add(S);
      ZF.AddDirName(S);
    End;

Directory path seems to be now recorded in table of content, 7z still works with it, but windows still does not display zip file content. :-(((

I do not know zip internal structures enough to write something with more sense...
Any help will be welcome !

Last edited by 5050 (2016-04-30 09:50:33)

Offline

#2 2016-05-21 07:25:14

5050
Member
Registered: 2016-04-30
Posts: 2

Re: SynZip archive file displays as empty in windows explorer

I finally found what happened, something very stupid, thanks to Microsoft:

When the archive content is displayed inside windows explorer, files or directories that have a drive letter (that start with "[drive-letter]:/" ) are simply ignored and never displayed.

The very simple solution is to delete the colon (:) if it is present, making the drive letter to be seen as a directory, for the stored path.

  CleanPath := StringReplace(Path, '\', '/', [rfReplaceAll]); //optional replacement
  If (Length(CleanPath) >= 2) and (CleanPath[2] = ':') then
    Delete(CleanPath, 2, 1);
  ZF.AddDeflated(Path, false, OptNivCompress, CleanPath);

Offline

Board footer

Powered by FluxBB