ZIP_SOURCE_STAT(3)

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

πŸ’– 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 by sb must be initialized with zip_stat_init(3) before you call zip_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 β€” for name
  • ZIP_STAT_INDEX β€” for index
  • ZIP_STAT_SIZE β€” for size
  • ZIP_STAT_COMP_SIZE β€” for comp_size
  • ZIP_STAT_MTIME β€” for mtime
  • ZIP_STAT_CRC β€” for crc
  • ZIP_STAT_COMP_METHOD β€” for comp_method
  • ZIP_STAT_ENCRYPTION_METHOD β€” for encryption_method
  • ZIP_STAT_FLAGS β€” for flags
πŸ“ NOTE: some fields may only be filled out after all the data has been read from the source β€” for example the crc or size fields. 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 in source gets 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