<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'rarentry.getstream.php',
    1 => 'RarEntry::getStream',
    2 => 'Get file handler for entry',
  ),
  'up' => 
  array (
    0 => 'class.rarentry.php',
    1 => 'RarEntry',
  ),
  'prev' => 
  array (
    0 => 'rarentry.getpackedsize.php',
    1 => 'RarEntry::getPackedSize',
  ),
  'next' => 
  array (
    0 => 'rarentry.getunpackedsize.php',
    1 => 'RarEntry::getUnpackedSize',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/rar/rarentry/getstream.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="rarentry.getstream" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">RarEntry::getStream</h1>
  <p class="verinfo">(PECL rar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">RarEntry::getStream</span> &mdash; <span class="dc-title">Get file handler for entry</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-rarentry.getstream-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>RarEntry::getStream</strong></span>(<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"> = ?</span></span>): <span class="type"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="simpara">
   Returns a file handler that
   supports read operations. This handler provides on-the-fly decompression
   for this entry.
  </p>
  <p class="simpara">
    The handler is not invalidated by calling
    <span class="function"><a href="rararchive.close.php" class="function">rar_close()</a></span>.
  </p>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="simpara">The resulting stream has no integrity verification. In particular, file corruption and
   decryption with a wrong a key will not be detected. It is the programmer&#039;s responsability to use the entry&#039;s CRC
   to check for integrity, if he so wishes.</p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-rarentry.getstream-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">password</code></dt>
    <dd>
     <span class="simpara">
      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>, this method&#039;s resulting stream will produce wrong
      output. 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>.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-rarentry.getstream-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="simpara">
   The file handler  或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-rarentry.getstream-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <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>

 </div>


 <div class="refsect1 examples" id="refsect1-rarentry.getstream-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="example-1">
   <p><strong>示例 #1 <span class="methodname"><strong>RarEntry::getStream()</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">);<br />if (</span><span style="color: #0000BB">$rar_file </span><span style="color: #007700">=== </span><span style="color: #0000BB">false</span><span style="color: #007700">)<br />    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">);<br />if (</span><span style="color: #0000BB">$entry </span><span style="color: #007700">=== </span><span style="color: #0000BB">false</span><span style="color: #007700">)<br />    die(</span><span style="color: #DD0000">"Failed to find such entry"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$stream </span><span style="color: #007700">= </span><span style="color: #0000BB">$entry</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getStream</span><span style="color: #007700">();<br />if (</span><span style="color: #0000BB">$stream </span><span style="color: #007700">=== </span><span style="color: #0000BB">false</span><span style="color: #007700">)<br />    die(</span><span style="color: #DD0000">"Failed to obtain stream."</span><span style="color: #007700">);<br /><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">); </span><span style="color: #FF8000">//stream is independent from file<br /><br /></span><span style="color: #007700">while (!</span><span style="color: #0000BB">feof</span><span style="color: #007700">(</span><span style="color: #0000BB">$stream</span><span style="color: #007700">)) {<br />    </span><span style="color: #0000BB">$buff </span><span style="color: #007700">= </span><span style="color: #0000BB">fread</span><span style="color: #007700">(</span><span style="color: #0000BB">$stream</span><span style="color: #007700">, </span><span style="color: #0000BB">8192</span><span style="color: #007700">);<br />    if (</span><span style="color: #0000BB">$buff </span><span style="color: #007700">!== </span><span style="color: #0000BB">false</span><span style="color: #007700">)<br />        echo </span><span style="color: #0000BB">$buff</span><span style="color: #007700">;<br />    else<br />        break; </span><span style="color: #FF8000">//fread error<br /></span><span style="color: #007700">}<br /><br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$stream</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-rarentry.getstream-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="rarentry.extract.php" class="methodname" rel="rdfs-seeAlso">RarEntry::extract()</a> - Extract entry from the archive</span></li>
   <li><a href="wrappers.rar.php" class="link"><code class="literal">rar://</code> wrapper</a></li>
  </ul>
 </div>


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