ZIP_FILE_EXTRA_FIELD_SET(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_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 IDs 0x0001 (the ZIP64 extension), 0x6375 (Infozip UTF-8 comment), and 0x7075 (Infozip UTF-8 file name) cannot be set with zip_file_extra_field_set(), because libzip(3) handles those itself automatically whenever it needs to. So don't even try it. πŸ™ˆ

🌈 RETURN VALUES 🌈

  • Glowed up and succeeded? 0 is returned. ✨
  • Messy? -1 comes back, and the error code inside archive gets 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 need 4 bytes; the maximum length of all extra fields for one file combined is 65536 bytes). This error also shows up if extra_field_index is too large. She's got limits, okay. 🫠
  • [ZIP_ER_MEMORY] β€” Required memory could not be allocated. πŸ’Έ
  • [ZIP_ER_NOENT] β€” index is not a valid file index in archive. 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 πŸ’…βœ¨