1ZIP_NAME_LOCATE(3)       BSD Library Functions Manual       ZIP_NAME_LOCATE(3)
2

NAME

4     zip_name_locate — get index of file by name
5

LIBRARY

7     libzip (-lzip)
8

SYNOPSIS

10     #include <zip.h>
11
12     zip_int64_t
13     zip_name_locate(zip_t *archive, const char *fname, zip_flags_t flags);
14

DESCRIPTION

16     The zip_name_locate() function returns the index of the file named fname
17     in archive.  If archive does not contain a file with that name, -1 is re‐
18     turned.
19
20     If neither ZIP_FL_ENC_RAW nor ZIP_FL_ENC_STRICT are specified, guess the
21     encoding of the name in the ZIP archive and convert it to UTF-8, if nec‐
22     essary, before comparing.
23
24     If neither ZIP_FL_ENC_CP437 nor ZIP_FL_ENC_UTF_8 are specified, guess the
25     encoding of fname.
26
27     Only CP-437 and UTF-8 are recognized.
28
29     The flags are specified by or'ing the following values, or 0 for none of
30     them.
31
32           ZIP_FL_NOCASE      Ignore case distinctions.  (Will only work well
33                              if the file names are ASCII.)  With this flag,
34                              zip_name_locate() will be slow for archives with
35                              many files.
36
37           ZIP_FL_NODIR       Ignore directory part of file name in archive.
38                              With this flag, zip_name_locate() will be slow
39                              for archives with many files.
40
41           ZIP_FL_ENC_GUESS   This flag has no effect (its value is 0); it can
42                              be used to explicitly denote the absence of en‐
43                              coding flags.
44
45           ZIP_FL_ENC_RAW     Compare fname against the unmodified names as
46                              they are in the ZIP archive, without converting
47                              them to UTF-8.
48
49           ZIP_FL_ENC_STRICT  Follow the ZIP specification and expect CP-437
50                              encoded names in the ZIP archive (except if they
51                              are explicitly marked as UTF-8).  Convert them
52                              to UTF-8 before comparing.
53
54           ZIP_FL_ENC_CP437   fname is encoded as CP-437.
55
56           ZIP_FL_ENC_UTF_8   fname is encoded as UTF-8.
57
58     Note: ASCII is a subset of both CP-437 and UTF-8.
59

RETURN VALUES

61     zip_name_locate() returns the index of the file named fname or -1, if
62     archive does not contain an entry of that name.
63

ERRORS

65     zip_name_locate() fails if:
66
67     [ZIP_ER_INVAL]     One of the arguments is invalid.
68
69     [ZIP_ER_MEMORY]    Required memory could not be allocated.
70
71     [ZIP_ER_NOENT]     No entry of the name fname is found in the archive.
72

SEE ALSO

74     libzip(3), zip_get_name(3)
75

HISTORY

77     zip_name_locate() was added in libzip 0.6.  In libzip 0.11 the return
78     type was changed from int to zip_int64_t.  In libzip 0.11 the type of
79     flags was changed from int to zip_flags_t.
80

AUTHORS

82     Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at>
83
84BSD                             March 15, 2022                             BSD
Impressum