Difference between revisions of "paszlib"

From Lazarus wiki
Jump to navigationJump to search
Line 39: Line 39:
 
====Unzip files====
 
====Unzip files====
  
Unzip all files contained in archive with name given by first parameter to directory entered as second parameter.
+
Unzip all files contained in archive with name given by ZipFilePath to directory entered as UnzippedFolderName.
  
 
<delphi>uses
 
<delphi>uses
Line 48: Line 48:
 
   UnZipper := TUnZipper.Create;
 
   UnZipper := TUnZipper.Create;
 
   try     
 
   try     
     UnZipper.FileName := ParamStr(1);
+
     UnZipper.FileName := ZipFilePath;
     UnZipper.OutputPath := ParamStr(2);
+
     UnZipper.OutputPath := UnzippedFolderName;
 
     UnZipper.Examine;
 
     UnZipper.Examine;
 
     UnZipper.UnZipAllFiles;
 
     UnZipper.UnZipAllFiles;

Revision as of 16:21, 14 January 2011

Deutsch (de) English (en) 한국어 (ko) polski (pl) русский (ru)

paszlib is a Pascal conversion (thus without dependancies) of the standard zlib library, implemented by Jacques Nomssi Nzali (his old homepage is dead, see a continuation of the project here) It is used in the FCL to implement the TCompressionStream class. The main unit of this package is paszlib. there are other, auxiliary units, but the only unit that needs to be included in a typical program is this one. (View interface)

TZipper

Using the latest TZipper

In FPC 2.3.1 there are many fixes which make TZipper much better. To be able to use them until the next FPC is released with those fixes one should follow the following steps:

1 - Download zipper.pp, and only this file, from: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/paszlib/src/

2 - Rename the file to a unique name, to avoid conflict with the fpc unit, like myzipper.pp and also change the name inside the source file.

3 - Add the file to your project and use the TZipper from there.

Examples

Zip files

Create zip file named as parameter 1 from files entered as rest parameters.

<delphi>uses

 Zipper;

var

 Zipper: TZipper;

begin

 try
   Zipper := TZipper.Create;
   Zipper.FileName := ParamStr(1);
   for I := 2 to ParamCount do
     Zipper.Entries.AddFileEntry(ParamStr(I), ParamStr(I));
   Zipper.ZipAllFiles;
 finally
   Zipper.Free;
 end;

end.</delphi>

Unzip files

Unzip all files contained in archive with name given by ZipFilePath to directory entered as UnzippedFolderName.

<delphi>uses

 Zipper;

var

 UnZipper: TUnZipper;

begin

 UnZipper := TUnZipper.Create;
 try    
   UnZipper.FileName := ZipFilePath;
   UnZipper.OutputPath := UnzippedFolderName;
   UnZipper.Examine;
   UnZipper.UnZipAllFiles;
 finally
   UnZipper.Free;
 end;

end.</delphi>

More examples can be found in FPC source directory [1]


Go to back Packages List