Sign in Join
Wiki copytemporary

Zlibar: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# About
22
33**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
44
55The two main components are :
66
77- TZlibWriteArchive - Used to create an archive
88- TZlibReadArchive - Used to read the archive and extract it's files
99
1010Features of TZlibWriteArchive :
1111
1212- Create the Archive file in a stream, allowing you to save it to a file or do something else creative with it
1313- Each file in the archive is stored with a MD5 checksum
1414- Each file can be stored with a relative path
1515- Contains progress [[callback|callbacks]] to inform the program of the current file and all files progress
1616
1717Features of TZlibReadArchive :
1818
1919- Loads the archive from a TStream.
2020- Contains a progress callback to inform the program of the extraction progress
2121- Files in the archive are extractable by an index number and are extracted to a TStream
2222
2323The download contains a demo program, and the unit. Also a package file.
2424
2525Although not tested, it should work on any platform.
2626
2727**Changes in versions** :
2828
29290.2.3 (19/02/2012)
3030
3131- Fixed compilation with newer versions of fpc
3232
33330.2.2
3434
3535- LCL requirement removed
3636- FPC version 2.0.4 (or a recent development version) required.
3737- Compatible with FPC 2.0.4 ( go figure.... ;)
3838
39390.2.1
4040
4141- archives should work across different endian machines now.
4242- fixed bad memory corruption bug
4343- now requires LCL for endian safeness
4444
4545# Author
4646
4747Andrew Haines
4848
4949# License
5050
5151zlibar.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.
5252
5353# Download
5454
5555## Releases
5656
5757The latest stable release can be found on the [Lazarus CCR Files page](http://sourceforge.net/projects/lazarus-ccr/files/ZlibAr/).
5858
5959## Subversion
6060
6161zlibar is available in the lazarus code and component repository since version 0.2.3:
6262
63-` svn co `[`https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/zlibar`](https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/zlibar)` zlibar`
63+```text
64+ svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/zlibar zlibar
65+```
6466
6567# Dependencies / System Requirements
6668
6769- Free Pascal
6870- Demo Program requires Lazarus
6971
7072Issues:
7173
7274- Tested on Linux.
7375- Needs testing on Windows. *Confirmed working on Windows*\
7476 --Eyecreate 03:22, 23 February 2007 (CET)
7577
7678Version 0.2.2 will not compile on newer versions of fpc (\>2.4.2) Use a version newer than 0.2.2 or subversion.
7779
7880# Usage
7981
8082Add the unit "zlibar" to your uses section.
8183
8284## TZLibWriteArchive
8385
8486Example:
8587
8688``` pascal
8789var
8890 Zar: TZlibWriteArchive;
8991 Stream: TMemoryStream;
9092 X: Integer;
9193begin
9294 Stream := TMemoryStream.Create;
9395 Zar := TZlibWriteArchive.Create;
9496 Zar.OutStream := Stream;
9597
9698 Zar.InputFiles.Add('/path/to/MyFileName1');
9799 Zar.InputFiles.Add('/path/to/MyFileName2');
98100
99101 Zar.CreateArchive;
100102
101103 Stream.SaveToFile('MySavedFileName');
102104 Zar.Free;
103105 Stream.Free;
104106end;
105107```
106108
107109## TZlibReadArchive
108110
109111Example:
110112
111113``` pascal
112114var
113115 ArchStream: TMemoryStream;
114116 FileStream: TMemoryStream;
115117 ZReadArc: TZlibReadArchive;
116118 X: Integer;
117119 DestPath: String;
118120begin
119121 ArchStream := TMemoryStream.Create;
120122 FileStream := TmemoryStream.Create;
121123
122124 ArchStream.LoadFromFile('ArchiveFileName');
123125 ZReadArc:= TZlibReadArchive.Create(ArchStream);
124126 DestPath := '/Some/Path';
125127 for X := 0 to ZReadArc.Count -1 do begin
126128 ZReadArc.ExtractFileToStream(X, FileStream);
127129 FileStream.SaveToFile(DestPath+ZReadArc.FilesInArchive[X].FilePath+'/'+ZReadArc.FilesInArchive[X].FIleName);
128130 FileStream.Position := 0;
129131 FileStream.Size := 0;
130132 end;
131133 ZReadArc.Free;
132134 ArchStream.Free;
133135 FileStream.Free;
134136end;
135137```
136138
137139---
138140*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](/wiki-contact).*

Back to history