<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.rarentry.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'rarentry.extract.php',
    1 => 'RarEntry::extract',
    2 => 'Extract entry from the archive',
  ),
  'up' => 
  array (
    0 => 'class.rarentry.php',
    1 => 'RarEntry',
  ),
  'prev' => 
  array (
    0 => 'class.rarentry.php',
    1 => 'RarEntry',
  ),
  'next' => 
  array (
    0 => 'rarentry.getattr.php',
    1 => 'RarEntry::getAttr',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/rar/rarentry/extract.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="rarentry.extract" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">RarEntry::extract</h1>
  <p class="verinfo">(PECL rar &gt;= 0.1)</p><p class="refpurpose"><span class="refname">RarEntry::extract</span> &mdash; <span class="dc-title">Extract entry from the archive</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-rarentry.extract-description">
  <h3 class="title">Опис</h3>
   <div class="methodsynopsis dc-description">
    <span class="modifier">public</span> <span class="methodname"><strong>RarEntry::extract</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$dir</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filepath</code><span class="initializer"> = &quot;&quot;</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$password</code><span class="initializer"> = NULL</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$extended_data</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   <span class="methodname"><strong>RarEntry::extract()</strong></span> extracts the entry&#039;s data.
   It will create new file in the specified
   <code class="parameter">dir</code> with the name identical to the entry&#039;s name,
   unless the second argument is specified. See below for more information.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-rarentry.extract-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">dir</code></dt>
     <dd>
      <p class="para">
       Path to the directory where files should be extracted. This parameter is
       considered if and only if <code class="parameter">filepath</code> is not. If both
       parameters are empty an extraction to the current directory will be
       attempted.
      </p>
     </dd>
    
    
    
     <dt><code class="parameter">filepath</code></dt>
     <dd>
      <p class="para">
       Path (relative or absolute) containing the directory and filename of the
       extracted file. This parameter overrides both the parameter
       <code class="parameter">dir</code> and the original file name.
      </p>
     </dd>
    
    
    
     <dt><code class="parameter">password</code></dt>
     <dd>
      <p class="para">
       The password used to encrypt this entry. If the entry is not encrypted, this value will not be used and can
       be omitted. If this parameter is omitted and the entry is encrypted, the password given to
       <span class="function"><a href="rararchive.open.php" class="function">rar_open()</a></span>, if any, will be used. If a wrong password is given, either explicitly
       or implicitly via <span class="function"><a href="rararchive.open.php" class="function">rar_open()</a></span>, CRC checking will fail and this method will fail and return <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
       If no password is given and one is required, this method will fail and return <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
       You can check whether an entry is encrypted with <span class="methodname"><a href="rarentry.isencrypted.php" class="methodname">RarEntry::isEncrypted()</a></span>.
      </p>
     </dd>
    

   
    <dt><code class="parameter">extended_data</code></dt>
    <dd>
     <p class="para">
       If <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, extended information such as NTFS ACLs and Unix owner information will be set in the extract
       files, as long as it&#039;s present in the archive.
     </p>
    </dd>
   
   </dl>
  </p>
  <div class="warning"><strong class="warning">Увага</strong>
      <p class="para">Prior to version 2.0.0, this function would not handle relative
      paths correctly. Use <span class="function"><a href="function.realpath.php" class="function">realpath()</a></span> as a workaround.</p>
  </div>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-rarentry.extract-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Повертає <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> у разі успіху або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-rarentry.extract-changelog">
  <h3 class="title">Журнал змін</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Версія</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL rar 3.0.0</td>
       <td>
        <code class="parameter">extended_data</code> was added.
       </td>
      </tr>

      <tr>
       <td>PECL rar 3.0.0</td>
       <td>
        Support for RAR archives with repeated entry names is no longer defective.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-rarentry.extract-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="methodname"><strong>RarEntry::extract()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$rar_file </span><span style="color: #007700">= </span><span style="color: #0000BB">rar_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'example.rar'</span><span style="color: #007700">) or die(</span><span style="color: #DD0000">"Failed to open Rar archive"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$entry </span><span style="color: #007700">= </span><span style="color: #0000BB">rar_entry_get</span><span style="color: #007700">(</span><span style="color: #0000BB">$rar_file</span><span style="color: #007700">, </span><span style="color: #DD0000">'Dir/file.txt'</span><span style="color: #007700">) or die(</span><span style="color: #DD0000">"Failed to find such entry"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$entry</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">extract</span><span style="color: #007700">(</span><span style="color: #DD0000">'/dir/to'</span><span style="color: #007700">); </span><span style="color: #FF8000">// create /dir/to/Dir/file.txt<br /></span><span style="color: #0000BB">$entry</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">extract</span><span style="color: #007700">(</span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #DD0000">'/dir/to/new_name.txt'</span><span style="color: #007700">); </span><span style="color: #FF8000">// create /dir/to/new_name.txt<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
   <div class="example" id="example-2">
    <p><strong>Приклад #2 How to extract all files in archive: </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/* example by Erik Jenssen aka erix */<br /><br /></span><span style="color: #0000BB">$filename </span><span style="color: #007700">= </span><span style="color: #DD0000">"foobar.rar"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$filepath </span><span style="color: #007700">= </span><span style="color: #DD0000">"/home/foo/bar/"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$rar_file </span><span style="color: #007700">= </span><span style="color: #0000BB">rar_open</span><span style="color: #007700">(</span><span style="color: #0000BB">$filepath</span><span style="color: #007700">.</span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$list </span><span style="color: #007700">= </span><span style="color: #0000BB">rar_list</span><span style="color: #007700">(</span><span style="color: #0000BB">$rar_file</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$list </span><span style="color: #007700">as </span><span style="color: #0000BB">$file</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$entry </span><span style="color: #007700">= </span><span style="color: #0000BB">rar_entry_get</span><span style="color: #007700">(</span><span style="color: #0000BB">$rar_file</span><span style="color: #007700">, </span><span style="color: #0000BB">$file</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$entry</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">extract</span><span style="color: #007700">(</span><span style="color: #DD0000">"."</span><span style="color: #007700">); </span><span style="color: #FF8000">// extract to the current dir<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">rar_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$rar_file</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-rarentry.extract-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="rarentry.getstream.php" class="methodname" rel="rdfs-seeAlso">RarEntry::getStream()</a> - Get file handler for entry</span></li>
    <li><a href="wrappers.rar.php" class="link"><code class="literal">rar://</code> wrapper</a></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>