Forum > Packages and Libraries

Unit Zipper from package paszlib has an inconsistency

(1/7) > >>

Gustavo 'Gus' Carreno:
Hey All,

In the comments of the Unit it self it says that the Archive Name should always use / as Directory Separators.
I guess that's the ZIP standard.

But then, when under Windows you use(To try and be cross-platform compatible):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    for index:=1 to 4 do    begin      filename:= Format('data%sblock%d.txt', [DirectorySeparator,index]);      Zip.Entries.AddFileEntry(filename);    end; 
You get:

--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---& less file.zipArchive:  file.zip Length   Method    Size  Cmpr    Date    Time   CRC-32   Name--------  ------  ------- ---- ---------- ----- --------  ----      16  Defl:N       16   0% 2021-04-21 21:20 fffc0087  data\block1.txt      16  Defl:N       16   0% 2021-04-21 21:20 d4d15344  data\block2.txt      16  Defl:N       16   0% 2021-04-21 21:20 cdca6205  data\block3.txt      16  Defl:N       16   0% 2021-04-21 21:21 828bf4c2  data\block4.txt--------          -------  ---                            -------      64               64   0%                            4 files
That has the wrong Directory Separator!!

But if instead you do:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    for index:=1 to 4 do    begin      filename:= Format('data%sblock%d.txt', [DirectorySeparator,index]);      archivename:= Format('data/block%d.txt', [index]);      Zip.Entries.AddFileEntry(filename, archivename);    end; 
You get:

--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---& less file.zipArchive:  file.zip Length   Method    Size  Cmpr    Date    Time   CRC-32   Name--------  ------  ------- ---- ---------- ----- --------  ----      16  Defl:N       16   0% 2021-04-21 21:20 fffc0087  data/block1.txt      16  Defl:N       16   0% 2021-04-21 21:20 d4d15344  data/block2.txt      16  Defl:N       16   0% 2021-04-21 21:20 cdca6205  data/block3.txt      16  Defl:N       16   0% 2021-04-21 21:21 828bf4c2  data/block4.txt--------          -------  ---                            -------      64               64   0%                            4 filesThis has the correct Directory Separator!!

So then I tried to unzip a BAD under Linux but trying to change the Entries properties, to no avail!!

Where can I post this bug? Is the unit still being maintained?

Cheers,
Gus

trev:
DirectorySeparator is system dependant constant, so on Windows it's \ but on Linux, macOS, FreeBSD etc it's  /.

Gustavo 'Gus' Carreno:
Hey Trev,


--- Quote from: trev on April 22, 2021, 03:48:10 am ---DirectorySeparator is system dependant constant, so on Windows it's \ but on Linux, macOS, FreeBSD etc it's  /.

--- End quote ---

I know you're not being condescendant here, cuz I know that for quite a while :P (around my first install of Slackware circa 1995), but that's not the issue.

You add a file under Windows using Zip.Entries.AddFileEntry(filename)(One param, not 2) and the Zip file is incorrectly formatted:

--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---& less file.zipArchive:  file.zip Length   Method    Size  Cmpr    Date    Time   CRC-32   Name--------  ------  ------- ---- ---------- ----- --------  ----      16  Defl:N       16   0% 2021-04-21 21:20 fffc0087  data\block1.txt      16  Defl:N       16   0% 2021-04-21 21:20 d4d15344  data\block2.txt      16  Defl:N       16   0% 2021-04-21 21:20 cdca6205  data\block3.txt      16  Defl:N       16   0% 2021-04-21 21:21 828bf4c2  data\block4.txt--------          -------  ---                            -------      64               64   0%                            4 file
Internally it should replace those IN-correct Directory separators, but it doesn't !!!

Only a problem in Windows.

Cheers,
Gus

trev:

--- Quote from: Gustavo 'Gus' Carreno on April 22, 2021, 04:48:25 am ---Internally it should replace those IN-correct Directory separators, but it doesn't !!!
--- End quote ---

Gotcha. It would be nice to have in that case for Windows (I no longer recall what OS/2 used for directory separators). On the other hand, you did specify the incorrect separator :)

Is the author known? If so, you could contact him/her and suggest an enhancement.

Gustavo 'Gus' Carreno:
Hey Trev,


--- Quote from: trev on April 22, 2021, 07:33:49 am ---Gotcha. It would be nice to have in that case for Windows (I no longer recall what OS/2 used for directory separators).

--- End quote ---

Hummm, good call, that also needs to be addressed!!


--- Quote from: trev on April 22, 2021, 07:33:49 am ---On the other hand, you did specify the incorrect separator :)

--- End quote ---

Well, yes and no...
In the case where you use the single param overload of Zip.Entries.AddFileEntry() you can only specify the file itself.
This means that under Windows it will be separated with \.
So INTERNALLY, in this case, TZipper should keep the Filename intact, but replace the \ with / on it's internally named ArchiveFilename, which it doesn't and causes the above mentioned issue to arise.

This is only an issue if you try to unzip that badly formed zip on a Linux system where data\block1.txt is a perfectly valid file name and NOT a folder and a file.
If you do so, you have a file called data\block1.txt on the current folder and not a file block1.txt under a data folder.


--- Quote from: trev on April 22, 2021, 07:33:49 am ---Is the author known? If so, you could contact him/her and suggest an enhancement.

--- End quote ---

Well, I was hoping that the oldest members of the Forum would know that, since this is the only info I got and it's the header of the Zipper unit(who's this micheal?):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{    $Id: header,v 1.3 2013/05/26 06:33:45 michael Exp $    This file is part of the Free Component Library (FCL)    Copyright (c) 1999-2014 by the Free Pascal development team     See the file COPYING.FPC, included in this distribution,    for details about the copyright.     This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  **********************************************************************}
This unit is part of fpcsrc/packages/paszlib.

Can anyone else help?

Many MANY thanks in advance!!

Cheers,
Gus

Navigation

[0] Message Index

[#] Next page

Go to full version