ZIP_FILE_GET_COMMENT(3)
π ZIP_FILE_GET_COMMENT(3) π
okay bestie, so this is a page from the Library Functions Manual (we're in the libzip cinematic universe, and yes, it's giving main character energy π). Buckle up, because we're getting the comment off a file inside a zip archive and it's honestly so much fun.
β¨ NAME β¨
zip_file_get_comment β get comment for file in zip
πΈ LIBRARY πΈ
libzip (-lzip) β link it, love it, that's the vibe.
π¦ SYNOPSIS π¦
#include <zip.h>
const char *
zip_file_get_comment(zip_t *archive, zip_uint64_t index,
zip_uint32_t *lenp, zip_flags_t flags);
π DESCRIPTION π
So, like, zip_file_get_comment() hands you back the comment for the file sitting at position index inside the zip archive. β¨
The name is in UTF-8 encoding unless ZIP_FL_ENC_RAW was specified (peep below, iykyk). And listen β this pointer? Do not modify it, do not free(3) it, and heads up: it goes invalid the moment archive is closed. It's a temporary queen, respect her timeline. π
If lenp is not NULL, the integer it points to gets set to the length of the comment. Cute, right?
And if flags is set to ZIP_FL_UNCHANGED, you get the original unchanged comment back β the pre-glow-up version. π«Ά
Additionally, the following flags are supported:
ZIP_FL_ENC_RAWβ Return the unmodified comment as it is in the ZIP archive. raw. unfiltered. no edits, no notes. πZIP_FL_ENC_GUESSβ (Default.) Guess the encoding of the comment in the ZIP archive and convert it to UTF-8, if necessary. (Only CP-437 and UTF-8 are recognized.) it's giving detective energy πZIP_FL_ENC_STRICTβ Follow the ZIP specification for file names and extend it to file comments, expecting them to be encoded in CP-437 in the ZIP archive (except if it is a UTF-8 comment from the special extra field). Convert it to UTF-8. strict queen, rules are rules. π
Note: ASCII is a subset of both CP-437 and UTF-8. no cap, that's literally just true. π
β RETURN VALUES β
Upon successful completion, a pointer to the comment is returned β slay. Or NULL if there is no comment (sad, empty, tragic π₯²).
In case of an error, NULL is returned and the error code in archive is set to indicate the error. so check your error code, bestie, don't just assume. π
π ERRORS π
zip_file_get_comment() fails if:
[ZIP_ER_INVAL]βindexis not a valid file index inarchive. not a real index, not a real one of us. π«
π SEE ALSO π
libzip(3), zip_file_set_comment(3), zip_get_archive_comment(3)
go read the whole friend group, they're all iconic. π«Ά
π HISTORY π
zip_file_get_comment() was added in libzip 0.11. an OG. a legend. periodt. π
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at>
the two geniuses behind all of this, we stan. π
and that's the whole page bestie!! this beauty shipped with Debian on September 22, 2020 β so go forth, fetch those comments, and remember: pointers expire, but the vibe is forever β¨ππ¦
π¦ where this page comes from
- arch rolling: libzip 1.11.4-1 Β· BSD
- debian trixie: libzip-dev 1.11.3-2 Β· BSD-3-Clause
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- nixpkgs unstable: libzip 1.11.4
- ubuntu questing: libzip-dev 1.11.3-2
- ubuntu resolute: libzip-dev 1.11.4-2 Β· BSD-3-Clause
- ubuntu stonking: libzip-dev 1.11.4-2build1 Β· BSD-3-Clause
- Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms