Difference between revisions of "paszlib"

From Lazarus wiki
Jump to navigationJump to search
m (→‎Using the latest TZipper: - deleted pre-2.4.0-specific section)
m (Text replace - "delphi>" to "syntaxhighlight>")
Line 13: Line 13:
 
Create zip file named as parameter 1 from files entered as rest parameters.
 
Create zip file named as parameter 1 from files entered as rest parameters.
  
<delphi>uses
+
<syntaxhighlight>uses
 
   Zipper;
 
   Zipper;
 
var
 
var
Line 27: Line 27:
 
     Zipper.Free;
 
     Zipper.Free;
 
   end;
 
   end;
end.</delphi>
+
end.</syntaxhighlight>
  
 
====Unzip files====
 
====Unzip files====
Line 33: Line 33:
 
Unzip all files contained in archive with name given by ZipFilePath to directory entered as UnzippedFolderName.
 
Unzip all files contained in archive with name given by ZipFilePath to directory entered as UnzippedFolderName.
  
<delphi>uses
+
<syntaxhighlight>uses
 
   Zipper;
 
   Zipper;
 
var
 
var
Line 47: Line 47:
 
     UnZipper.Free;
 
     UnZipper.Free;
 
   end;
 
   end;
end.</delphi>
+
end.</syntaxhighlight>
  
 
More examples can be found in FPC source directory [http://svn.freepascal.org/svn/fpc/trunk/packages/paszlib/examples/]
 
More examples can be found in FPC source directory [http://svn.freepascal.org/svn/fpc/trunk/packages/paszlib/examples/]

Revision as of 16:18, 24 March 2012

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

Examples

Zip files

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

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.

Unzip files

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

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.

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


Go to back Packages List