ZIP_SOURCE_ZIP(3)

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

πŸ’– zip_source_zip β€” the NAME moment πŸ’–

okay bestie, gather round, because this page is literally called zip_source_zip, zip_source_zip_create and what it does is create a data source from a zip file β€” and yes, it's the obsolete interface, we'll get to that, don't panic 🫢


πŸ“š LIBRARY πŸ“š

libzip (-lzip) β€” that's the one, that's the girl πŸ’…


✨ SYNOPSIS ✨

#include <zip.h>

zip_source_t *
zip_source_zip(zip_t *archive, zip_t *srcarchive, zip_uint64_t srcidx,
    zip_flags_t flags, zip_uint64_t start, zip_int64_t len);

zip_source_t *
zip_source_zip_create(zip_t *srcarchive, zip_uint64_t srcidx,
    zip_flags_t flags, zip_uint64_t start, zip_int64_t len,
    zip_error_t *error);

like look at those signatures, they ate πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

so. real talk. zip_source_zip() and zip_source_zip_create() are the obsolete versions of zip_source_zip_file(3) and zip_source_zip_file_create(3) respectively. old queens, still iconic, but the newer ones are the main characters now. 😭

if what you actually want is the compressed data of the complete file, you do this instead:

zip_source_zip_file(za, source_archive, source_index,
ZIP_FL_COMPRESSED, 0, -1, NULL)

periodt. write that down.

now, what do the old ones actually do? They create a zip source from a file inside a zip archive. So:

  • srcarchive is the (open!) zip archive that's holding the source zip file, and that file lives at index srcidx β€” got it? index, not name, bestie.
  • len bytes starting from offset start get used in the zip_source.
  • if len is 0 or -1, then it's the rest of the file, starting from start. simple as.
  • and if start is zero and len is -1, the whole file gets copied without decompressing it. no decompression, just vibes. πŸ’…

the flags that are supported (just the one, she's lowkey solo):

  • ZIP_FL_UNCHANGED β€” try to get the original data, without any of the changes that may have been made to srcarchive after it was opened. like, pre-edit footage. no cap.

πŸŽ€ RETURN VALUES πŸŽ€

if it works? the created source is returned. slay. πŸŽ‰

if it doesn't? NULL comes back, and the error code in archive or error is set to tell you what went wrong. it's giving "we need to talk". πŸ’€


πŸ’€ ERRORS πŸ’€

zip_source_zip() and zip_source_zip_create() fail if:

  • [ZIP_ER_CHANGED] β€” you asked for unchanged data, but it's just not available. she's not there, babe. πŸ™ˆ
  • [ZIP_ER_INVAL] β€” srcarchive, srcidx, start, or len are invalid. check ur args bestie.
  • [ZIP_ER_MEMORY] β€” the memory it needed could not be allocated. 😭

and additionally, it can return all error codes from zip_stat_index() and zip_fopen_index(). so many possibilities, she contains multitudes ✨


πŸ‘‘ SEE ALSO πŸ‘‘

libzip(3), zip_file_add(3), zip_file_replace(3), zip_source(5)

go read them, iykyk 🌈


🌸 HISTORY 🌸

  • zip_source_zip() was added in libzip 1.0.
  • zip_source_zip_create() was added in libzip 1.8.0.
  • Both were deprecated in libzip 1.10.0. πŸ’€ rip boo, you had a good run.
  • Use zip_source_zip_file() or zip_source_zip_file_create() instead. that's the assignment. 🫢

πŸ’œ AUTHORS πŸ’œ

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β€” the parents of this whole thing, obsessed with them πŸ’–


and that's the page!! this was the Debian build of the zip_source_zip(3) manual, dated January 23, 2023 β€” mwah, thanks for reading, love u, bye bestie!! πŸ’…βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from