---
name: "zip_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_stat"
---

# zip\_stat(3)

get information about file

## NAME

**zip\_stat**, **zip\_stat\_index** – get information about file

## LIBRARY

libzip (-lzip)

## 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

The **zip\_stat**() function obtains information about the file named *fname* in *archive*. The *flags* argument specifies how the name lookup should be done. Its values are described in [zip\_name\_locate(3)](/zip_name_locate/3.md). Also, ZIP\_FL\_UNCHANGED may be *or*'ed to it to request information about the original file in the archive, ignoring any changes made.

The **zip\_stat\_index**() function obtains information about the file at position *index*.

The *sb* argument is a pointer to a *struct* *zip\_stat* (shown below), into which information about the file is placed.

```
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 */
};
```

The structure pointed to by *sb* must be allocated before calling **zip\_stat**() or **zip\_stat\_index**().

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*

## RETURN VALUES

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

## ERRORS

The function **zip\_stat**() can fail for any of the errors specified for the routine [zip\_name\_locate(3)](/zip_name_locate/3.md).

The function **zip\_stat\_index**() fails and sets the error information to ZIP\_ER\_INVAL if *index* is invalid. If ZIP\_FL\_UNCHANGED is not set and no information can be obtained from the source callback, the error information is set to ZIP\_ER\_CHANGED.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_get\_num\_entries(3)](/zip_get_num_entries/3.md), [zip\_name\_locate(3)](/zip_name_locate/3.md), [zip\_stat\_init(3)](/zip_stat_init/3.md)

## HISTORY

**zip\_stat**() was added in libzip 0.6. In libzip 0.11 the type of *flags* was changed from *int* to *zip\_flags\_t*.

**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*. In libzip 0.11 the type of *flags* was changed from *int* to *zip\_flags\_t*.

## AUTHORS

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