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

Bo Berglund bo.berglund at gmail.com
Thu Jul 14 16:57:01 CEST 2016

On Thu, 14 Jul 2016 09:25:56 -0400,
wkitty42 at windstream.net wrote:

>On 07/14/2016 08:31 AM, Bo Berglund wrote:
>> 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?
>i found the following in the interface section of zipper.pp
>   TZipFileEntries = Class(TCollection)
>   private
>     function GetZ(AIndex : Integer): TZipFileEntry;
>     procedure SetZ(AIndex : Integer; const AValue: TZipFileEntry);
>   Public
>     Function AddFileEntry(Const ADiskFileName : String): TZipFileEntry;
>     Function AddFileEntry(Const ADiskFileName, AArchiveFileName : String): 
>     Function AddFileEntry(Const AStream : TSTream; Const AArchiveFileName : 
>String): TZipFileEntry;
>     Procedure AddFileEntries(Const List : TStrings);
>     Property Entries[AIndex : Integer] : TZipFileEntry Read GetZ Write SetZ; 
>   end;

Sounds like this is going to work given that the AArchiveFileName can
be used as argument (untested):

 ExtractDir := ExtractFileName(TargetZipFile);
 ExtractDir := IncludePathDelimiter(ReplaceFileExt(ExtractDir, ''));
 for i := 0 to FileList.Count-1 do
   FileName := FileList[i];
   if not FileExists(FileName) then Continue;
   {$ifdef FPC}
   FileNameArc := ExtractDir + ExtractFileName(FileName);
   ZW.Entries.AddFileEntry(FileName, FilenameArc);

I have not gotten to the point where there are files to zip yet, but
the utility builds fine and runs as expected now! And PasZip will be
ifdefed out on FPC, only used with Delphi...

Thanks for all the help and suggestions!

Bo Berglund
Developer in Sweden

More information about the fpc-pascal mailing list