ZIP_DIR_ADD(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_DIR_ADD(3) β€” Library Functions Manual πŸ’–

okay bestie, so the manual name is ZIP_DIR_ADD(3) and it lives in the Library Functions Manual section, and today we are learning about zip_dir_add β€” yes, the icon herself. let's go πŸ¦‹


✨ NAME ✨

zip_dir_add β€” add directory to zip archive. that's it, that's the whole job, and she does it flawlessly πŸ’…


πŸ“š LIBRARY πŸ“š

libzip (-lzip) β€” you know the one. link her in or nothing works, no cap.


🌸 SYNOPSIS 🌸

#include <zip.h>

zip_int64_t
zip_dir_add(zip_t *archive, const char *name, zip_flags_t flags);

look at that signature. gorgeous. iconic. she returns a zip_int64_t because she's got range πŸ’œ


πŸŽ€ DESCRIPTION πŸŽ€

so here's the tea πŸ“ β€” the function zip_dir_add() adds a directory to a zip archive. that's the whole vibe.

  • the argument archive is the zip archive that the directory is getting added to, like, that's the destination bestie
  • name is the directory's name inside the zip archive
🫢 IMPORTANT: this function adds an entry to the archive. it does not check whether a directory with that name actually exists in the file system, and it does not add that directory's contents even if it does exist. she is not doing your filesystem homework for you, she's just writing an entry. periodt.

the flags argument can be any of these three cuties:

  • ZIP_FL_ENC_GUESS β€” guess the encoding of name (this is the default, she's just winging it ✨). heads up tho: only CP-437 and UTF-8 are recognized, so don't get too creative.
  • ZIP_FL_ENC_UTF_8 β€” interpret name as UTF-8. slay, unambiguous, my beloved.
  • ZIP_FL_ENC_CP437 β€” interpret name as code page 437 (CP-437). retro queen behavior 🧚

πŸ”₯ RETURN VALUES πŸ”₯

  • if everything goes well (and it will, manifesting ✨), the index of the new entry in the archive is returned. she's giving you receipts.
  • otherwise, -1 is returned 😭 and the error code in archive gets set to tell you what went wrong.

πŸ’€ ERRORS πŸ’€

zip_dir_add() fails if:

  • [ZIP_ER_EXISTS] β€” there is already an entry called name in the archive. bestie she's already here, we can't have two of her πŸ’…
  • [ZIP_ER_INVAL] β€” archive or name are NULL, or the file names are invalid UTF-8 encoded. yeah that's a no from her πŸ™ˆ
  • [ZIP_ER_MEMORY] β€” required memory could not be allocated. ran out of room, tragic, devastating, actually.

πŸ‘‘ SEE ALSO πŸ‘‘

go read those next, iykyk 🌈


⭐ HISTORY ⭐

zip_dir_add() was added in libzip 0.11. a legend since day one, fr fr.


πŸ¦‹ AUTHORS πŸ¦‹

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β€” the two masterminds behind this masterpiece, we stan 🌸


and that's the whole page, bestie!! πŸ’– this cutie came from Debian and she's dated September 20, 2020, so if you're citing her, that's the version and date, and honestly? she's still eating. mwah πŸŽ€βœ¨