ZIP_SOURCE_FILEP(3)

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

πŸ’– zip_source_filep β€” the manual page, but make it make sense πŸ’–

okay bestie, so this is a page from the Library Functions Manual, and it's all about zip_source_filep and zip_source_filep_create. Yes the name is a mouthful. No we're not changing it. Let's go πŸ¦‹


✨ NAME ✨

zip_source_filep, zip_source_filep_create β€” literally just "create a data source from a FILE *". that's the whole job. that's it. πŸ’…


πŸ“š LIBRARY πŸ“š

libzip β€” link it with -lzip, and don't forget it or the linker will be so dramatic about it 😭


🌸 SYNOPSIS 🌸

#include <zip.h>

zip_source_t *
zip_source_filep(zip_t *archive, FILE *file, zip_uint64_t start,
    zip_int64_t len);

zip_source_t *
zip_source_filep_create(FILE *file, zip_uint64_t start, zip_int64_t len,
    zip_error_t *error);

bestie look at those signatures. one takes an archive, one takes an error. that's the whole difference, iykyk πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

so zip_source_filep() and zip_source_filep_create() are the girlies that build you a zip source out of a file stream. 🧚

what they do: they read len bytes, starting from offset start, out of the open file stream file.

now, about that len argument β€” the tea is fully spilled over in zip_source_file(3), so go read that for the whole explanation. not me redirecting you mid-paragraph but it's literally the right place πŸ’€

if the file stream supports seeking, then the source can be used to open a read-only zip archive from. slay. ✨

and here's the part you gotta remember: the file stream gets closed when the source is being freed, which is usually triggered by zip_close(3). so don't go closing it yourself and then acting surprised, okay? 🫢


πŸ”₯ RETURN VALUES πŸ”₯

if everything goes well β†’ the created source is returned. iconic. πŸ‘‘

if it doesn't β†’ NULL comes back, and the error code in archive or error is set so it can tell you what went wrong. that's your vibe check failing, fr fr. 😭


πŸ’€ ERRORS πŸ’€

zip_source_filep() fails if:

  • ZIP_ER_INVAL β€” file, start, or len are invalid. one of them is lying to you πŸ™ˆ
  • ZIP_ER_MEMORY β€” required memory could not be allocated. the machine said "no <3" πŸ’”

πŸ‘€ SEE ALSO πŸ‘€

go read them. all of them. for me. 🫢


🌈 HISTORY 🌈

  • zip_source_filep() and zip_source_filep_create() were added in libzip 1.0.
  • ZIP_LENGTH_TO_END and ZIP_LENGTH_UNCHECKED were added in libzip 1.10.1.

periodt. that's the timeline. ⭐


🫢 AUTHORS 🫢

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β€” the actual main characters who wrote this. respect. πŸ’œ


and that's the page!! this came out of the Debian build of the manual, dated June 30, 2023, filed under ZIP_SOURCE_FILEP(3) β€” mwah, no notes, go write some zip sources bestie πŸ’…βœ¨

πŸ“¦ where this page comes from