1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<reference id="ref.zip">
<title>Zip File Functions (Read Only Access)</title>
<titleabbrev>Zip</titleabbrev>
<partintro>
<para>
This module uses the functions of the <ulink
url="&url.zziplib;">ZZIPlib</ulink> library by Guido Draheim to
transparently read ZIP compressed archives and the files inside
them.
</para>
<para>
Please note that ZZIPlib only provides a subset of functions
provided in a full implementation of the ZIP compression algorithm
and can only read ZIP file archives. A normal ZIP utility is
needed to create the ZIP file archives read by this library.
</para>
<para>
Zip support in PHP is not enabled by default. You will need to
use the <link
linkend="install.configure.with-zip">--with-zip</link>
configuration option when compiling PHP to enable zip
support. This module requires ZZIPlib version >= 0.10.6.
</para>
<note>
<para>
Zip support before PHP 4.1.0 is experimental. This section
reflects the Zip extension as it exists in PHP 4.1.0 and later.
</para>
</note>
<sect1 id="zip-example">
<title>Example Usage</title>
<para>
This example opens a ZIP file archive, reads each file in the
archive and prints out its contents. The
<filename>test2.zip</filename> archive used in this example is
one of the test archives in the ZZIPlib source distribution.
</para>
<example>
<title>Zip Usage Example</title>
<programlisting role="php">
<![CDATA[
<?php
$zip = zip_open("/tmp/test2.zip");
if ($zip) {
while ($zip_entry = zip_read($zip)) {
echo "Name: " . zip_entry_name($zip_entry) . "\n";
echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . "\n";
echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "\n";
echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "\n";
if (zip_entry_open($zip, $zip_entry, "r")) {
echo "File Contents:\n";
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
echo "$buf\n";
zip_entry_close($zip_entry);
}
echo "\n";
}
zip_close($zip);
}
?>
]]>
</programlisting>
</example>
</sect1>
</partintro>
<refentry id="function.zip-close">
<refnamediv>
<refname>zip_close</refname>
<refpurpose>Close a Zip File Archive</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>void</type><methodname>zip_close</methodname>
<methodparam><type>resource</type><parameter>zip</parameter></methodparam>
</methodsynopsis>
<para>
Closes a zip file archive. The parameter
<parameter>zip</parameter> must be a zip archive previously
opened by <function>zip_open</function>.
</para>
<para>
This function has no return value.
</para>
<para>
See also <function>zip_open</function> and
<function>zip_read</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.zip-entry-close">
<refnamediv>
<refname>zip_entry_close</refname>
<refpurpose>Close a Directory Entry</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>void</type><methodname>zip_entry_close</methodname>
<methodparam><type>resource</type><parameter>zip_entry</parameter></methodparam>
</methodsynopsis>
<para>
Closes a directory entry specified by
<parameter>zip_entry</parameter>. The parameter
<parameter>zip_entry</parameter> must be a valid directory entry
opened by <function>zip_entry_open</function>.
</para>
<para>
This function has no return value.
</para>
<para>
See also <function>zip_entry_open</function> and
<function>zip_entry_read</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.zip-entry-compressedsize">
<refnamediv>
<refname>zip_entry_compressedsize</refname>
<refpurpose>Retrieve the Compressed Size of a Directory Entry</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>zip_entry_compressedsize</methodname>
<methodparam><type>resource</type><parameter>zip_entry</parameter></methodparam>
</methodsynopsis>
<para>
Returns the compressed size of the directory entry specified by
<parameter>zip_entry</parameter>. The parameter
<parameter>zip_entry</parameter> is a valid directory entry
returned by <function>zip_read</function>.
</para>
<para>
See also <function>zip_open</function> and
<function>zip_read</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.zip-entry-compressionmethod">
<refnamediv>
<refname>zip_entry_compressionmethod</refname>
<refpurpose>
Retrieve the Compression Method of a Directory Entry
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>zip_entry_compressionmethod</methodname>
<methodparam><type>resource</type><parameter>zip_entry</parameter></methodparam>
</methodsynopsis>
<para>
Returns the compression method of the directory entry specified
by <parameter>zip_entry</parameter>. The parameter
<parameter>zip_entry</parameter> is a valid directory entry
returned by <function>zip_read</function>.
</para>
<para>
See also <function>zip_open</function> and
<function>zip_read</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.zip-entry-filesize">
<refnamediv>
<refname>zip_entry_filesize</refname>
<refpurpose>
Retrieve the Actual File Size of a Directory Entry
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>zip_entry_filesize</methodname>
<methodparam><type>resource</type><parameter>zip_entry</parameter></methodparam>
</methodsynopsis>
<para>
Returns the actual size of the directory entry specified by
<parameter>zip_entry</parameter>. The parameter
<parameter>zip_entry</parameter> is a valid directory entry
returned by <function>zip_read</function>.
</para>
<para>
See also <function>zip_open</function> and
<function>zip_read</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.zip-entry-name">
<refnamediv>
<refname>zip_entry_name</refname>
<refpurpose>Retrieve the Name of a Directory Entry</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>zip_entry_name</methodname>
<methodparam><type>resource</type><parameter>zip_entry</parameter></methodparam>
</methodsynopsis>
<para>
Returns the name of the directory entry specified by
<parameter>zip_entry</parameter>. The parameter
<parameter>zip_entry</parameter> is a valid directory entry
returned by <function>zip_read</function>.
</para>
<para>
See also <function>zip_open</function> and
<function>zip_read</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.zip-entry-open">
<refnamediv>
<refname>zip_entry_open</refname>
<refpurpose>Open a Directory Entry for Reading</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>zip_entry_open</methodname>
<methodparam><type>resource</type><parameter>zip</parameter></methodparam>
<methodparam><type>resource</type><parameter>zip_entry</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>mode</parameter></methodparam>
</methodsynopsis>
<para>
Opens a directory entry in a zip file for reading. The parameter
<parameter>zip</parameter> is a valid resource handle returned by
<function>zip_open</function>. The parameter
<parameter>zip_entry</parameter> is a directory entry resource
returned by <function>zip_read</function>. The optional
parameter <parameter>mode</parameter> can be any of the modes
specified in the documentaion for <function>fopen</function>.
</para>
<note>
<para>
Currently, <parameter>mode</parameter> is ignored and is always
<literal>"rb"</literal>. This is due to the fact that zip
support in PHP is read only access. Please see
<function>fopen</function> for an explanation of various modes,
including <literal>"rb"</literal>.
</para>
</note>
<para>
Returns &true; on succes or &false; on failure.
</para>
<note>
<para>
Unlike <function>fopen</function> and other similar functions,
the return value of <function>zip_entry_open</function> only
indicates the result of the operation and is not needed for
reading or closing the directory entry.
</para>
</note>
<para>
See also <function>zip_entry_read</function> and
<function>zip_entry_close</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.zip-entry-read">
<refnamediv>
<refname>zip_entry_read</refname>
<refpurpose>Read From an Open Directory Entry</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>zip_entry_read</methodname>
<methodparam><type>resource</type><parameter>zip_entry</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
</methodsynopsis>
<para>
Reads up to <parameter>length</parameter> bytes from an open
directory entry. If <parameter>length</parameter> is not
specified, then <function>zip_entry_read</function> will attempt
to read 1024 bytes. The parameter
<parameter>zip_entry</parameter> is a valid directory entry
returned by <function>zip_read</function>.
</para>
<note>
<para>
The <parameter>length</parameter> parameter should be the
uncompressed length you wish to read.
</para>
</note>
<para>
Returns the data read, or &false; if the end of the file is
reached.
</para>
<para>
See also <function>zip_entry_open</function>,
<function>zip_entry_close</function> and
<function>zip_entry_filesize</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.zip-open">
<refnamediv>
<refname>zip_open</refname>
<refpurpose>Open a Zip File Archive</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>zip_open</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
Opens a new zip archive for reading. The
<parameter>filename</parameter> parameter is the filename of the
zip archive to open.
</para>
<para>
Returns a resource handle for later use with
<function>zip_read</function> and <function>zip_close</function>
or returns &false; if <parameter>filename</parameter> does not
exist.
</para>
<para>
See also <function>zip_read</function> and
<function>zip_close</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.zip-read">
<refnamediv>
<refname>zip_read</refname>
<refpurpose>Read Next Entry in a Zip File Archive</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>zip_read</methodname>
<methodparam><type>resource</type><parameter>zip</parameter></methodparam>
</methodsynopsis>
<para>
Reads the next entry in a zip file archive. The parameter
<parameter>zip</parameter> must be a zip archive previously
opened by <function>zip_open</function>.
</para>
<para>
Returns a directory entry resource for later use with the
<function>zip_entry_...</function> functions.
</para>
<para>
See also <function>zip_open</function>,
<function>zip_close</function>,
<function>zip_entry_open</function>, and
<function>zip_entry_read</function>.
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
|