[fpc-pascal] Porting code from Windows D2007, missing Windows functions
bo.berglund at gmail.com
Thu Jul 14 12:31:19 CEST 2016
On Thu, 14 Jul 2016 10:09:36 +0100, Graeme Geldenhuys
<mailinglists at geldenhuys.co.uk> wrote:
>If you have the time, it might be worth abstracting out the zip reading
>functionality so you can swap out the actual compression components used
>as needed. This will allow your application to change compression tools
>in future, without your application code needing any changes. This is
>always a good design philosophy when it comes to using 3rd party components.
>While working at a previous employer we use the TurboPower suite of
>compression components under Windows and Linux with great success, but
>could also swap it out for the FPC included ZLib unit.
I do have the zip *writing* in one single place as a method for the
class that handles the communication. It gets a target zipfile name
and a stringlist containing the files to zip as arguments, so that is
Here is how it looks like:
function TSSCommHandler.ZipFiles(TargetFile: string; FileList:
Result := false;
ZW := TZipWrite.Create(TargetFile);
for i := 0 to FileList.Count-1 do
FileName := FileList[i];
if not FileExists(FileName) then Continue;
Result := true;
on E: Exception do
FLastError := 'Zip error: ' + E.Message;
What I need elsewhere in the code is not depening on PasZip, the call
to create the zipfile is simply:
So with the proper set of conditionals I could have different
implementations of this method for Windows and Linux.
Do you have an example of how to do the above with FPC ZLib?
Developer in Sweden
More information about the fpc-pascal