[fpc-pascal] Using paszlib from fpc 3.0 with fpc and delphi 2007?

Bo Berglund bo.berglund at gmail.com
Thu May 26 12:43:05 CEST 2016


On Thu, 26 May 2016 00:10:20 +0200, Bo Berglund
<bo.berglund at gmail.com> wrote:

>OK, I will see if I can work with Abbrevia without installing the complete
>package. Maybe I can just figure out the needed units and go with
>these. If so I will post the result here (I mean which units were
>needed for a minimum file write).

I have a solution now, but I got a suggestion from the Embarcadero
forum to check Synopse and there I found a single file (plus an inc)
solution to my problem.
I downloaded the PasZip.pas and Synopse.inc files from this location:
http://synopse.info/fossil/dir?ci=tip
(Actually the inc file would not download so I copied the contents
from the website display instead into a file)
This is the function I ended up with and it works just fine:


function TSSCommHandler.ZipFiles(TargetFile: string; FileList:
TStringList): boolean;
{This function uses the Synopse files PasZip.pas and Synopse.inc to
create the zipfile.
Files were obtained from http://synopse.info/fossil/dir?ci=tip}
var
  ZW: TZipWrite;
  i: integer;
  FileName: string;
begin
  Result := false;
  ZW := TZipWrite.Create(TargetFile);
  try
    try
      for i := 0 to FileList.Count-1 do
      begin
        FileName := FileList[i];
        if not FileExists(FileName) then Continue;
        ZW.AddDeflated(FileName);
      end;
      Result := true;
    except
      on E: Exception do
      begin
        FLastError := 'Zip error: ' + E.Message;
        exit;
      end;
    end;
  finally
    ZW.Free;
  end;
end;

I am only interested in the creation of the zipfile, but there is a
reader class available too.


-- 
Bo Berglund
Developer in Sweden




More information about the fpc-pascal mailing list