---
name: "zip_file_extra_fields_count"
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_file_extra_fields_count"
---

# zip\_file\_extra\_fields\_count(3)

count extra fields for file in zip

## NAME

**zip\_file\_extra\_fields\_count**, **zip\_file\_extra\_fields\_count\_by\_id** – count extra fields for file in zip

## LIBRARY

libzip (-lzip)

## SYNOPSIS

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

*zip\_int16\_t*\

**zip\_file\_extra\_fields\_count**(*zip\_t \*archive*, *zip\_uint64\_t index*, *zip\_flags\_t flags*);

*zip\_int16\_t*\

**zip\_file\_extra\_fields\_count\_by\_id**(*zip\_t \*archive*, *zip\_uint64\_t index*, *zip\_uint16\_t extra\_field\_id*, *zip\_flags\_t flags*);

## DESCRIPTION

The **zip\_file\_extra\_fields\_count**() function counts the extra fields for the file at position *index* in the zip archive.

The following *flags* are supported:

- ZIP\_FL\_CENTRAL

  Count extra fields from the archive's central directory.

- ZIP\_FL\_LOCAL

  Count extra fields from the local file headers.

- ZIP\_FL\_UNCHANGED

  Count the original unchanged extra fields, ignoring any changes made.

The **zip\_file\_extra\_fields\_count\_by\_id**() function counts the extra fields with ID (two-byte signature) *extra\_field\_id*. The other arguments are the same as for **zip\_file\_extra\_fields\_count**().

Extra fields that are the same in the central directory and the local file header are merged into one. Therefore, the counts with ZIP\_FL\_CENTRAL and ZIP\_FL\_LOCAL do not need to add up to the same value as when given ZIP\_FL\_CENTRAL\|ZIP\_FL\_LOCAL at the same time.

## RETURN VALUES

Upon successful completion, the requested number of extra fields is returned. Otherwise, -1 is returned and the error code in *archive* is set to indicate the error.

## ERRORS

**zip\_file\_extra\_fields\_count**() and **zip\_file\_extra\_fields\_count\_by\_id**() fail if:

- \[ZIP\_ER\_NOENT\]

  *index* is not a valid file index in *archive*.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_file\_extra\_field\_delete(3)](/zip_file_extra_field_delete/3.md), [zip\_file\_extra\_field\_get(3)](/zip_file_extra_field_get/3.md), [zip\_file\_extra\_field\_set(3)](/zip_file_extra_field_set/3.md)

## HISTORY

**zip\_file\_extra\_fields\_count**() and **zip\_file\_extra\_fields\_count\_by\_id**() were added in libzip 0.11.

## AUTHORS

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