ZIP_SOURCE_ZIP_FILE(3)
β¨ zip_source_zip_file, zip_source_zip_file_create β¨
okay bestie, pull up a chair π this is the zip_source_zip_file page from the Library Functions Manual, and it's literally all about creating a data source from a zip file. yes, a zip inside a zip, we're doing inception but make it iconic. π
π«Ά LIBRARY
libzip β and yes you link it with -lzip, no cap.
πΈ SYNOPSIS
#include <zip.h>
zip_source_t *
zip_source_zip_file(zip_t *archive, zip_t *srcarchive,
zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start,
zip_int64_t length, const char *password);
zip_source_t *
zip_source_zip_file_create(zip_t *srcarchive, zip_uint64_t srcidx,
zip_flags_t flags, zip_uint64_t start, zip_int64_t length,
const char *password, zip_error_t *error);
look at those signatures. gorgeous. no notes. π
π DESCRIPTION
so zip_source_zip_file() and zip_source_zip_file_create() make a zip source out of a file that lives inside a zip archive. girl, it's a zip source from a zip file. the way that works is:
srcarchiveβ the (open) zip archive that's holding your source zip file. it's gotta be open, bestie, don't come at me with a closed one.srcidxβ the index of the file you want insidesrcarchive.startβ the offset you're starting from.lengthβ how many bytes from offsetstartget used in thezip_source. and iflengthis-1? then it's the rest of the file, starting fromstart, periodt. π
π‘ real talk: if you're planning to copy a file from one archive to another, using the flag ZIP_FL_COMPRESSED is more efficient, because it skips recompressing the file data. save your CPU the drama. π₯
π¦ Supported flags
ZIP_FL_COMPRESSEDβ get the compressed data. β οΈ this is only supported if you're asking for the complete file data (start == 0andlength == -1). it is not supported for changed data. default is uncompressed.ZIP_FL_ENCRYPTEDβ get the encrypted data. (this flag impliesZIP_FL_COMPRESSED, so don't act surprised.) β οΈ same deal: only supported if the complete file data is requested (start == 0andlength == -1). default is decrypted.ZIP_FL_UNCHANGEDβ try to get the original data, without any changes that may have been made tosrcarchiveafter opening it. the before-times data. π°οΈ
π RETURN VALUES
if it works? you get the created source back. slay. π
if it doesn't? you get NULL, and the error code in archive or error gets set to tell you what went wrong. not the vibe, but at least it's honest. π
π ERRORS
zip_source_zip_file() and zip_source_zip_file_create() fail if:
[ZIP_ER_CHANGED]β you asked for unchanged data, but it's just not available. it's giving "we don't have that anymore."[ZIP_ER_INVAL]βsrcarchive,srcidx,start, orlengthare invalid. one of them is lying to you. π[ZIP_ER_MEMORY]β the memory it needed could not be allocated. rip.
also, heads up: it can return all error codes from zip_stat_index() and zip_fopen_index() too, so don't be shocked when extra errors show up to the party. π
π SEE ALSO
β HISTORY
zip_source_zip_file() and zip_source_zip_file_create() were added in libzip 1.10.0. a modern classic. iykyk.
π§ AUTHORS
- Dieter Baron
<dillo@nih.at> - Thomas Klausner
<wiz@gatalith.at>
absolute legends, both of them. π
and that's the whole page, bestie!! π this one came from the Debian build, dated March 10, 2023, and it's ZIP_SOURCE_ZIP_FILE(3) β now go make some zip sources, you main character. π¦β¨
π¦ 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