---
name: "zip_source_stat"
section: "3"
platform: "linux"
package: "libzip"
version: "1.11.4-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/zip_source_stat"
---

# zip\_source\_stat(3)

get information about zip\_source

## NAME

**zip\_source\_stat** – get information about zip\_source

## LIBRARY

libzip (-lzip)

## SYNOPSIS

**#include \<zip.h\>**

*int*\

**zip\_source\_stat**(*zip\_source\_t \*source*, *zip\_stat\_t \*sb*);

## DESCRIPTION

The **zip\_source\_stat**() function obtains information about the zip source *source*

The *sb* argument is a pointer to a *struct* *zip\_source\_stat* (shown below), into which information about the zip source is 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 */
};
```

The structure pointed to by *sb* must be initialized with **zip\_stat\_init**(*3*) before calling **zip\_source\_stat**().

The *valid* field of the structure specifies which other fields are valid. Check if the flag defined by the following defines are in *valid* before accessing the fields:

- ZIP\_STAT\_NAME

  *name*

- ZIP\_STAT\_INDEX

  *index*

- ZIP\_STAT\_SIZE

  *size*

- ZIP\_STAT\_COMP\_SIZE

  *comp\_size*

- ZIP\_STAT\_MTIME

  *mtime*

- ZIP\_STAT\_CRC

  *crc*

- ZIP\_STAT\_COMP\_METHOD

  *comp\_method*

- ZIP\_STAT\_ENCRYPTION\_METHOD

  *encryption\_method*

- ZIP\_STAT\_FLAGS

  *flags*

*NOTE*: Some fields may only be filled out after all data has been read from the source, for example the *crc* or *size* fields.

## RETURN VALUES

Upon successful completion 0 is returned. Otherwise, -1 is returned and the error information in *source* is set to indicate the error.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_source(5)](/zip_source/5.md)

## HISTORY

**zip\_source\_stat**() was added in libzip 1.0.

## AUTHORS

Dieter Baron ⟨*dillo@nih.at*⟩ and Thomas Klausner ⟨*wiz@gatalith.at*⟩
