Sign in Join
Wiki copytemporary

bzip2lib: what changed

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

Title: bzip2lib

OldNewLine
1+### About
2+
3+bzip2lib provides stream classes for bzip2 compression and decompression. It uses external bzip2 libraries.
4+
5+Unit bzip2lib contains 2 streams:
6+
7+- TBzip2CompressStream for compressing (packing) data to bzip2 format.
8+- TBzip2DecompressStream for decompressing (unpacking) data back to its original form.
9+
10+Unit bzip2lib is collected and edited from 2 unit files in [Jcl](https://wiki.delphi-jedi.org/wiki/JEDI_Code_Library) package:
11+
12+- JclCompression
13+- bzip2
14+
15+The purpose was to make it compile and work with FPC (Free Pascal Compiler). In the process lots of code with conditional compilation directives was removed and also many unit dependencies were removed.
16+
17+The download contains the source unit file and a demo program which compresses and then again decompresses a text file given as a command line parameter.
18+
19+### Author
20+
21+Juha Manninen \<juha dot manninen (at) phnet dot fi\>
22+
23+\+ the original authors of Jcl code.
24+
25+### License
26+
27+This code is licensed under the same terms as Jcl library.
28+
29+### Download
30+
31+The latest stable release can be found on <http://sourceforge.net/projects/lazarus-ccr/files/bzip2lib/bzip2lib-1.tar.gz/download>.
32+
33+### Change Log
34+
35+- Version 1.0, Date: 2009.11.06
36+
37+### Dependencies / System Requirements
38+
39+The code uses external bzip2 libraries for its job:
40+
41+- 'bzip2.dll' in Windows
42+- 'libbz2.so.1' in Linux
43+
44+Status: Stable
45+
46+Issues: The author has tested the code only under Linux. There it works well.
47+
48+### Usage
49+
50+Just include unit `bzip2lib` in the "uses" section. Set path for it in project settings if needed. The external bzip2 library must be installed in your machine (see *Dependencies*). Use `TBzip2CompressStream` and `TBzip2DecompressStream` just like any stream, connecting them to file stream or memory stream if needed.
51+
52+Note: there is a bzip2 component supplied with FPC: packages/bzip2. It is a pure Pascal solution (doesn't need external libraries) but it can only decompress. If you also need compression then bzip2lib is for you.
53+
54+### Example code for bzip2lib
55+
56+- Compressing a string to a file. "S" is the string to compress.
57+
58+``` pascal
59+OutFileStream := TFileStream.Create(CompressedFileName, fmCreate);
60+CompressStream := TBzip2CompressStream.Create(OutFileStream);
61+try
62+ CompressStream.Write(Pointer(S)^, Length(S));
63+finally
64+ CompressStream.Free;
65+ OutFileStream.Free;
66+end;
67+```
68+
69+- Decompressing from a file to a TStringList (SL). TStringList.LoadFromStream can be used here.
70+
71+``` pascal
72+SL := TStringList.Create;
73+InFileStream := TFileStream.Create(CompressedFileName, fmOpenRead);
74+DecompressStream := TBzip2DecompressStream.Create(InFileStream);
75+try
76+ SL.LoadFromStream(DecompressStream);
77+ SL.SaveToFile(OutFileName);
78+finally
79+ DecompressStream.Free;
80+ InFileStream.Free;
81+ SL.Free;
82+end;
83+```
84+
85+---
86+*From the Free Pascal wiki, page "bzip2lib", as it stood on 2020-07-29 after a change by Rvasin, 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).*
87+Category: Components
88+Category: Lazarus-CCR

Back to history