ZIP_STAT(3)
π ZIP_STAT(3) π
okay bestie, welcome to the Library Functions Manual for ZIP_STAT, aka the libzip page that tells you everything you ever wanted to know about a file in an archive. pull up a chair, grab a boba, we're doing this. π§β¨
β¨ NAME β¨
zip_stat, zip_stat_index β get information about file π΅οΈβοΈπ
π LIBRARY π
libzip (<code>-lzip</code>) β you gotta link it, bestie, it's not gonna link itself. π«Ά
πΈ SYNOPSIS πΈ
#include <zip.h>
int
zip_stat(zip_t *archive, const char *fname, zip_flags_t flags,
zip_stat_t *sb);
int
zip_stat_index(zip_t *archive, zip_uint64_t index, zip_flags_t flags,
zip_stat_t *sb);
π« DESCRIPTION π«
so zip_stat() is the vibe-check function. it goes and gets you information about the file named fname in archive. iconic behaviour, truly. π
the flags argument is what controls how the name lookup should be done. all its little values are described over in zip_name_locate(3) β go read that one too, i'm not doing your homework for you. also, ZIP_FL_UNCHANGED can be or'ed onto it, which asks for info about the original file in the archive, straight-up ignoring any changes that were made. like, "no edits, just the og, thanks." π
and then zip_stat_index() does the exact same thing but it's information about the file at position index instead of by name. index girlies, this one's for you. π
the sb argument is a pointer to a struct zip_stat (shown right below, don't scroll past it), and all the info about the file gets placed into it. here's the whole thing, verbatim, no cap:
struct zip_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 */
};
bestie, listen. the structure pointed to bysbmust be allocated before callingzip_stat()orzip_stat_index(). if you forget, that's on you, not me. π
okay so the valid field is the β¨main characterβ¨ here β it specifies which other fields are valid. do NOT just start reading fields all willy-nilly. you gotta check if the flag defined by these defines is in valid before you access the fields:
ZIP_STAT_NAMEβnameZIP_STAT_INDEXβindexZIP_STAT_SIZEβsizeZIP_STAT_COMP_SIZEβcomp_sizeZIP_STAT_MTIMEβmtimeZIP_STAT_CRCβcrcZIP_STAT_COMP_METHODβcomp_methodZIP_STAT_ENCRYPTION_METHODβencryption_methodZIP_STAT_FLAGSβflags
check first, read second. that's the rule. π
π«Ά RETURN VALUES π«Ά
0β slayed. successful completion, we ate. β¨-1β not slayed. it failed, and the error information inarchiveis set to indicate the error. π
π ERRORS π
zip_stat() can fail for any of the errors specified for the routine zip_name_locate(3). like, all of them. every single one. go look.
zip_stat_index() fails and sets the error information to ZIP_ER_INVAL if index is invalid. π
βοΈ
and if ZIP_FL_UNCHANGED is not set and no information can be obtained from the source callback, the error information gets set to ZIP_ER_CHANGED. so like... nothing to report, bestie, sorry. π
π SEE ALSO π
libzip(3), zip_get_num_entries(3), zip_name_locate(3), zip_stat_init(3)
go read those too, i believe in you. πβ¨
π HISTORY π
zip_stat() was added in libzip 0.6. then in libzip 0.11 the type of flags was changed from int to zip_flags_t. glow-up fr. π
zip_stat_index() was added in libzip 0.6. in libzip 0.10 the type of index was changed from int to zip_uint64_t. and then in libzip 0.11 the type of flags was changed from int to zip_flags_t. two glow-ups, she's thriving. πΈ
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β thank you kings, we stan. π«Άβ¨
and that's the whole page, bestie!! this one shipped out from Debian on December 18, 2017 and it lives at ZIP_STAT(3) in the manual. now go stat something and be free. mwah. πππ¦
π¦ where this page comes from
- arch rolling: libzip 1.11.4-1 Β· BSD
- debian trixie: libzip-dev 1.11.3-2 Β· BSD-3-Clause
- 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 questing: libzip-dev 1.11.3-2
- ubuntu resolute: libzip-dev 1.11.4-2 Β· BSD-3-Clause
- ubuntu stonking: libzip-dev 1.11.4-2build1 Β· BSD-3-Clause
- Copyright (C) 2003-2017 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