ZIP_SOURCE_BUFFER_FRAGMENT_CREATE(3)

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

πŸ’– 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] β€” nfragments is greater than zero and fragments is NULL. 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