---
name: "zip_name_locate"
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_name_locate"
---

# zip\_name\_locate(3)

get index of file by name

## NAME

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

## LIBRARY

libzip (-lzip)

## SYNOPSIS

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

*zip\_int64\_t*\

**zip\_name\_locate**(*zip\_t \*archive*, *const char \*fname*, *zip\_flags\_t flags*);

## DESCRIPTION

The **zip\_name\_locate**() function returns the index of the file named *fname* in *archive*. If *archive* does not contain a file with that name, -1 is returned.

If neither ZIP\_FL\_ENC\_RAW nor ZIP\_FL\_ENC\_STRICT are specified, guess the encoding of the name in the ZIP archive and convert it to UTF-8, if necessary, before comparing.

If neither ZIP\_FL\_ENC\_CP437 nor ZIP\_FL\_ENC\_UTF\_8 are specified, guess the encoding of *fname*.

Only CP-437 and UTF-8 are recognized.

The *flags* are specified by *or*'ing the following values, or 0 for none of them.

- ZIP\_FL\_NOCASE

  Ignore case distinctions. (Will only work well if the file names are ASCII.) With this flag, **zip\_name\_locate**() will be slow for archives with many files.

- ZIP\_FL\_NODIR

  Ignore directory part of file name in archive. With this flag, **zip\_name\_locate**() will be slow for archives with many files.

- ZIP\_FL\_ENC\_GUESS

  This flag has no effect (its value is 0); it can be used to explicitly denote the absence of encoding flags.

- ZIP\_FL\_ENC\_RAW

  Compare *fname* against the unmodified names as they are in the ZIP archive, without converting them to UTF-8.

- 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 them to UTF-8 before comparing.

- ZIP\_FL\_ENC\_CP437

  *fname* is encoded as CP-437.

- ZIP\_FL\_ENC\_UTF\_8

  *fname* is encoded as UTF-8.

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

## RETURN VALUES

**zip\_name\_locate**() returns the index of the file named *fname* or -1, if *archive* does not contain an entry of that name.

## ERRORS

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

- \[ZIP\_ER\_INVAL\]

  One of the arguments is invalid.

- \[ZIP\_ER\_MEMORY\]

  Required memory could not be allocated.

- \[ZIP\_ER\_NOENT\]

  No entry of the name *fname* is found in the archive.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_get\_name(3)](/zip_get_name/3.md)

## HISTORY

**zip\_name\_locate**() was added in libzip 0.6. In libzip 0.11 the return type was changed from *int* to *zip\_int64\_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*⟩
