Compression & Archive

9 entries

bzopen / bzread / bzcompress Function The bzip2 family: bzopen/bzread/bzwrite stream .bz2 files while bzcompress/bzdecompress handle strings; built on the BWT (Burrows-Wheeler Transform) algorithm — a better compression ratio than gzip/deflate at the cost of speed. deflate_init / deflate_add / inflate_init / inflate_add Function Incremental (streaming) deflate compression/decompression: feed data in chunks with flush modes controlling block boundaries — contrasted with the existing gzdeflate (one-shot): NO_FLUSH middle chunks produce identical output while SYNC_FLUSH inserts sync-marker bytes; Python's zlib.compressobj and Java's Deflater are the direct counterparts. gzcompress Function Compresses a string in bare zlib format (RFC 1950): a 2-byte header, deflate data and an Adler32 trailer — no gzip wrapper. gzdecode Function Decompresses gzip (RFC 1952) data and returns the original string after CRC32 verification; false on failure. gzdeflate / gzinflate Function Compresses/decompresses raw deflate data (RFC 1951) — the leanest of the three zlib formats (raw deflate / zlib / gzip), forming a family with gzcompress (zlib format) and gzencode (gzip format); the wbits window parameter is the core switch across languages. gzencode Function Compresses a string in gzip format (RFC 1952); level 0-9 controls compression (0 = stored, no compression). gzopen / gzread / gzwrite Function Opens a .gz file pointer for streaming I/O: writes are compressed and reads transparently decompressed; the level can be embedded in the mode (e.g. "wb9") — suited for chunked processing of large files. gzuncompress Function Decompresses bare zlib (RFC 1950) data and returns the original string after Adler32 verification; false on failure. ZIP Archive Function ZIP in three steps: create (multi-file packaging that keeps directory structure), list entries, extract and read back. Contrast with gz/bz2 single-file compression — an archive is a container for many files plus directory structure.