mirror of
https://github.com/splitbrain/php-archive.git
synced 2025-07-10 17:36:27 +02:00
721 lines
17 KiB
HTML
721 lines
17 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
|
|
<title>Class splitbrain\PHPArchive\Archive</title>
|
|
|
|
<link rel="stylesheet" href="resources/style.css?c2f33731c1948fbed7c333554678bfa68d4817da">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<div id="left">
|
|
<div id="menu">
|
|
<a href="index.html" title="Overview"><span>Overview</span></a>
|
|
|
|
|
|
<div id="groups">
|
|
<h3>Namespaces</h3>
|
|
<ul>
|
|
<li class="active">
|
|
<a href="namespace-splitbrain.html">
|
|
splitbrain<span></span>
|
|
</a>
|
|
|
|
<ul>
|
|
<li class="active">
|
|
<a href="namespace-splitbrain.PHPArchive.html">
|
|
PHPArchive </a>
|
|
|
|
</li>
|
|
</ul></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
|
|
<div id="elements">
|
|
<h3>Classes</h3>
|
|
<ul>
|
|
<li class="active"><a href="class-splitbrain.PHPArchive.Archive.html">Archive</a></li>
|
|
<li><a href="class-splitbrain.PHPArchive.FileInfo.html">FileInfo</a></li>
|
|
<li><a href="class-splitbrain.PHPArchive.Tar.html">Tar</a></li>
|
|
<li><a href="class-splitbrain.PHPArchive.Zip.html">Zip</a></li>
|
|
</ul>
|
|
|
|
|
|
|
|
<h3>Exceptions</h3>
|
|
<ul>
|
|
<li><a href="class-splitbrain.PHPArchive.ArchiveCorruptedException.html">ArchiveCorruptedException</a></li>
|
|
<li><a href="class-splitbrain.PHPArchive.ArchiveIllegalCompressionException.html">ArchiveIllegalCompressionException</a></li>
|
|
<li><a href="class-splitbrain.PHPArchive.ArchiveIOException.html">ArchiveIOException</a></li>
|
|
<li><a href="class-splitbrain.PHPArchive.FileInfoException.html">FileInfoException</a></li>
|
|
</ul>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="splitter"></div>
|
|
|
|
<div id="right">
|
|
<div id="rightInner">
|
|
<form id="search">
|
|
<input type="hidden" name="cx" value="">
|
|
<input type="hidden" name="ie" value="UTF-8">
|
|
<input type="text" name="q" class="text" placeholder="Search">
|
|
</form>
|
|
|
|
<div id="navigation">
|
|
<ul>
|
|
<li>
|
|
<a href="index.html" title="Overview"><span>Overview</span></a>
|
|
</li>
|
|
<li>
|
|
<a href="namespace-splitbrain.PHPArchive.html" title="Summary of splitbrain\PHPArchive"><span>Namespace</span></a>
|
|
</li>
|
|
<li class="active">
|
|
<span>Class</span> </li>
|
|
</ul>
|
|
<ul>
|
|
</ul>
|
|
<ul>
|
|
</ul>
|
|
</div>
|
|
|
|
<div id="content" class="class">
|
|
<h1>Class Archive</h1>
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
|
<h4>Direct known subclasses</h4>
|
|
<a href="class-splitbrain.PHPArchive.Tar.html">splitbrain\PHPArchive\Tar</a>,
|
|
<a href="class-splitbrain.PHPArchive.Zip.html">splitbrain\PHPArchive\Zip</a>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="info">
|
|
<b>Abstract</b><br>
|
|
|
|
<b>Namespace:</b> <a href="namespace-splitbrain.html">splitbrain</a>\<a href="namespace-splitbrain.PHPArchive.html">PHPArchive</a><br>
|
|
|
|
|
|
<b>Located at</b> <a href="source-class-splitbrain.PHPArchive.Archive.html#5-135" title="Go to source code">Archive.php</a>
|
|
<br>
|
|
</div>
|
|
|
|
|
|
|
|
<table class="summary methods" id="methods">
|
|
<caption>Methods summary</caption>
|
|
<tr data-order="setCompression" id="_setCompression">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_setCompression">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#16-23" title="Go to source code">setCompression</a>( <span>integer <var>$level</var> = <span class="php-num">9</span></span>, <span>integer <var>$type</var> = Archive::COMPRESS_AUTO</span> )</code>
|
|
|
|
<div class="description short">
|
|
<p>Set the compression level and type</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Set the compression level and type</p>
|
|
|
|
|
|
<h4>Parameters</h4>
|
|
<div class="list"><dl>
|
|
<dt><var>$level</var></dt>
|
|
<dd>Compression level (0 to 9)</dd>
|
|
<dt><var>$type</var></dt>
|
|
<dd>Type of compression to use (use COMPRESS_* constants)</dd>
|
|
</dl></div>
|
|
|
|
|
|
<h4>Throws</h4>
|
|
<div class="list">
|
|
<code><a href="class-splitbrain.PHPArchive.ArchiveIllegalCompressionException.html">splitbrain\PHPArchive\ArchiveIllegalCompressionException</a></code>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="open" id="_open">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_open">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#25-31" title="Go to source code">open</a>( <span>string <var>$file</var></span> )</code>
|
|
|
|
<div class="description short">
|
|
<p>Open an existing archive file for reading</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Open an existing archive file for reading</p>
|
|
|
|
|
|
<h4>Parameters</h4>
|
|
<div class="list"><dl>
|
|
<dt><var>$file</var></dt>
|
|
<dd></dd>
|
|
</dl></div>
|
|
|
|
|
|
<h4>Throws</h4>
|
|
<div class="list">
|
|
<code><a href="class-splitbrain.PHPArchive.ArchiveIOException.html">splitbrain\PHPArchive\ArchiveIOException</a></code>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="contents" id="_contents">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
<code><a href="class-splitbrain.PHPArchive.FileInfo.html">splitbrain\PHPArchive\FileInfo</a>[]</code>
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_contents">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#33-43" title="Go to source code">contents</a>( )</code>
|
|
|
|
<div class="description short">
|
|
<p>Read the contents of an archive</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Read the contents of an archive</p>
|
|
|
|
<p>This function lists the files stored in the archive, and returns an indexed array of FileInfo objects</p>
|
|
|
|
<p>The archive is closed afer reading the contents, because rewinding is not possible in bzip2 streams.
|
|
Reopen the file with open() again if you want to do additional operations</p>
|
|
|
|
|
|
|
|
<h4>Returns</h4>
|
|
<div class="list">
|
|
<code><a href="class-splitbrain.PHPArchive.FileInfo.html">splitbrain\PHPArchive\FileInfo</a>[]</code>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="extract" id="_extract">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
array
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_extract">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#45-69" title="Go to source code">extract</a>( <span>string <var>$outdir</var></span>, <span>integer|string <var>$strip</var> = <span class="php-quote">''</span></span>, <span>string <var>$exclude</var> = <span class="php-quote">''</span></span>, <span>string <var>$include</var> = <span class="php-quote">''</span></span> )</code>
|
|
|
|
<div class="description short">
|
|
<p>Extract an existing archive</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Extract an existing archive</p>
|
|
|
|
<p>The $strip parameter allows you to strip a certain number of path components from the filenames
|
|
found in the archive file, similar to the --strip-components feature of GNU tar. This is triggered when
|
|
an integer is passed as $strip.
|
|
Alternatively a fixed string prefix may be passed in $strip. If the filename matches this prefix,
|
|
the prefix will be stripped. It is recommended to give prefixes with a trailing slash.</p>
|
|
|
|
<p>By default this will extract all files found in the archive. You can restrict the output using the $include
|
|
and $exclude parameter. Both expect a full regular expression (including delimiters and modifiers). If
|
|
$include is set, only files that match this expression will be extracted. Files that match the $exclude
|
|
expression will never be extracted. Both parameters can be used in combination. Expressions are matched against
|
|
stripped filenames as described above.</p>
|
|
|
|
<p>The archive is closed afterwards. Reopen the file with open() again if you want to do additional operations</p>
|
|
|
|
|
|
<h4>Parameters</h4>
|
|
<div class="list"><dl>
|
|
<dt><var>$outdir</var></dt>
|
|
<dd>the target directory for extracting</dd>
|
|
<dt><var>$strip</var></dt>
|
|
<dd>either the number of path components or a fixed prefix to strip</dd>
|
|
<dt><var>$exclude</var></dt>
|
|
<dd>a regular expression of files to exclude</dd>
|
|
<dt><var>$include</var></dt>
|
|
<dd>a regular expression of files to include</dd>
|
|
</dl></div>
|
|
|
|
<h4>Returns</h4>
|
|
<div class="list">
|
|
array
|
|
</div>
|
|
|
|
<h4>Throws</h4>
|
|
<div class="list">
|
|
<code><a href="class-splitbrain.PHPArchive.ArchiveIOException.html">splitbrain\PHPArchive\ArchiveIOException</a></code>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="create" id="_create">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_create">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#71-78" title="Go to source code">create</a>( <span>string <var>$file</var> = <span class="php-quote">''</span></span> )</code>
|
|
|
|
<div class="description short">
|
|
<p>Create a new archive file</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Create a new archive file</p>
|
|
|
|
<p>If $file is empty, the archive file will be created in memory</p>
|
|
|
|
|
|
<h4>Parameters</h4>
|
|
<div class="list"><dl>
|
|
<dt><var>$file</var></dt>
|
|
<dd></dd>
|
|
</dl></div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="addFile" id="_addFile">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_addFile">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#80-87" title="Go to source code">addFile</a>( <span>string <var>$file</var></span>, <span>string|<code><a href="class-splitbrain.PHPArchive.FileInfo.html">splitbrain\PHPArchive\FileInfo</a></code> <var>$fileinfo</var> = <span class="php-quote">''</span></span> )</code>
|
|
|
|
<div class="description short">
|
|
<p>Add a file to the current archive using an existing file in the filesystem</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Add a file to the current archive using an existing file in the filesystem</p>
|
|
|
|
|
|
<h4>Parameters</h4>
|
|
<div class="list"><dl>
|
|
<dt><var>$file</var></dt>
|
|
<dd>path to the original file</dd>
|
|
<dt><var>$fileinfo</var></dt>
|
|
<dd>either the name to us in archive (string) or a FileInfo oject with all meta data, empty to take from original</dd>
|
|
</dl></div>
|
|
|
|
|
|
<h4>Throws</h4>
|
|
<div class="list">
|
|
<code><a href="class-splitbrain.PHPArchive.ArchiveIOException.html">splitbrain\PHPArchive\ArchiveIOException</a></code>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="addData" id="_addData">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_addData">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#89-96" title="Go to source code">addData</a>( <span>string|<code><a href="class-splitbrain.PHPArchive.FileInfo.html">splitbrain\PHPArchive\FileInfo</a></code> <var>$fileinfo</var></span>, <span>string <var>$data</var></span> )</code>
|
|
|
|
<div class="description short">
|
|
<p>Add a file to the current archive using the given $data as content</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Add a file to the current archive using the given $data as content</p>
|
|
|
|
|
|
<h4>Parameters</h4>
|
|
<div class="list"><dl>
|
|
<dt><var>$fileinfo</var></dt>
|
|
<dd>either the name to us in archive (string) or a FileInfo oject with all meta data</dd>
|
|
<dt><var>$data</var></dt>
|
|
<dd>binary content of the file to add</dd>
|
|
</dl></div>
|
|
|
|
|
|
<h4>Throws</h4>
|
|
<div class="list">
|
|
<code><a href="class-splitbrain.PHPArchive.ArchiveIOException.html">splitbrain\PHPArchive\ArchiveIOException</a></code>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="close" id="_close">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_close">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#98-104" title="Go to source code">close</a>( )</code>
|
|
|
|
<div class="description short">
|
|
<p>Close the archive, close all file handles</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Close the archive, close all file handles</p>
|
|
|
|
<p>After a call to this function no more data can be added to the archive, for
|
|
read access no reading is allowed anymore</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="getArchive" id="_getArchive">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_getArchive">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#106-111" title="Go to source code">getArchive</a>( )</code>
|
|
|
|
<div class="description short">
|
|
<p>Returns the created in-memory archive data</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Returns the created in-memory archive data</p>
|
|
|
|
<p>This implicitly calls close() on the Archive</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="save" id="_save">
|
|
|
|
<td class="attributes"><code>
|
|
abstract public
|
|
|
|
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_save">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#113-121" title="Go to source code">save</a>( <span>string <var>$file</var></span> )</code>
|
|
|
|
<div class="description short">
|
|
<p>Save the created in-memory archive data</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Save the created in-memory archive data</p>
|
|
|
|
<p>Note: It is more memory effective to specify the filename in the create() function and
|
|
let the library work on the new file directly.</p>
|
|
|
|
|
|
<h4>Parameters</h4>
|
|
<div class="list"><dl>
|
|
<dt><var>$file</var></dt>
|
|
<dd></dd>
|
|
</dl></div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
<tr data-order="setCallback" id="_setCallback">
|
|
|
|
<td class="attributes"><code>
|
|
public
|
|
|
|
|
|
|
|
</code>
|
|
</td>
|
|
|
|
<td class="name"><div>
|
|
<a class="anchor" href="#_setCallback">#</a>
|
|
<code><a href="source-class-splitbrain.PHPArchive.Archive.html#123-134" title="Go to source code">setCallback</a>( <span>callable <var>$callback</var></span> )</code>
|
|
|
|
<div class="description short">
|
|
<p>Set a callback function to be called whenever a file is added or extracted.</p>
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
<p>Set a callback function to be called whenever a file is added or extracted.</p>
|
|
|
|
<p>The callback is called with a FileInfo object as parameter. You can use this to show progress
|
|
info during an operation.</p>
|
|
|
|
|
|
<h4>Parameters</h4>
|
|
<div class="list"><dl>
|
|
<dt><var>$callback</var></dt>
|
|
<dd></dd>
|
|
</dl></div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div></td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<table class="summary constants" id="constants">
|
|
<caption>Constants summary</caption>
|
|
<tr data-order="COMPRESS_AUTO" id="COMPRESS_AUTO">
|
|
|
|
<td class="attributes"><code>integer</code></td>
|
|
<td class="name">
|
|
<code>
|
|
<a href="source-class-splitbrain.PHPArchive.Archive.html#8" title="Go to source code"><b>COMPRESS_AUTO</b></a>
|
|
</code>
|
|
|
|
<div class="description short">
|
|
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
|
|
|
|
</div>
|
|
</td>
|
|
<td class="value">
|
|
<div>
|
|
<a href="#COMPRESS_AUTO" class="anchor">#</a>
|
|
<code>-<span class="php-num">1</span></code>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr data-order="COMPRESS_NONE" id="COMPRESS_NONE">
|
|
|
|
<td class="attributes"><code>integer</code></td>
|
|
<td class="name">
|
|
<code>
|
|
<a href="source-class-splitbrain.PHPArchive.Archive.html#9" title="Go to source code"><b>COMPRESS_NONE</b></a>
|
|
</code>
|
|
|
|
<div class="description short">
|
|
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
|
|
|
|
</div>
|
|
</td>
|
|
<td class="value">
|
|
<div>
|
|
<a href="#COMPRESS_NONE" class="anchor">#</a>
|
|
<code><span class="php-num">0</span></code>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr data-order="COMPRESS_GZIP" id="COMPRESS_GZIP">
|
|
|
|
<td class="attributes"><code>integer</code></td>
|
|
<td class="name">
|
|
<code>
|
|
<a href="source-class-splitbrain.PHPArchive.Archive.html#10" title="Go to source code"><b>COMPRESS_GZIP</b></a>
|
|
</code>
|
|
|
|
<div class="description short">
|
|
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
|
|
|
|
</div>
|
|
</td>
|
|
<td class="value">
|
|
<div>
|
|
<a href="#COMPRESS_GZIP" class="anchor">#</a>
|
|
<code><span class="php-num">1</span></code>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr data-order="COMPRESS_BZIP" id="COMPRESS_BZIP">
|
|
|
|
<td class="attributes"><code>integer</code></td>
|
|
<td class="name">
|
|
<code>
|
|
<a href="source-class-splitbrain.PHPArchive.Archive.html#11" title="Go to source code"><b>COMPRESS_BZIP</b></a>
|
|
</code>
|
|
|
|
<div class="description short">
|
|
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
|
|
|
|
</div>
|
|
</td>
|
|
<td class="value">
|
|
<div>
|
|
<a href="#COMPRESS_BZIP" class="anchor">#</a>
|
|
<code><span class="php-num">2</span></code>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
|
|
|
|
<table class="summary properties" id="properties">
|
|
<caption>Properties summary</caption>
|
|
<tr data-order="callback" id="$callback">
|
|
<td class="attributes"><code>
|
|
protected
|
|
callable
|
|
</code></td>
|
|
|
|
<td class="name">
|
|
<a href="source-class-splitbrain.PHPArchive.Archive.html#13-14" title="Go to source code"><var>$callback</var></a>
|
|
|
|
<div class="description short">
|
|
|
|
</div>
|
|
|
|
<div class="description detailed hidden">
|
|
|
|
|
|
</div>
|
|
</td>
|
|
<td class="value">
|
|
<div>
|
|
<a href="#$callback" class="anchor">#</a>
|
|
<code></code>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
API documentation generated by <a href="http://apigen.org">ApiGen</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="resources/combined.js?58699d70ee1015ed63e509c64f4dd9d3b29ddbbe"></script>
|
|
<script src="elementlist.js?d1556c44b5531910445709dcbedf0d7a38d1a058"></script>
|
|
</body>
|
|
</html>
|