mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-17 21:16:57 +08:00
610 lines
16 KiB
HTML
610 lines
16 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
<title>Reads through a whole directory</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.eio-readdir" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">eio_readdir</h1>
|
||
<p class="verinfo">(PECL eio >= 0.0.1dev)</p><p class="refpurpose"><span class="refname">eio_readdir</span> — <span class="dc-title">Reads through a whole directory</span></p>
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.eio-readdir-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>eio_readdir</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>
|
||
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>
|
||
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$pri</code></span>
|
||
, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>
|
||
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code><span class="initializer"> = NULL</span></span>
|
||
] ) : <span class="type">resource</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
Reads through a whole directory(via the <em>opendir</em>, <em>readdir</em> and
|
||
<em>closedir</em> system calls) and returns either the names or an array in
|
||
<code class="parameter">result</code> argument of <code class="parameter">callback</code>
|
||
function, depending on the <code class="parameter">flags</code> argument.
|
||
</p>
|
||
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.eio-readdir-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">path</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Directory path.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">flags</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Combination of <em class="emphasis">EIO_READDIR_*</em> constants.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">pri</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">请求的优先级:<strong><code>EIO_PRI_DEFAULT</code></strong>,<strong><code>EIO_PRI_MIN</code></strong>,<strong><code>EIO_PRI_MAX</code></strong> 或 <strong><code>NULL</code></strong>。如果是
|
||
<strong><code>NULL</code></strong>,<code class="parameter">pri</code> 将设为
|
||
<strong><code>EIO_PRI_DEFAULT</code></strong>。
|
||
</p>
|
||
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">callback</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
<code class="parameter">callback</code>
|
||
函数在请求完成时被调用。其应匹配一下原型:<div class="example-contents"><div class="phpcode"><pre><span style="color: #000000">
|
||
void callback(mixed $data, int $result[, resource $req]);</span>
|
||
</pre></div></div>
|
||
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">data</code></dt>
|
||
|
||
<dd>
|
||
<p class="para">传递给请求的用户数据。</p></dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">result</code></dt>
|
||
|
||
<dd>
|
||
<p class="para">针对请求的结果的值。通常是相应的系统调用返回的值。</p></dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">req</code></dt>
|
||
|
||
<dd>
|
||
<p class="para">可选的请求资源,可被 <span class="function"><a href="eio_get_last_error.html" class="function">eio_get_last_error()</a></span>
|
||
之类的函数使用。</p></dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">data</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Arbitrary variable passed to <code class="parameter">callback</code>.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.eio-readdir-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
<span class="function"><strong>eio_readdir()</strong></span> returns request resource on success, or
|
||
<strong><code>FALSE</code></strong> on error. Sets <code class="parameter">result</code> argument of
|
||
<code class="parameter">callback</code> function according to
|
||
<code class="parameter">flags</code>:
|
||
</p>
|
||
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_READDIR_DENTS</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
<span class="function"><strong>eio_readdir()</strong></span> flag. If specified, the result argument of the callback
|
||
becomes an array with the following keys:
|
||
<em>'names'</em> - array of directory names
|
||
<em>'dents'</em> - array of <em>struct
|
||
eio_dirent</em>-like arrays having the following keys each:
|
||
<em>'name'</em> - the directory name;
|
||
<em>'type'</em> - one of <em class="emphasis">EIO_DT_*</em>
|
||
constants;
|
||
<em>'inode'</em> - the inode number, if available, otherwise
|
||
unspecified;
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_READDIR_DIRS_FIRST</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
When this flag is specified, the names will be returned in an order
|
||
where likely directories come first, in optimal stat order.
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_READDIR_STAT_ORDER</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
When this flag is specified, then the names will be returned in an order
|
||
suitable for <em>stat</em>'ing each one. When planning to
|
||
<span class="function"><a href="stat.html" class="function">stat()</a></span> all files in the given directory, the
|
||
returned order will likely be
|
||
fastest.
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_READDIR_FOUND_UNKNOWN</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
|
||
<p class="para">Node types:
|
||
<dl>
|
||
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_UNKNOWN</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Unknown node type(very common). Further <span class="function"><a href="stat.html" class="function">stat()</a></span> needed.
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_FIFO</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
FIFO node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_CHR</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_MPC</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Multiplexed char device (v7+coherent) node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_DIR</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Directory node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_NAM</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Xenix special named file node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_BLK</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_MPB</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Multiplexed block device (v7+coherent)
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_REG</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_NWK</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_CMP</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
HP-UX network special node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_LNK</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Link node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_SOCK</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Socket node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_DOOR</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Solaris door node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_WHT</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Node type
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
|
||
<strong><code>EIO_DT_MAX</code></strong>
|
||
(<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
|
||
</dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
Highest node type value
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.eio-readdir-examples">
|
||
<h3 class="title">范例</h3>
|
||
<div class="example" id="example-4284">
|
||
<p><strong>Example #1 <span class="function"><strong>eio_readdir()</strong></span> example</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">/* Is called when eio_readdir() finishes */<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">my_readdir_callback</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">, </span><span style="color: #0000BB">$result</span><span style="color: #007700">) {<br /> echo </span><span style="color: #0000BB">__FUNCTION__</span><span style="color: #007700">, </span><span style="color: #DD0000">" called\n"</span><span style="color: #007700">;<br /> echo </span><span style="color: #DD0000">"data: "</span><span style="color: #007700">; </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br /> echo </span><span style="color: #DD0000">"result: "</span><span style="color: #007700">; </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /> echo </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">eio_readdir</span><span style="color: #007700">(</span><span style="color: #DD0000">"/var/spool/news"</span><span style="color: #007700">, </span><span style="color: #0000BB">EIO_READDIR_STAT_ORDER </span><span style="color: #007700">| </span><span style="color: #0000BB">EIO_READDIR_DIRS_FIRST</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_readdir_callback"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">eio_event_loop</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
|
||
<div class="example-contents screen">
|
||
<div class="cdata"><pre>
|
||
my_readdir_callback called
|
||
data: NULL
|
||
result: array(2) {
|
||
["names"]=>
|
||
array(7) {
|
||
[0]=>
|
||
string(7) "archive"
|
||
[1]=>
|
||
string(8) "articles"
|
||
[2]=>
|
||
string(8) "incoming"
|
||
[3]=>
|
||
string(7) "innfeed"
|
||
[4]=>
|
||
string(8) "outgoing"
|
||
[5]=>
|
||
string(8) "overview"
|
||
[6]=>
|
||
string(3) "tmp"
|
||
}
|
||
["dents"]=>
|
||
array(7) {
|
||
[0]=>
|
||
array(3)
|
||
{
|
||
["name"]=>
|
||
string(7)
|
||
"archive"
|
||
["type"]=>
|
||
int(4)
|
||
["inode"]=>
|
||
int(393265)
|
||
}
|
||
[1]=>
|
||
array(3)
|
||
{
|
||
["name"]=>
|
||
string(8)
|
||
"articles"
|
||
["type"]=>
|
||
int(4)
|
||
["inode"]=>
|
||
int(393266)
|
||
}
|
||
[2]=>
|
||
array(3)
|
||
{
|
||
["name"]=>
|
||
string(8)
|
||
"incoming"
|
||
["type"]=>
|
||
int(4)
|
||
["inode"]=>
|
||
int(393267)
|
||
}
|
||
[3]=>
|
||
array(3)
|
||
{
|
||
["name"]=>
|
||
string(7)
|
||
"innfeed"
|
||
["type"]=>
|
||
int(4)
|
||
["inode"]=>
|
||
int(393269)
|
||
}
|
||
[4]=>
|
||
array(3)
|
||
{
|
||
["name"]=>
|
||
string(8)
|
||
"outgoing"
|
||
["type"]=>
|
||
int(4)
|
||
["inode"]=>
|
||
int(393270)
|
||
}
|
||
[5]=>
|
||
array(3)
|
||
{
|
||
["name"]=>
|
||
string(8)
|
||
"overview"
|
||
["type"]=>
|
||
int(4)
|
||
["inode"]=>
|
||
int(393271)
|
||
}
|
||
[6]=>
|
||
array(3)
|
||
{
|
||
["name"]=>
|
||
string(3)
|
||
"tmp"
|
||
["type"]=>
|
||
int(4)
|
||
["inode"]=>
|
||
int(393272)
|
||
}
|
||
}
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
</div></div></div></body></html> |