[fpc-pascal] Porting code from Windows D2007, missing Windows functions

Michael Van Canneyt michael at freepascal.org
Thu Jul 14 15:22:14 CEST 2016



On Thu, 14 Jul 2016, Bo Berglund wrote:

> On Thu, 14 Jul 2016 13:32:38 +0200 (CEST), Michael Van Canneyt
> <michael at freepascal.org> wrote:
>
>
>>> Do you have an example of how to do the above with FPC ZLib?
>>
>> You can find this almost verbatim in the examples of paszlib, using the
>> zipper unit.
>>
>
> The one I found is this (a command line utility):
>
> uses
>  Zipper;
> var
>  OurZipper: TZipper;
>  I: Integer;
> begin
>  OurZipper := TZipper.Create;
>  try
>    OurZipper.FileName := ParamStr(1);
>    for I := 2 to ParamCount do
>      OurZipper.Entries.AddFileEntry(ParamStr(I), ParamStr(I));
>    OurZipper.ZipAllFiles;
>  finally
>    OurZipper.Free;
>  end;
> end.
>
> It seems straightforward for my method to add all the supplied files
> in the stringlist the way the example does it.
>
> But this line:
> OurZipper.Entries.AddFileEntry(ParamStr(I), ParamStr(I));
>
> seems to add the files to zip into some kind of internal list.
> Why does it take the same argument twice?

Because you can add a file with a different filename to the zip.
e.g. an absolute filename with a relative filename.
Or add a case sensitive filename for the filesystem with an all-lowercase
filename.

>
> One issue I had with PasZip is that I have not found a way to enter
> the extract (target) dir for the zipped files.
> Can I specify a relative target extract path in the TZipper case, for
> example relative to the folder where the zipfile being extracted
> resides?
> If so how?

With the call above. The first name is the 'real' filename. The second name
is the filename that will be stored in the zip.
(or was it vice versa ?)

Michael.



More information about the fpc-pascal mailing list