---
name: "zip_set_file_extra"
section: "3"
platform: "linux"
package: "libzip-dev"
version: "0.10.1-1.1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/zip_set_file_extra"
---

# zip\_set\_file\_extra(3)

set extra field for file in zip

## NAME

zip\_set\_file\_extra - set extra field for file in zip

## LIBRARY

libzip (-lzip)

## SYNOPSIS

\#include \<zip.h\>

int zip\_set\_file\_extra(struct zip \*archive, zip\_uint64\_t index); "const char \*extra" "int len"

## DESCRIPTION

The zip\_set\_file\_extra function sets the extra field for the file at position **index** in the zip archive to **extra** of length **len.** If **extra** is **NULL** and **len** is 0, the file extra field will be removed.

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

zip\_set\_file\_extra fails if:

- \[ZIP\_ER\_INVAL\]

  **index** is not a valid file index in **archive,** or **len** is less than 0 or longer than the maximum extra field length in a zip file (65535).

- \[ZIP\_ER\_MEMORY\]

  Required memory could not be allocated.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_get\_file\_extra(3)](/zip_get_file_extra/3.md)

## AUTHORS

Dieter Baron \<dillo@giga.or.at\> and Thomas Klausner \<tk@giga.or.at\>
