ZIP_DIR_ADD(3)
π 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
archiveis the zip archive that the directory is getting added to, like, that's the destination bestie nameis 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 ofname(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β interpretnameas UTF-8. slay, unambiguous, my beloved.ZIP_FL_ENC_CP437β interpretnameas 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,
-1is returned π and the error code inarchivegets set to tell you what went wrong.
π ERRORS π
zip_dir_add() fails if:
[ZIP_ER_EXISTS]β there is already an entry callednamein the archive. bestie she's already here, we can't have two of her π[ZIP_ER_INVAL]βarchiveornameareNULL, 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 πβ¨
π¦ 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-2020 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