Modules / Standard library
std/zlib_linux
Whole zlib, gzip or raw deflate streams over the platform zlib, into growing vectors: what PNG files, gzip archives and other formats need when the result's size is not known in advance. Link the platform zlib (-lz). packed: Vec(u8) if ZlibCompress(bytes, *packed, 9) { ... } unpacked: Vec(u8) if ZlibDecompress(packed_bytes, *unpacked, 64 << 20) { ... } WINDOW_BITS chooses the wrapper as zlib does: 15 zlib, 31 gzip, -15 raw deflate; decompressing with 47 accepts zlib or gzip.
Stable Needs: Native Linux. Shipped in release v0.4.2.
Import with #import "std/zlib_linux".
ZlibCompress :: (input: []u8, output: *Vec(u8), level: s32, window_bits: s32) -> boolAppends INPUT compressed at LEVEL (0 to 9, -1 for zlib's default) to OUTPUT. False when zlib refuses the settings or the input.
ZlibDecompress :: (input: []u8, output: *Vec(u8), limit: s64, window_bits: s32) -> boolAppends the stream INPUT holds, decompressed, to OUTPUT. False for a damaged or truncated stream, trailing bytes, or more than LIMIT bytes.
Source ↗ · All modules