Wiki copymirror

This is a mirror of the wiki at pascal.chat. Editing, history and sign-in are there.

Zlibar

Deutsch ยท English

About

zlibar is a unit that contains components to create a single compressed file archive that contains many files. It uses paszlib that is included with FreePascal so there are no external library requirements

The two main components are :

Features of TZlibWriteArchive :

Features of TZlibReadArchive :

The download contains a demo program, and the unit. Also a package file.

Although not tested, it should work on any platform.

Changes in versions :

0.2.3 (19/02/2012)

0.2.2

0.2.1

Author

Andrew Haines

License

zlibar.pas is distributed with the same modified LGPL as the LCL, so it is possible to use it in proprietary programs without disclosing your source.

Download

Releases

The latest stable release can be found on the Lazarus CCR Files page.

Subversion

zlibar is available in the lazarus code and component repository since version 0.2.3:

text
 svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/zlibar zlibar

Dependencies / System Requirements

Issues:

Version 0.2.2 will not compile on newer versions of fpc (>2.4.2) Use a version newer than 0.2.2 or subversion.

Usage

Add the unit "zlibar" to your uses section.

TZLibWriteArchive

Example:

pascal
var
  Zar: TZlibWriteArchive;
  Stream: TMemoryStream;
  X: Integer;
begin    
  Stream := TMemoryStream.Create;
  Zar := TZlibWriteArchive.Create;    
  Zar.OutStream := Stream;
  
  Zar.InputFiles.Add('/path/to/MyFileName1');
  Zar.InputFiles.Add('/path/to/MyFileName2');

  Zar.CreateArchive;
  
  Stream.SaveToFile('MySavedFileName');
  Zar.Free;
  Stream.Free;
end;

TZlibReadArchive

Example:

pascal
var
  ArchStream: TMemoryStream;
  FileStream: TMemoryStream;
  ZReadArc: TZlibReadArchive;
  X: Integer;
  DestPath: String;
begin
  ArchStream := TMemoryStream.Create;
  FileStream := TmemoryStream.Create;
   
  ArchStream.LoadFromFile('ArchiveFileName');
  ZReadArc:= TZlibReadArchive.Create(ArchStream);
  DestPath := '/Some/Path';
  for X := 0 to ZReadArc.Count -1 do begin    
    ZReadArc.ExtractFileToStream(X, FileStream);
    FileStream.SaveToFile(DestPath+ZReadArc.FilesInArchive[X].FilePath+'/'+ZReadArc.FilesInArchive[X].FIleName);
    FileStream.Position := 0;
    FileStream.Size := 0;
  end;
  ZReadArc.Free;
  ArchStream.Free;
  FileStream.Free;  
end;

From the Free Pascal wiki, page "Zlibar", as it stood on 2021-10-25 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .