ZIP_FILE_EXTRA_FIELD_SET(3)
β¨ ZIP_FILE_EXTRA_FIELD_SET(3) β¨
okay bestie, pull up a chair π«Ά this one's a manual page for libzip β specifically the zip_file_extra_field_set() function β and it's giving "Library Functions Manual" energy. Let's get into it, no cap. π
πΈ NAME πΈ
zip_file_extra_field_set β set extra field for file in zip β¨
π LIBRARY π
libzip (-lzip) β link it and you're set, periodt.
π¦ SYNOPSIS π¦
#include <zip.h>
int
zip_file_extra_field_set(zip_t *archive, zip_uint64_t index,
zip_uint16_t extra_field_id, zip_uint16_t extra_field_index,
const zip_uint8_t *extra_field_data, zip_uint16_t len,
zip_flags_t flags);
Look at all those arguments. She's thriving. π
π DESCRIPTION π
So basically, zip_file_extra_field_set() sets the extra field with ID (that's a two-byte signature) extra_field_id and index extra_field_index for the file sitting at position index in the zip archive. π¦β¨
The extra field's data gets set to extra_field_data and its length to len.
Want to append a brand new entry instead of editing an existing one? Set extra_field_index to ZIP_EXTRA_FIELD_NEW and she's slotted in at the end. π
At least one of these flags must be set, bestie β pick your fighter:
ZIP_FL_CENTRALβ Set extra field in the archive's central directory. πZIP_FL_LOCALβ Set extra field in the local file headers. π
β οΈ heads up gorgeous β οΈ The extra field IDs0x0001(the ZIP64 extension),0x6375(Infozip UTF-8 comment), and0x7075(Infozip UTF-8 file name) cannot be set withzip_file_extra_field_set(), becauselibzip(3)handles those itself automatically whenever it needs to. So don't even try it. π
π RETURN VALUES π
- Glowed up and succeeded?
0is returned. β¨ - Messy?
-1comes back, and the error code insidearchivegets set to tell you what went wrong. π
π ERRORS π
zip_file_extra_field_set() fails (as in, no slay) if:
[ZIP_ER_INVAL]β The extra field size is too large (ID and length need4bytes; the maximum length of all extra fields for one file combined is65536bytes). This error also shows up ifextra_field_indexis too large. She's got limits, okay. π«[ZIP_ER_MEMORY]β Required memory could not be allocated. πΈ[ZIP_ER_NOENT]βindexis not a valid file index inarchive. Doesn't exist, babes. π»
π SEE ALSO π
libzip(3), zip_file_extra_field_delete(3), zip_file_extra_field_get(3), zip_file_extra_fields_count(3)
Squad goals, honestly. Go read them too. π
π°οΈ HISTORY π°οΈ
zip_file_extra_field_set() was added in libzip 0.11. A legend from the start. β
π§ AUTHORS π§
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β the icons who made this happen. π«Ά
Debian shipped this page dated December 18, 2017, and it lives in the ZIP_FILE_EXTRA_FIELD_SET(3) era of the manual, bestie. That's the whole tea. π bye 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) 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