ZIP_FILE_EXTRA_FIELDS_COUNT_BY_ID(3)
π zip_file_extra_fields_count(3) π
okay bestie, so this is a page from the Library Functions Manual and it's all about counting extra fields in zip files. yes. counting. it's giving census but for zip metadata. let's get into it π
β¨ NAME β¨
zip_file_extra_fields_count, zip_file_extra_fields_count_by_id β count extra fields for file in zip
ngl the name is literally the whole plot. two functions, both counting extra fields, one of them has a lil id filter. iconic behavior honestly.
π LIBRARY π
libzip (-lzip)
that's the vibe. link against it, love it, live it. π
πΈ SYNOPSIS πΈ
#include <zip.h>
zip_int16_t
zip_file_extra_fields_count(zip_t *archive, zip_uint64_t index,
zip_flags_t flags);
zip_int16_t
zip_file_extra_fields_count_by_id(zip_t *archive, zip_uint64_t index,
zip_uint16_t extra_field_id, zip_flags_t flags);
look at those signatures. gorgeous. both return a zip_int16_t, both take an archive and an index, and the second one is the extra-fancy one that also takes an extra_field_id. she's got range. π
π DESCRIPTION π
so the zip_file_extra_fields_count() function counts the extra fields for the file at position index in the zip archive. that's it. that's the job. she counts. periodt.
the following flags are supported:
ZIP_FL_CENTRALβ count extra fields from the archive's central directory. central directory core fr. πZIP_FL_LOCALβ count extra fields from the local file headers. the local girlies. πΈZIP_FL_UNCHANGEDβ count the original unchanged extra fields, ignoring any changes made. no edits, no notes, just the OG. β¨
and then zip_file_extra_fields_count_by_id() counts the extra fields with ID (two-byte signature) extra_field_id. the other arguments are the same as for zip_file_extra_fields_count(). so it's the same girlie but she's filtering by id now. slay.
π important lore alert: extra fields that are the same in the central directory and the local file header are merged into one. therefore, the counts withZIP_FL_CENTRALandZIP_FL_LOCALdo not need to add up to the same value as when givenZIP_FL_CENTRAL|ZIP_FL_LOCALat the same time. so do NOT come for me with "but the math doesn't math" β the math is literally not supposed to math. it's giving merged. it's giving deduplicated. iykyk. π
π«Ά RETURN VALUES π«Ά
upon successful completion, the requested number of extra fields is returned. otherwise, -1 is returned and the error code in archive is set to indicate the error.
so either you get your count, or you get a -1 and a lil error situation. one or the other bestie. no in between. β¨
π¨ ERRORS π¨
zip_file_extra_fields_count() and zip_file_extra_fields_count_by_id() fail if:
[ZIP_ER_NOENT]βindexis not a valid file index inarchive. yeah she looked for that file and it was simply not there. tragic. π
π SEE ALSO π
the whole extra-field friend group. go read them, they're all connected, it's a whole universe. π
π HISTORY π
zip_file_extra_fields_count() and zip_file_extra_fields_count_by_id() were added in libzip 0.11.
throwback era. vintage. the origin story. π
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at>
the legends themselves. we stan. π«Ά
and that's the whole page bestie, from the Debian build dated December 18, 2017, living under ZIP_FILE_EXTRA_FIELDS_COUNT(3) π now go count those extra fields, you absolute icon. no cap. πΈβ¨π
π¦ 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) 2012-2017 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