ZIP_FILE_EXTRA_FIELD_DELETE(3)

πŸ“¦
version 1.11.4 Β· 3 versions
, in arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

zip_file_extra_field_delete, zip_file_extra_field_delete_by_id β€” bestie, we're deleting extra fields for a file in a zip πŸ’…

This is a page from the libzip manual, section 3 (library functions), so you know it's the real deal πŸŽ€


🌸 LIBRARY 🌸

libzip β€” link it with -lzip and you're golden ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <zip.h>

int
zip_file_extra_field_delete(zip_t *archive, zip_uint64_t index,
    zip_uint16_t extra_field_index, zip_flags_t flags);

int
zip_file_extra_field_delete_by_id(zip_t *archive, zip_uint64_t index,
    zip_uint16_t extra_field_id, zip_uint16_t extra_field_index,
    zip_flags_t flags);

πŸ’– DESCRIPTION πŸ’–

Okay so, zip_file_extra_field_delete() does exactly what it says on the tin: it deletes the extra field with index extra_field_index for the file sitting at position index in the zip archive. Gone. Poof. Not me ✨

And if extra_field_index is ZIP_EXTRA_FIELD_ALL? Then every single extra field gets deleted β€” full clear-out, no survivors 😭

These are the flags it supports, and yes you gotta know them:

  • ZIP_FL_CENTRAL β€” delete extra fields from the archive's central directory πŸ‘‘
  • ZIP_FL_LOCAL β€” delete extra fields from the local file headers 🏠

Now for the glow-up: zip_file_extra_field_delete_by_id() deletes the extra field with ID (that's the two-byte signature) extra_field_id and index extra_field_index β€” in other words, the extra_field_index'th extra field with ID extra_field_id. Everything else works the same as zip_file_extra_field_delete(), and yeah, ZIP_EXTRA_FIELD_ALL here will delete all extra fields of the specified ID πŸ’€

⚠️ Important note, bestie, listen up: because of how the library is designed, the index of an extra field may be different between the central directory and the local file headers. So for that reason, you are not allowed to specify both ZIP_FL_CENTRAL and ZIP_FL_LOCAL in flags β€” the one exception is when you're deleting all extra fields, i.e. when extra_field_index is ZIP_EXTRA_FIELD_ALL. Any other combo? Not it. πŸ™ˆ

πŸ”₯ RETURN VALUES πŸ”₯

If it works, you get 0 back. Iconic. πŸŽ‰

If it doesn't, you get -1, and the error code in archive gets set to tell you what went wrong 😭


🌈 ERRORS 🌈

Both zip_file_extra_field_delete() and zip_file_extra_field_delete_by_id() fail if:

  • ZIP_ER_NOENT β€” index is not a valid file index in archive. That file does not exist, babes πŸ’€

🫢 SEE ALSO 🫢

libzip(3), zip_file_extra_field_get(3), zip_file_extra_field_set(3), zip_file_extra_fields_count(3)


⭐ HISTORY ⭐

zip_file_extra_field_delete() and zip_file_extra_field_delete_by_id() were added in libzip 0.11. Vintage, but make it fashion πŸ’œ


πŸ‘‘ AUTHORS πŸ‘‘

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β€” the icons who wrote this, we stan 🌸


and that's the whole page, bestie!! this came from the Debian build, dated December 18, 2017, and yeah the footer still calls it ZIP_FILE_EXTRA_FIELD_DELETE(3) β€” slay, go delete some extra fields responsibly πŸ’–βœ¨πŸŽ€