The libzio provides with the help the fopencookie(3) extension of the glibc or funopen(3) function known on BSD Systems together with zlib and libbzip2 an interface to read or write gzip/bzip2 files with streams. Beside handling gzip, bzip2 and lzma files, the libzio provides support for reading ``.Z'' compressed files. Libzio uses the GNUC weak facility to allow programs to be linked against zlib, libbzip2 or liblzmadec only.
For writing gzip or bzip2 files, fzopen only supports the suffixes .z and .gz for gzipped files and .bz2 for bzip2ed files. All supported formats can be found in the following table:
fread | fwrite | fseek | suffix | library | |
---|---|---|---|---|---|
gzip | yes | yes | yes | .gz | -lz |
bzip2 | yes | yes | yes | .bz2 | -lbz2 |
LZW | yes | no | yes | .Z | builtin |
lzma | yes | yes(no) | yes | .lzma | -llzma (-llzmadec) |
xz | yes | yes | yes | .xz | -llzma |
zstd | yes | yes | no | .zst | -lzstd |
On reading first the appropriate suffixes are checked if not provided. If no file is found the magic byte sequence at the beginning of the file is checked to detect a gzip or bzip2 file.
The zlib home page at https://www.zlib.net
The bzip2 home page at https://www.bzip.org
The gzip home page at https://www.gzip.org
The LZMA home page at https://tukaani.org/lzma