3 <!-- This is an automatically generated file. Do not edit.
4 zip_name_locate.mdoc -- get index of file by name
5 Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner
7 This file is part of libzip, a library to manipulate ZIP archives.
8 The authors can be contacted at <libzip@nih.at>
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions
13 1. Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15 2. Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in
17 the documentation and/or other materials provided with the
19 3. The names of the authors may not be used to endorse or promote
20 products derived from this software without specific prior
23 THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
24 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 <meta charset="utf-8"/>
37 <link rel="stylesheet" href="../nih-man.css" type="text/css" media="all"/>
38 <title>ZIP_NAME_LOCATE(3)</title>
43 <td class="head-ltitle">ZIP_NAME_LOCATE(3)</td>
44 <td class="head-vol">Library Functions Manual</td>
45 <td class="head-rtitle">ZIP_NAME_LOCATE(3)</td>
48 <div class="manual-text">
50 <h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
51 <code class="Nm">zip_name_locate</code> —
52 <div class="Nd">get index of file by name</div>
55 <h1 class="Sh" id="LIBRARY"><a class="permalink" href="#LIBRARY">LIBRARY</a></h1>
59 <h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
60 <code class="In">#include <<a class="In">zip.h</a>></code>
61 <p class="Pp"><var class="Ft">zip_int64_t</var>
63 <code class="Fn">zip_name_locate</code>(<var class="Fa" style="white-space: nowrap;">zip_t
64 *archive</var>, <var class="Fa" style="white-space: nowrap;">const char
65 *fname</var>, <var class="Fa" style="white-space: nowrap;">zip_flags_t
69 <h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
70 The <code class="Fn">zip_name_locate</code>() function returns the index of the
71 file named <var class="Ar">fname</var> in <var class="Ar">archive</var>. If
72 <var class="Ar">archive</var> does not contain a file with that name, -1 is
74 <p class="Pp">If neither <code class="Dv">ZIP_FL_ENC_RAW</code> nor
75 <code class="Dv">ZIP_FL_ENC_STRICT</code> are specified, guess the encoding
76 of the name in the ZIP archive and convert it to UTF-8, if necessary, before
78 <p class="Pp">If neither <code class="Dv">ZIP_FL_ENC_CP437</code> nor
79 <code class="Dv">ZIP_FL_ENC_UTF_8</code> are specified, guess the encoding
80 of <var class="Ar">fname</var>.</p>
81 <p class="Pp">Only CP-437 and UTF-8 are recognized.</p>
82 <p class="Pp">The <var class="Fa">flags</var> are specified by
83 <i class="Em">or</i><span class="No">'ing</span> the following values, or 0
85 <div class="Bd-indent">
87 <dt><a class="permalink" href="#ZIP_FL_NOCASE"><code class="Dv" id="ZIP_FL_NOCASE">ZIP_FL_NOCASE</code></a></dt>
88 <dd>Ignore case distinctions. (Will only work well if the file names are
89 ASCII.) With this flag, <code class="Fn">zip_name_locate</code>() will be
90 slow for archives with many files.</dd>
91 <dt><a class="permalink" href="#ZIP_FL_NODIR"><code class="Dv" id="ZIP_FL_NODIR">ZIP_FL_NODIR</code></a></dt>
92 <dd>Ignore directory part of file name in archive. With this flag,
93 <code class="Fn">zip_name_locate</code>() will be slow for archives with
95 <dt><a class="permalink" href="#ZIP_FL_ENC_GUESS"><code class="Dv" id="ZIP_FL_ENC_GUESS">ZIP_FL_ENC_GUESS</code></a></dt>
96 <dd>This flag has no effect (its value is 0); it can be used to explicitly
97 denote the absence of encoding flags.</dd>
98 <dt><a class="permalink" href="#ZIP_FL_ENC_RAW"><code class="Dv" id="ZIP_FL_ENC_RAW">ZIP_FL_ENC_RAW</code></a></dt>
99 <dd>Compare <var class="Ar">fname</var> against the unmodified names as they
100 are in the ZIP archive, without converting them to UTF-8.</dd>
101 <dt><a class="permalink" href="#ZIP_FL_ENC_STRICT"><code class="Dv" id="ZIP_FL_ENC_STRICT">ZIP_FL_ENC_STRICT</code></a></dt>
102 <dd>Follow the ZIP specification and expect CP-437 encoded names in the ZIP
103 archive (except if they are explicitly marked as UTF-8). Convert them to
104 UTF-8 before comparing.</dd>
105 <dt><a class="permalink" href="#ZIP_FL_ENC_CP437"><code class="Dv" id="ZIP_FL_ENC_CP437">ZIP_FL_ENC_CP437</code></a></dt>
106 <dd><var class="Ar">fname</var> is encoded as CP-437.</dd>
107 <dt><a class="permalink" href="#ZIP_FL_ENC_UTF_8"><code class="Dv" id="ZIP_FL_ENC_UTF_8">ZIP_FL_ENC_UTF_8</code></a></dt>
108 <dd><var class="Ar">fname</var> is encoded as UTF-8.</dd>
111 <p class="Pp"><i class="Em">Note</i>: ASCII is a subset of both CP-437 and
115 <h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN
117 <code class="Fn">zip_name_locate</code>() returns the index of the file named
118 <var class="Ar">fname</var> or -1, if <var class="Ar">archive</var> does not
119 contain an entry of that name.
122 <h1 class="Sh" id="ERRORS"><a class="permalink" href="#ERRORS">ERRORS</a></h1>
123 <code class="Fn">zip_name_locate</code>() fails if:
125 <dt>[<a class="permalink" href="#ZIP_ER_INVAL"><code class="Er" id="ZIP_ER_INVAL">ZIP_ER_INVAL</code></a>]</dt>
126 <dd>One of the arguments is invalid.</dd>
127 <dt>[<a class="permalink" href="#ZIP_ER_MEMORY"><code class="Er" id="ZIP_ER_MEMORY">ZIP_ER_MEMORY</code></a>]</dt>
128 <dd>Required memory could not be allocated.</dd>
129 <dt>[<a class="permalink" href="#ZIP_ER_NOENT"><code class="Er" id="ZIP_ER_NOENT">ZIP_ER_NOENT</code></a>]</dt>
130 <dd>No entry of the name <var class="Ar">fname</var> is found in the
135 <h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
137 <a class="Xr" href="libzip.html">libzip(3)</a>,
138 <a class="Xr" href="zip_get_name.html">zip_get_name(3)</a>
141 <h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
142 <code class="Fn">zip_name_locate</code>() was added in libzip 0.6. In libzip
143 0.11 the return type was changed from <var class="Vt">int</var> to
144 <var class="Vt">zip_int64_t</var>. In libzip 0.11 the type of
145 <var class="Ar">flags</var> was changed from <var class="Vt">int</var> to
146 <var class="Vt">zip_flags_t</var>.
149 <h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
150 <span class="An">Dieter Baron</span>
151 <<a class="Mt" href="mailto:dillo@nih.at">dillo@nih.at</a>> and
152 <span class="An">Thomas Klausner</span>
153 <<a class="Mt" href="mailto:tk@giga.or.at">tk@giga.or.at</a>>
158 <td class="foot-date">March 15, 2022</td>
159 <td class="foot-os">NiH</td>