ZOPEN(3)
π NAME π
okay so welcome to ZOPEN(3), straight outta the Library Functions Manual β this page is all about zopen, aka open a gzip compressed stream. bestie, it's literally the glow-up your compressed-file reading needed β¨
π§ LIBRARY π§
Compression Library (libz, -lz) β that's the link-up, no cap.
πΈ SYNOPSIS πΈ
FILE *
zopen(const char *path, const char *mode);
FILE *
zdopen(int fd, const char *mode);
π¦ DESCRIPTION π¦
okay so zopen() opens a gzip file whose name is the string pointed to by path, and it returns a stream which can be used to access the uncompressed contents of the file. the zdopen() variant takes a gzip file referenced by the file descriptor fd, analogous to fdopen(3). they are wrappers around zlib(3) and the standard stream I/O APIs. iconic behavior, honestly.
the argument mode has the same meaning as it does in fopen(3). yes bestie, same mode energy.
zopen() and zdopen() will associate the read, write, seek and close functions of zlib(3) with the returned stream. periodt.
π₯ RETURN VALUES π₯
upon successful completion, zopen() and zdopen() return a FILE pointer. otherwise, NULL is returned and the global variable errno is set to indicate the error. so like, check that errno, bestie π
π ERRORS π
in addition to the errors documented for fopen(3) and fdopen(3), the functions may also fail for:
[ENOMEM]β Insufficient memory is available.
that's the extra failure listed here, and it's giving βnot enough memory, bestieβ energy π
π COMPATIBILITY π
the implementation of the zopen() function first appeared in NetBSD 1.6 and FreeBSD 4.5. zdopen() first appeared in FreeBSD 13.0. these functions may not be portable to systems other than FreeBSD. so if you're not on FreeBSD, do a vibe check before relying on them π
π SEE ALSO π
fdopen(3), fopen(3), funopen(3), zlib(3)
this page is from Debian, dated December 6, 2018, and it's ZOPEN(3) β mwah, take care bestie π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2014 Xin LI <delphij@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms