ZIP_FDOPEN(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_FDOPEN(3) πŸ’–

okay bestie, gather round β€” this is the zip_fdopen page from the Library Functions Manual, and it's literally the shortcut for "I already have an open file descriptor, just zip it open for me" 🫢


✨ NAME ✨

zip_fdopen β€” open zip archive using open file descriptor 🌸

πŸ“š LIBRARY πŸ“š

libzip (-lzip) β€” that's the one, no cap πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

#include <zip.h>

zip_t *
zip_fdopen(int fd, int flags, int *errorp);

πŸ’œ DESCRIPTION πŸ’œ

So here's the vibe: the zip archive that your open file descriptor fd points at gets opened, and you get back a pointer to a struct zip β€” that's the lil handle you use to actually mess with the archive ✨

But bestie, listen: unlike zip_open(3), when you come through zip_fdopen the archive can only be opened in read-only mode. That's just the deal. πŸ™ˆ

Also, the fd argument may not be used any longer after calling zip_fdopen β€” like, it's been claimed, it's got main character energy now, hands off 😭

The flags are specified by or'ing the following values, or 0 for none of them:

  • ZIP_CHECKCONS β€” do extra stricter consistency checks on the archive, and error out if they fail πŸ‘‘

If an error happens and errorp is non-NULL, it gets set to the corresponding error code. Simple as that.

🌈 RETURN VALUES 🌈

On the happy path, zip_fdopen() returns a struct zip pointer, and fd should not be used any longer β€” nor passed to close(2) ⚠️ (fr fr, don't do it).

Otherwise you get NULL back and *errorp is set to indicate the error. And in the error case, fd remains unchanged β€” so it's not just gone, okay? 🫢

πŸ’€ ERRORS πŸ’€

The file specified by fd is prepared for use by libzip(3) unless:

  • [ZIP_ER_INCONS] β€” Inconsistencies were found in the file specified by path. This error is often caused by specifying ZIP_CHECKCONS but can also happen without it 😭
  • [ZIP_ER_INVAL] β€” The flags argument is invalid. Not all zip_open(3) flags are allowed for zip_fdopen, see "DESCRIPTION" πŸ‘€
  • [ZIP_ER_MEMORY] β€” Required memory could not be allocated πŸ’€
  • [ZIP_ER_NOZIP] β€” The file specified by fd is not a zip archive πŸ™…
  • [ZIP_ER_OPEN] β€” The file specified by fd could not be prepared for use by libzip(3)
  • [ZIP_ER_OPNOTSUPP] β€” This functionality has been disabled at compile time 🚫
  • [ZIP_ER_READ] β€” A read error occurred; see errno for details
  • [ZIP_ER_SEEK] β€” The file specified by fd does not allow seeks πŸŒ€

πŸ‘€ SEE ALSO πŸ‘€

libzip(3), zip_close(3), zip_error_strerror(3), zip_open(3)

πŸ¦‹ HISTORY πŸ¦‹

zip_fdopen() was added in libzip 1.0 β€” vintage, honestly πŸ’…

πŸ‘‘ AUTHORS πŸ‘‘

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β€” icons, we thank them 🫢


k bye, this page came from the Debian crew on September 23, 2022, and that's the whole tea πŸ“βœ¨