ZIP_UNCHANGE(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_UNCHANGE(3) ✨

okay bestie, this is the Library Functions Manual page for zip_unchange, and it's lowkey one of the most satisfying little functions in libzip β€” it's the undo button πŸ’…


πŸ’– NAME πŸ’–

zip_unchange β€” undo changes to file in zip archive

no fr, that's it. that's the whole vibe. you changed something, you regret it, you take it back. main character redemption arc πŸ¦‹


πŸ“š LIBRARY πŸ“š

libzip (-lzip)

that's the library you're linking against, bestie. don't forget the flag or the linker will simply not know her 😭


🌸 SYNOPSIS 🌸

#include <zip.h>

int
zip_unchange(zip_t *archive, zip_uint64_t index);

so you include <zip.h>, you hand her your archive, you hand her the index of the file you're having second thoughts about, and she returns an int. simple. iconic. no notes. ✨


πŸŽ€ DESCRIPTION πŸŽ€

Changes to the file at position index are reverted.

that's the whole thing!! reverted. all the little edits, the renames, the whatever-you-did β€” gone, back to how the archive originally had it. it's giving "not me accidentally editing a file in a zip and needing a full factory reset" πŸ™ˆ


πŸ’œ RETURN VALUES πŸ’œ

  • 0 β€” slay, it worked, we're so back 🫢
  • -1 β€” nope, something went wrong, and the error code in archive is set to tell you exactly what.

periodt.


πŸ”₯ ERRORS πŸ”₯

zip_unchange() fails if:

  • [ZIP_ER_EXISTS] β€” Unchanging the name would result in a duplicate name in the archive.

like... you'd end up with two files sharing a name and the archive is NOT doing that. it's giving "there can only be one" πŸ‘‘

  • [ZIP_ER_INVAL] β€” index is not a valid file index in zip.

you pointed at something that isn't a real file in there. vibe check failed. index invalid, bestie πŸ’€


πŸ‘€ SEE ALSO πŸ‘€

iykyk β€” if you want to undo everything, go peep those two. this one is just for the one file. 🧚


🌈 HISTORY 🌈

  • zip_unchange() was added in libzip 0.6. a legend was born.
  • In libzip 0.10 the type of index was changed from int to zip_uint64_t.

so if you're reading old code and the signature looks different β€” that's why. glow-up era ✨


πŸ‘‘ AUTHORS πŸ‘‘

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at>

the founding mothers/fathers of this whole thing, we stan 🫢


and that's the page!! this little gem comes to you from Debian, dated December 18, 2017 β€” yes the footer said so, and yes I'm telling you anyway because we respect our elders πŸ’– now go undo something, bestie 🌸