blob: 8843c83638ed89caa36eedbc72d334cdf359975a [file]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style>
table.head, table.foot { width: 100%; }
td.head-rtitle, td.foot-os { text-align: right; }
td.head-vol { text-align: center; }
div.Pp { margin: 1ex 0ex; }
</style>
<link rel="stylesheet" href="../nih-man.css" type="text/css" media="all"/>
<title>ZIP_FILE_GET_EXTERNAL_ATTRIBUTES(3)</title>
</head>
<body>
<table class="head">
<tr>
<td class="head-ltitle">ZIP_FILE_GET_EXTERNAL_ATTRIBUTES(3)</td>
<td class="head-vol">Library Functions Manual</td>
<td class="head-rtitle">ZIP_FILE_GET_EXTERNAL_ATTRIBUTES(3)</td>
</tr>
</table>
<div class="manual-text">
<h1 class="Sh" id="NAME">NAME</h1>
<b class="Nm">zip_file_get_external_attributes</b> &#8212; <span class="Nd">get
external attributes for file in zip</span>
<h1 class="Sh" id="LIBRARY">LIBRARY</h1>
libzip (-lzip)
<h1 class="Sh" id="SYNOPSIS">SYNOPSIS</h1>
<b class="In">#include &lt;<a class="In">zip.h</a>&gt;</b>
<div class="Pp"></div>
<var class="Ft">int</var>
<br/>
<b class="Fn">zip_file_get_external_attributes</b>(<var class="Fa" style="white-space: nowrap;">zip_t
*archive</var>, <var class="Fa" style="white-space: nowrap;">zip_uint64_t
index</var>, <var class="Fa" style="white-space: nowrap;">zip_flags_t
flags</var>, <var class="Fa" style="white-space: nowrap;">zip_uint8_t
*opsys</var>, <var class="Fa" style="white-space: nowrap;">zip_uint32_t
*attributes</var>);
<h1 class="Sh" id="DESCRIPTION">DESCRIPTION</h1>
The <b class="Fn">zip_file_get_external_attributes</b>() function returns the
operating system and external attributes for the file at position
<var class="Ar">index</var> in the zip archive. The external attributes
usually contain the operating system-specific file permissions. If
<var class="Ar">flags</var> is set to
<code class="Dv">ZIP_FL_UNCHANGED</code>, the original unchanged values are
returned. If <var class="Ar">opsys</var> or <var class="Ar">attributes</var>
are <code class="Dv">NULL</code>, they are not filled in.
<div class="Pp"></div>
The following operating systems are defined by the zip specification:
<ul class="Bl-item" style="margin-left: 6.00ex;">
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_ACORN_RISC</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_ALTERNATE_MVS</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_AMIGA</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_ATARI_ST</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_BEOS</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_CPM</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_DOS</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_MACINTOSH</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_MVS</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_OPENVMS</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_OS_2</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_OS_400</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_OS_X</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_TANDEM</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_UNIX</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_VFAT</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_VM_CMS</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_VSE</code></li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_WINDOWS_NTFS</code>
(uncommon, use <code class="Dv">ZIP_OPSYS_DOS</code> instead)</li>
<li class="It-item" style="margin-top: 0.00em;"><code class="Dv">ZIP_OPSYS_Z_SYSTEM</code></li>
</ul>
<div class="Pp"></div>
The defines above follow the PKWARE Inc. Appnote; please note that the InfoZIP
Appnote has a slightly different mapping.
<h1 class="Sh" id="RETURN_VALUES">RETURN VALUES</h1>
Upon successful completion, 0 is returned. In case of an error,
<code class="Dv">-1</code> is returned and the error code in
<var class="Ar">archive</var> is set to indicate the error.
<h1 class="Sh" id="EXAMPLES">EXAMPLES</h1>
The following code can be used to expand <var class="Ar">attributes</var> if the
operating system is <code class="Dv">ZIP_OPSYS_DOS</code>.
<div class="Pp"></div>
<div class="Bd" style="margin-left: 0.00ex;">
<pre class="Li">
#include &lt;sys/stat.h&gt;
#define FA_RDONLY 0x01 // FILE_ATTRIBUTE_READONLY
#define FA_DIREC 0x10 // FILE_ATTRIBUTE_DIRECTORY
static mode_t
_zip_dos_attr2mode(zip_uint32_t attr)
{
mode_t m = S_IRUSR | S_IRGRP | S_IROTH;
if (0 == (attr &amp; FA_RDONLY))
m |= S_IWUSR | S_IWGRP | S_IWOTH;
if (attr &amp; FA_DIREC)
m = (S_IFDIR | (m &amp; ~S_IFMT)) | S_IXUSR | S_IXGRP | S_IXOTH;
return m;
}
</pre>
</div>
<h1 class="Sh" id="ERRORS">ERRORS</h1>
<b class="Fn">zip_file_get_external_attributes</b>() fails if:
<dl class="Bl-tag" style="margin-left: 17.00ex;">
<dt class="It-tag" style="margin-left: -17.00ex;">&#160;</dt>
<dd class="It-tag">&#160;</dd>
<dt class="It-tag" style="margin-left: -17.00ex;">[<code class="Er">ZIP_ER_INVAL</code>]</dt>
<dd class="It-tag"><var class="Ar">index</var> is not a valid file index in
<var class="Ar">archive</var>.</dd>
</dl>
<h1 class="Sh" id="SEE_ALSO">SEE ALSO</h1>
<a class="Xr" href="libzip.html">libzip(3)</a>,
<a class="Xr" href="zip_file_set_external_attributes.html">zip_file_set_external_attributes(3)</a>
<h1 class="Sh" id="HISTORY">HISTORY</h1>
<b class="Fn">zip_file_get_external_attributes</b>() was added in libzip 0.11.2.
<h1 class="Sh" id="AUTHORS">AUTHORS</h1>
<span class="An">Dieter Baron</span>
&lt;<a class="Mt" href="mailto:dillo@nih.at">dillo@nih.at</a>&gt; and
<span class="An">Thomas Klausner</span>
&lt;<a class="Mt" href="mailto:tk@giga.or.at">tk@giga.or.at</a>&gt;</div>
<table class="foot">
<tr>
<td class="foot-date">December 18, 2017</td>
<td class="foot-os">NetBSD 8.99.14</td>
</tr>
</table>
</body>
</html>