ZIP_SOURCE_BUFFER(3)
π ZIP_SOURCE_BUFFER π
okay bestie, welcome to the zip_source_buffer(3) page β yes it's a manual page from the Library Functions Manual, and yes it's about turning a plain old buffer into a zip data source. it's giving "lowkey magic" and i'm obsessed. let's get into it π«Ά
β¨ NAME β¨
zip_source_buffer, zip_source_buffer_create β create zip data source from buffer
like. that's it. that's the whole vibe. one job. iconic. π
πΈ LIBRARY πΈ
libzip (-lzip)
you already know, link it and go π¦
β SYNOPSIS β
#include <zip.h>
zip_source_t *
zip_source_buffer(zip_t *archive, const void *data, zip_uint64_t len,
int freep);
zip_source_t *
zip_source_buffer_create(const void *data, zip_uint64_t len, int freep,
zip_error_t *error);
look at these two. siblings. twinsies. one takes an archive, one takes an error. that's the only difference and honestly? slay. π
π DESCRIPTION π
so here's the tea, bestie. both zip_source_buffer() and zip_source_buffer_create() do the exact same thing: they create a zip source out of the buffer data, which is len bytes big. that's it. a whole zip source, born from a buffer. main character energy fr fr β¨
now. the freep situation. if freep is non-zero, the buffer gets freed for you when it's no longer needed. cute, right? BUT β and this is important β data has to stay valid for the entire lifetime of the source you just created. the whole time. no take-backs. so don't be out here passing a stack buffer that's about to evaporate π
and the big news: the source you get back? you can use it to open a zip archive from. that's literally the point. zip_open_from_source() said hi π«Ά
π₯ RETURN VALUES π₯
on success, you get the created source back. yes, the actual source. hand it to you like a little gift π
otherwise β and we hate to see it β NULL comes back, and the error code inside archive or error is set to tell you what went wrong. so like, always check. don't ignore the NULL. that's a red flag in a situationship AND in C. π©
π ERRORS π
both zip_source_buffer() and zip_source_buffer_create() fail if:
[ZIP_ER_INVAL]βlenis greater than zero anddataisNULL. bestie you said there was data. there was no data. π[ZIP_ER_MEMORY]β required memory could not be allocated. the machine said no. it happens to the best of us. π
π SEE ALSO π
go read these next, i promise they're worth it:
π HISTORY π
zip_source_buffer() and zip_source_buffer_create() were added in libzip 1.0. so they've been around. they're not new here. they're veterans and they ate. β
π§ AUTHORS π§
the legends themselves: Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at>. we stan. π«Ά
also quick note: this page comes from the Debian crowd, dated December 18, 2017, and it lives atZIP_SOURCE_BUFFER(3)in theLibrary Functions Manual. so if you ever need to find it again, you know exactly where to look π
okay that's the whole page, bestie. go forth and buffer responsibly. mwah π β¨πΈ
π¦ 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