Zlibar: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | # About | |
| 2 | 2 | ||
| 3 | 3 | **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 | |
| 4 | 4 | ||
| 5 | 5 | The two main components are : | |
| 6 | 6 | ||
| 7 | 7 | - TZlibWriteArchive - Used to create an archive | |
| 8 | 8 | - TZlibReadArchive - Used to read the archive and extract it's files | |
| 9 | 9 | ||
| 10 | 10 | Features of TZlibWriteArchive : | |
| 11 | 11 | ||
| 12 | 12 | - Create the Archive file in a stream, allowing you to save it to a file or do something else creative with it | |
| 13 | 13 | - Each file in the archive is stored with a MD5 checksum | |
| 14 | 14 | - Each file can be stored with a relative path | |
| 15 | 15 | - Contains progress [[callback|callbacks]] to inform the program of the current file and all files progress | |
| 16 | 16 | ||
| 17 | 17 | Features of TZlibReadArchive : | |
| 18 | 18 | ||
| 19 | 19 | - Loads the archive from a TStream. | |
| 20 | 20 | - Contains a progress callback to inform the program of the extraction progress | |
| 21 | 21 | - Files in the archive are extractable by an index number and are extracted to a TStream | |
| 22 | 22 | ||
| 23 | 23 | The download contains a demo program, and the unit. Also a package file. | |
| 24 | 24 | ||
| 25 | 25 | Although not tested, it should work on any platform. | |
| 26 | 26 | ||
| 27 | 27 | **Changes in versions** : | |
| 28 | 28 | ||
| 29 | 29 | 0.2.3 (19/02/2012) | |
| 30 | 30 | ||
| 31 | 31 | - Fixed compilation with newer versions of fpc | |
| 32 | 32 | ||
| 33 | 33 | 0.2.2 | |
| 34 | 34 | ||
| 35 | 35 | - LCL requirement removed | |
| 36 | 36 | - FPC version 2.0.4 (or a recent development version) required. | |
| 37 | 37 | - Compatible with FPC 2.0.4 ( go figure.... ;) | |
| 38 | 38 | ||
| 39 | 39 | 0.2.1 | |
| 40 | 40 | ||
| 41 | 41 | - archives should work across different endian machines now. | |
| 42 | 42 | - fixed bad memory corruption bug | |
| 43 | 43 | - now requires LCL for endian safeness | |
| 44 | 44 | ||
| 45 | 45 | # Author | |
| 46 | 46 | ||
| 47 | 47 | Andrew Haines | |
| 48 | 48 | ||
| 49 | 49 | # License | |
| 50 | 50 | ||
| 51 | 51 | 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. | |
| 52 | 52 | ||
| 53 | 53 | # Download | |
| 54 | 54 | ||
| 55 | 55 | ## Releases | |
| 56 | 56 | ||
| 57 | 57 | The latest stable release can be found on the [Lazarus CCR Files page](http://sourceforge.net/projects/lazarus-ccr/files/ZlibAr/). | |
| 58 | 58 | ||
| 59 | 59 | ## Subversion | |
| 60 | 60 | ||
| 61 | 61 | zlibar is available in the lazarus code and component repository since version 0.2.3: | |
| 62 | 62 | ||
| 63 | - | ||
| 63 | + | ```text | |
| 64 | + | svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/zlibar zlibar | |
| 65 | + | ``` | |
| 64 | 66 | ||
| 65 | 67 | # Dependencies / System Requirements | |
| 66 | 68 | ||
| 67 | 69 | - Free Pascal | |
| 68 | 70 | - Demo Program requires Lazarus | |
| 69 | 71 | ||
| 70 | 72 | Issues: | |
| 71 | 73 | ||
| 72 | 74 | - Tested on Linux. | |
| 73 | 75 | - Needs testing on Windows. *Confirmed working on Windows*\ | |
| 74 | 76 | --Eyecreate 03:22, 23 February 2007 (CET) | |
| 75 | 77 | ||
| 76 | 78 | 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. | |
| 77 | 79 | ||
| 78 | 80 | # Usage | |
| 79 | 81 | ||
| 80 | 82 | Add the unit "zlibar" to your uses section. | |
| 81 | 83 | ||
| 82 | 84 | ## TZLibWriteArchive | |
| 83 | 85 | ||
| 84 | 86 | Example: | |
| 85 | 87 | ||
| 86 | 88 | ``` pascal | |
| 87 | 89 | var | |
| 88 | 90 | Zar: TZlibWriteArchive; | |
| 89 | 91 | Stream: TMemoryStream; | |
| 90 | 92 | X: Integer; | |
| 91 | 93 | begin | |
| 92 | 94 | Stream := TMemoryStream.Create; | |
| 93 | 95 | Zar := TZlibWriteArchive.Create; | |
| 94 | 96 | Zar.OutStream := Stream; | |
| 95 | 97 | ||
| 96 | 98 | Zar.InputFiles.Add('/path/to/MyFileName1'); | |
| 97 | 99 | Zar.InputFiles.Add('/path/to/MyFileName2'); | |
| 98 | 100 | ||
| 99 | 101 | Zar.CreateArchive; | |
| 100 | 102 | ||
| 101 | 103 | Stream.SaveToFile('MySavedFileName'); | |
| 102 | 104 | Zar.Free; | |
| 103 | 105 | Stream.Free; | |
| 104 | 106 | end; | |
| 105 | 107 | ``` | |
| 106 | 108 | ||
| 107 | 109 | ## TZlibReadArchive | |
| 108 | 110 | ||
| 109 | 111 | Example: | |
| 110 | 112 | ||
| 111 | 113 | ``` pascal | |
| 112 | 114 | var | |
| 113 | 115 | ArchStream: TMemoryStream; | |
| 114 | 116 | FileStream: TMemoryStream; | |
| 115 | 117 | ZReadArc: TZlibReadArchive; | |
| 116 | 118 | X: Integer; | |
| 117 | 119 | DestPath: String; | |
| 118 | 120 | begin | |
| 119 | 121 | ArchStream := TMemoryStream.Create; | |
| 120 | 122 | FileStream := TmemoryStream.Create; | |
| 121 | 123 | ||
| 122 | 124 | ArchStream.LoadFromFile('ArchiveFileName'); | |
| 123 | 125 | ZReadArc:= TZlibReadArchive.Create(ArchStream); | |
| 124 | 126 | DestPath := '/Some/Path'; | |
| 125 | 127 | for X := 0 to ZReadArc.Count -1 do begin | |
| 126 | 128 | ZReadArc.ExtractFileToStream(X, FileStream); | |
| 127 | 129 | FileStream.SaveToFile(DestPath+ZReadArc.FilesInArchive[X].FilePath+'/'+ZReadArc.FilesInArchive[X].FIleName); | |
| 128 | 130 | FileStream.Position := 0; | |
| 129 | 131 | FileStream.Size := 0; | |
| 130 | 132 | end; | |
| 131 | 133 | ZReadArc.Free; | |
| 132 | 134 | ArchStream.Free; | |
| 133 | 135 | FileStream.Free; | |
| 134 | 136 | end; | |
| 135 | 137 | ``` | |
| 136 | 138 | ||
| 137 | 139 | --- | |
| 138 | 140 | *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).* |
