---
name: "zip_file_extra_field_get"
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_field_get"
---

# zip\_file\_extra\_field\_get(3)

get extra field for file in zip

## NAME

**zip\_file\_extra\_field\_get**, **zip\_file\_extra\_field\_get\_by\_id** – get extra field for file in zip

## LIBRARY

libzip (-lzip)

## SYNOPSIS

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

*const* *zip\_uint8\_t* *\**\

**zip\_file\_extra\_field\_get**(*zip\_t \*archive*, *zip\_uint64\_t index*, *zip\_uint16\_t extra\_field\_index*, *zip\_uint16\_t \*idp*, *zip\_uint16\_t \*lenp*, *zip\_flags\_t flags*);

*const* *zip\_uint8\_t* *\**\

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

## DESCRIPTION

The **zip\_file\_extra\_field\_get**() function returns the extra field with index *extra\_field\_index* for the file at position *index* in the zip archive. This pointer should not be modified or [free(3)](/free/3.md)'d, and becomes invalid when *archive* is closed. If *idp* is not NULL, the integer to which it points will be set to the ID (two-byte signature) of the selected extra field. If *lenp* is not NULL, the integer to which it points will be set to the length of the extra field. Generally speaking, *lenp* and *idp* should be passed since only the extra field data is returned (i.e., neither the ID nor the length, if the *idp* and *lenp* arguments are not provided).

The following *flags* are supported:

- ZIP\_FL\_CENTRAL

  Return extra fields from the archive's central directory.

- ZIP\_FL\_LOCAL

  Return extra fields from the local file headers.

- ZIP\_FL\_UNCHANGED

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

The **zip\_file\_extra\_field\_get\_by\_id**() function returns the extra field with ID (two-byte signature) *extra\_field\_id* and index *extra\_field\_index* (in other words, the *extra\_field\_index*'th extra field with ID *extra\_field\_id*) The other arguments are the same as for **zip\_file\_extra\_field\_get**().

## RETURN VALUES

Upon successful completion, a pointer to an extra field is returned, or NULL if there is no extra field with that *extra\_field\_index* for the file with index *index*. In case of an error, NULL is returned and the error code in *archive* is set to indicate the error.

## ERRORS

**zip\_file\_extra\_field\_get**() and **zip\_file\_extra\_field\_get\_by\_id**() fail if:

- \[ZIP\_ER\_NOENT\]

  *index* is not a valid file index in *archive*, or *extra\_field\_index* is not a valid extra file index (for ID *extra\_field\_id*).

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_file\_extra\_field\_delete(3)](/zip_file_extra_field_delete/3.md), [zip\_file\_extra\_field\_set(3)](/zip_file_extra_field_set/3.md), [zip\_file\_extra\_fields\_count(3)](/zip_file_extra_fields_count/3.md)

## HISTORY

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

## AUTHORS

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

## CAVEATS

Please note that the extra field IDs 0x0001 (ZIP64 extension), 0x6375 (Infozip UTF-8 comment), and 0x7075 (Infozip UTF-8 file name) can not be read using **zip\_file\_extra\_field\_get**() since they are used by [libzip(3)](/libzip/3.md) internally.
