ZIP_FILE_SET_COMMENT(3)

πŸ“¦
version 1.11.4 Β· 3 versions
, in arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ZIP_FILE_SET_COMMENT(3) πŸ’–

okay bestie, welcome to the libzip corner of the manual pages β€” this one's about zip_file_set_comment(), and it's genuinely so useful, no cap. Library Functions Manual energy, but make it cute. πŸŽ€


✨ NAME ✨

zip_file_set_comment β€” set comment for file in zip

πŸ“š LIBRARY πŸ“š

libzip (-lzip)

🌸 SYNOPSIS 🌸

#include <zip.h>

int
zip_file_set_comment(zip_t *archive, zip_uint64_t index,
    const char *comment, zip_uint16_t len, zip_flags_t flags);

πŸ’… DESCRIPTION πŸ’…

So the zip_file_set_comment() function does exactly what it says on the tin, bestie: it sets the comment for the file sitting at position index in the zip archive to comment of length len. Glow up for your zip entries, literally. ✨

And if comment is NULL and len is 0? The file comment gets removed. Poof. Gone. It's giving "un-commenting your ex," we love to see it. πŸ’€

The flags argument can be any of these iconic little options:

  • ZIP_FL_ENC_GUESS β€” Guess the encoding of comment (this is the default, btw). Only CP-437 and UTF-8 get recognized, so don't get too creative in there. πŸ™ˆ
  • ZIP_FL_ENC_UTF_8 β€” Interpret comment as UTF-8. πŸ¦‹
  • ZIP_FL_ENC_CP437 β€” Interpret comment as code page 437 (CP-437). 🧚

πŸ”₯ RETURN VALUES πŸ”₯

When everything goes right, 0 is returned. Slay. πŸŽ‰

Otherwise you get -1, and the error information in archive is set to indicate the error β€” so like, check that if things go sideways, bestie.

😭 ERRORS 😭

zip_file_set_comment() fails if:

  • [ZIP_ER_INVAL] β€” index is not a valid file index in archive, or len is less than 0 or longer than the maximum comment length in a zip file (65535), or comment is not a valid UTF-8 encoded string. πŸ’€
  • [ZIP_ER_MEMORY] β€” Required memory could not be allocated. The audacity. 😭
  • [ZIP_ER_RDONLY] β€” The archive was opened in read-only mode. You can't write to something that said "no thank you," periodt. 🚫

πŸ‘‘ SEE ALSO πŸ‘‘

libzip(3), zip_file_get_comment(3), zip_get_archive_comment(3), zip_set_archive_comment(3)

🌈 HISTORY 🌈

zip_file_set_comment() was added in libzip 0.11. A classic, honestly. ⭐

🫢 AUTHORS 🫢

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β€” the icons who made this happen. πŸ’œ


okay that's the whole page, bestie β€” this one's from the Debian crew, dated September 22, 2020, and it lives at ZIP_FILE_SET_COMMENT(3). go forth and comment your zips, ily, bye πŸ’–βœ¨