ZIP_SOURCE_STAT(3)
π zip_source_stat(3) π
okay so bestie, we're in the Library Functions Manual section of the zip_source_stat(3) page and honestly? it's giving "let me peek behind the curtain of a zip source." β¨
πΈ LIBRARY πΈ
libzip β link it with -lzip and you're in. π«Ά
β¨ SYNOPSIS β¨
#include <zip.h>
int
zip_source_stat(zip_source_t *source, zip_stat_t *sb);
π DESCRIPTION π
So the zip_source_stat() function does exactly what it says on the tin: it gets you info about the zip source, source. Like, all the tea. β
The sb argument is a pointer to a struct zip_source_stat (iconic structure, shown below), and that's where all the info about the zip source gets placed.
struct zip_source_stat {
zip_uint64_t valid; /* which fields have valid values */
const char *name; /* name of the file */
zip_uint64_t index; /* index within archive */
zip_uint64_t size; /* size of file (uncompressed) */
zip_uint64_t comp_size; /* size of file (compressed) */
time_t mtime; /* modification time */
zip_uint32_t crc; /* crc of file data */
zip_uint16_t comp_method; /* compression method used */
zip_uint16_t encryption_method; /* encryption method used */
zip_uint32_t flags; /* reserved for future use */
};
β οΈ real talk: the structure pointed to bysbmust be initialized withzip_stat_init(3)before you callzip_source_stat(). no skipping steps, bestie. π
The valid field is the vibe check for the rest of the struct β it tells you which other fields actually have valid values. So before you go touching any of those fields, check that the flag defined by these defines is in valid:
ZIP_STAT_NAMEβ fornameZIP_STAT_INDEXβ forindexZIP_STAT_SIZEβ forsizeZIP_STAT_COMP_SIZEβ forcomp_sizeZIP_STAT_MTIMEβ formtimeZIP_STAT_CRCβ forcrcZIP_STAT_COMP_METHODβ forcomp_methodZIP_STAT_ENCRYPTION_METHODβ forencryption_methodZIP_STAT_FLAGSβ forflags
π NOTE: some fields may only be filled out after all the data has been read from the source β for example thecrcorsizefields. so don't come for them too early, they're not ready yet. π
π₯ RETURN VALUES π₯
- Slayed successfully? You get
0. periodt. π - Otherwise you get
-1, and the error information insourcegets set to tell you what went wrong. π
π SEE ALSO π
β HISTORY β
zip_source_stat() was added in libzip 1.0. a classic, an OG, we stan. π
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β the icons who wrote this. π«Ά
and that's the whole page, bestie! this one came from the Debian crew, dated December 18, 2017, and it lives at ZIP_SOURCE_STAT(3). go forth and stat your sources. πβ¨
π¦ 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) 2014-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