ZIP_SOURCE_BUFFER_FRAGMENT(3)
π NAME π
okay so bestie, this is zip_source_buffer_fragment(3) (the page header lowkey spells it ZIP_SOURCE_BUFFER_FRAGME, typo era, we move π
) β and the stars of the show are zip_source_buffer_fragment and zip_source_buffer_fragment_create, which create a zip data source from multiple buffers, not just one. iconic behaviour honestly.
π LIBRARY π
libzip β link it with -lzip and you're so set π
β¨ SYNOPSIS β¨
#include <zip.h>
zip_source_t *
zip_source_buffer_fragment(zip_t *archive,
zip_buffer_fragment_t *fragments, zip_uint64_t nfragments,
int freep);
zip_source_t *
zip_source_buffer_fragment_create(zip_buffer_fragment_t *fragments,
zip_uint64_t nfragments, int freep, zip_error_t *error);
π¦ DESCRIPTION π¦
So here's the vibe: zip_source_buffer_fragment() and zip_source_buffer_fragment_create() both build you a zip source out of the data sitting in fragments. nfragments tells them how many fragments there are. And if freep is non-zero? the data gets freed the moment it's no longer needed. clean-up queen energy π§Ήβ¨
here's the struct, copy it exactly, no editing:
struct zip_stat {
zip_uint8_t *data; /* pointer to the actual data */
zip_uint64_t length; /* length of this fragment */
};
β οΈ okay this part matters, bestie: the data the fragments point to has to stay valid for the entire lifetime of the source you create. don't be out here freeing it early π but fragments itself? that one you can toss the second the source is made. bye girl π
And the source you get back? you can use it to open a zip archive from. slay π
π RETURN VALUES π
If everything goes right, you get the created source back. if it doesn't? you get NULL, and the error code in archive or error gets set to tell you what went wrong. no cap π«Ά
π₯ ERRORS π₯
zip_source_buffer() and zip_source_buffer_create() fail if:
[ZIP_ER_INVAL]βnfragmentsis greater than zero andfragmentsisNULL. like girl you gotta actually give it something π[ZIP_ER_MEMORY]β the required memory could not be allocated. tragic. π
π SEE ALSO π
libzip(3), zip_file_add(3), zip_file_replace(3), zip_open_from_source(3), zip_source(5) β go read those too, iykyk π
πΈ HISTORY πΈ
zip_source_buffer_fragment() and zip_source_buffer_fragment_create() were added in libzip 1.4.0. glow up β¨
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β kings, honestly π
and that's the whole page, bestie!! this one came from Debian, dated December 18, 2017, and it lives at ZIP_SOURCE_BUFFER_FRAGMENT(3) in the manual. go build something cute with it, ily, bye ππβ¨
π¦ 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