ZIP_SOURCE_FILEP(3)
π 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, orlenare 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()andzip_source_filep_create()were added in libzip 1.0.ZIP_LENGTH_TO_ENDandZIP_LENGTH_UNCHECKEDwere 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
- arch rolling: libzip 1.11.4-1 Β· BSD
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- nixpkgs unstable: libzip 1.11.4
- ubuntu resolute: libzip-dev 1.11.4-2 Β· BSD-3-Clause
- ubuntu stonking: libzip-dev 1.11.4-2build1 Β· BSD-3-Clause
- Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms