ZIP_NAME_LOCATE(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_NAME_LOCATE(3) πŸ’–

ok so this is a page from the Library Functions Manual and we're talking about ZIP_NAME_LOCATE(3) bestie. come sit with me.


✨ NAME ✨

zip_name_locate β€” get index of file by name

πŸŽ€ LIBRARY πŸŽ€

libzip (-lzip)

🌸 SYNOPSIS 🌸

#include <zip.h>

zip_int64_t
zip_name_locate(zip_t *archive, const char *fname, zip_flags_t flags);

πŸ¦‹ DESCRIPTION πŸ¦‹

ok so zip_name_locate() hands you back the index of the file named fname inside archive. and if archive literally does not have a file with that name? you get -1. that's it, that's the whole vibe. 😭

if neither ZIP_FL_ENC_RAW nor ZIP_FL_ENC_STRICT are specified, it will guess the encoding of the name in the ZIP archive and convert it to UTF-8, if necessary, before comparing. guessing era fr.

if neither ZIP_FL_ENC_CP437 nor ZIP_FL_ENC_UTF_8 are specified, it guesses the encoding of fname.

Only CP-437 and UTF-8 are recognized. that's the whole roster, no plus ones.

the flags get specified by or'ing the following values, or 0 for none of them. slay:

  • ZIP_FL_NOCASE β€” ignore case distinctions. (will only work well if the file names are ASCII.) heads up bestie: with this flag, zip_name_locate() will be slow for archives with many files. πŸ’€
  • ZIP_FL_NODIR β€” ignore the directory part of the file name in the archive. and again: with this flag, zip_name_locate() will be slow for archives with many files.
  • ZIP_FL_ENC_GUESS β€” this flag has no effect (its value is 0); it can be used to explicitly denote the absence of encoding flags. it's giving "i'm here but i do nothing" energy πŸ™ˆ
  • ZIP_FL_ENC_RAW β€” compare fname against the unmodified names as they are in the ZIP archive, without converting them to UTF-8. raw dogging the bytes, no conversion.
  • ZIP_FL_ENC_STRICT β€” follow the ZIP specification and expect CP-437 encoded names in the ZIP archive (except if they are explicitly marked as UTF-8). convert them to UTF-8 before comparing. it's the rule-follower of the group.
  • ZIP_FL_ENC_CP437 β€” fname is encoded as CP-437.
  • ZIP_FL_ENC_UTF_8 β€” fname is encoded as UTF-8.
Note: ASCII is a subset of both CP-437 and UTF-8. so like, it's valid in both houses, iykyk πŸ’…

πŸ’… RETURN VALUES πŸ’…

zip_name_locate() returns the index of the file named fname, or -1, if archive does not contain an entry of that name.

😭 ERRORS 😭

zip_name_locate() fails if:

  • [ZIP_ER_INVAL] β€” one of the arguments is invalid. ma'am. 🫠
  • [ZIP_ER_MEMORY] β€” required memory could not be allocated. she tried her best.
  • [ZIP_ER_NOENT] β€” no entry of the name fname is found in the archive. ghosted fr.

πŸ‘‘ SEE ALSO πŸ‘‘

libzip(3), zip_get_name(3)

⭐ HISTORY ⭐

zip_name_locate() was added in libzip 0.6. in libzip 0.11 the return type was changed from int to zip_int64_t. and also in libzip 0.11 the type of flags was changed from int to zip_flags_t. glow-up era, honestly. ✨

🌈 AUTHORS 🌈

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β€” the icons who made all of this happen 🫢


and that's the tea, bestie πŸ’– this came from the Debian build, dated March 15, 2022 β€” go forth and locate some names, you've got this 🌸