---
name: "zip_get_name"
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_get_name"
---

# zip\_get\_name(3)

get name of file by index

## NAME

**zip\_get\_name** – get name of file by index

## LIBRARY

libzip (-lzip)

## SYNOPSIS

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

*const* *char* *\**\

**zip\_get\_name**(*zip\_t \*archive*, *zip\_uint64\_t index*, *zip\_flags\_t flags*);

## DESCRIPTION

The **zip\_get\_name**() function returns the name of the file at position *index* in *archive*. The name is in UTF-8 encoding unless ZIP\_FL\_ENC\_RAW was specified (see below).

If *flags* is set to ZIP\_FL\_UNCHANGED, the original unchanged filename is returned. The returned string must not be modified or freed, and becomes invalid when *archive* is closed.

Additionally, the following *flags* are supported:

- ZIP\_FL\_ENC\_RAW

  Return the unmodified names as it is in the ZIP archive.

- ZIP\_FL\_ENC\_GUESS

  (Default.) Guess the encoding of the name in the ZIP archive and convert it to UTF-8, if necessary. (Only CP-437 and UTF-8 are recognized.)

- ZIP\_FL\_ENC\_STRICT

  Follow the ZIP specification and expect CP-437 encoded names in the ZIP archive (except if they are explicitly marked as UTF-8). Convert it to UTF-8.

*Note*: ASCII is a subset of both CP-437 and UTF-8.

## RETURN VALUES

Upon successful completion, a pointer to the name is returned. Otherwise, NULL and the error code in *archive* is set to indicate the error.

## ERRORS

**zip\_get\_name**() fails if:

- \[ZIP\_ER\_DELETED\]

  *index* refers to a file that has been deleted (see [zip\_delete(3)](/zip_delete/3.md)).

- \[ZIP\_ER\_INVAL\]

  *index* is not a valid file index in *archive*, or *index* points to an added file and ZIP\_FL\_UNCHANGED is set.

- \[ZIP\_ER\_MEMORY\]

  Required memory could not be allocated.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_name\_locate(3)](/zip_name_locate/3.md)

## HISTORY

**zip\_get\_name**() 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*⟩
