Different behaviour of TZipper/TUnzipper(packages/paszlib) on Windows and Linux/Unix
Original Reporter info from Mantis: gcarreno @guscarreno
-
Reporter name: Gustavo Carreno
Original Reporter info from Mantis: gcarreno @guscarreno
- Reporter name: Gustavo Carreno
Description:
Hi there,
When you feed this 'subdir/a.txt' to AddFileEntry() you get:
- Windows: A file a.txt inside a folder subdir.
- Linux: A file a.txt inside a folder subdir.
BUT, if you feed this 'subdir\a.txt' to AddFileEntry() you get:
- Windows: A file a.txt inside a folder subdir.
- Linux: A file called subdir\a.txt. And YES, that's a valid Unix filename.
In my view, Entry.Filename can contain the platform specific slash AS LONG AS the Entry.Archivename will ALWAYS be platform independent and ZIP compliant by ALWAYS having the forward slash.
I've tried to follow the code to come here with a solution but I have to admit I've got my self lost.
I have a quick fix, but I think it's in the wrong place:
- Have both overloaded versions of AddFileEntry() make sure that Entry.Archivename is always using forward slashes.
But that only solves the Zipping side of things.
I think the fix should be in the writing AND reading of the Entry list to make sure that Archinename ALWAYS has forward slashes.
So maybe in the getter/setter of Archivename?
Cheers,
Gus
Steps to reproduce:
Run this code on a linux machine and see what happens:
[code=pascal]program project1;
{$mode objfpc}{$H+}
uses
Classes, zipper;
const
zipfilename = 'test.zip';
filename1 = 'project1.lpr';
filename2 = 'project1.lpi';
filename3 = 'subdir\a.txt';
filename4 = 'subdir\b.txt';
var
zip: TZipper;
unzip: TUnzipper;
begin
zip := TZipper.Create;
zip.Filename := zipfilename;
zip.Entries.AddFileEntry(filename1);
zip.Entries.AddFileEntry(filename2);
zip.Entries.AddFileEntry(filename3);
zip.Entries.AddFileEntry(filename4);
zip.ZipAllFiles;
zip.Free;
unzip:= TUnzipper.Create;
unzip.Filename:= zipfilename;
unzip.OutputPath:= EmptyStr;
unzip.Examine;
unzip.UnZipAllFiles;
end.[/code]
Mantis conversion info:
- Mantis ID: 38798
- OS: Ubuntu
- OS Build: 20.10
- Platform: x86_64
- Version: 3.3.1