mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 22:38:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@324122 c90b9560-bf6c-de11-be94-00142212c4b1
486 lines
10 KiB
XML
486 lines
10 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<refentry xml:id="function.eio-readdir" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>eio_readdir</refname>
|
|
<refpurpose>Reads through a whole directory</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>resource</type><methodname>eio_readdir</methodname>
|
|
<methodparam><type>string</type><parameter>path</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>flags</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>pri</parameter></methodparam>
|
|
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
|
<methodparam
|
|
choice="opt"><type>string</type><parameter>data</parameter><initializer>NULL</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Reads through a whole directory(via the <literal>opendir</literal>, <literal>readdir</literal> and
|
|
<literal>closedir</literal> system calls) and returns either the names or an array in
|
|
<parameter>result</parameter> argument of <parameter>callback</parameter>
|
|
function, depending on the <parameter>flags</parameter> argument.
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>path</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Directory path.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Combination of <emphasis>EIO_READDIR_*</emphasis> constants.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>pri</parameter></term>
|
|
<listitem>
|
|
&eio.request.pri.values;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>callback</parameter></term>
|
|
<listitem>
|
|
&eio.callback.proto;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>data</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Arbitrary variable passed to <parameter>callback</parameter>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<function>eio_readdir</function> returns request resource on success, or
|
|
&false; on error. Sets <parameter>result</parameter> argument of
|
|
<parameter>callback</parameter> function according to
|
|
<parameter>flags</parameter>:
|
|
</para>
|
|
|
|
<para>
|
|
<variablelist>
|
|
|
|
<!--{{{ EIO_READDIR_* -->
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_READDIR_DENTS</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
<function>eio_readdir</function> flag. If specified, the result argument of the callback
|
|
becomes an array with the following keys:
|
|
<literal>'names'</literal> - array of directory names
|
|
<literal>'dents'</literal> - array of <literal>struct
|
|
eio_dirent</literal>-like arrays having the following keys each:
|
|
<literal>'name'</literal> - the directory name;
|
|
<literal>'type'</literal> - one of <emphasis>EIO_DT_*</emphasis>
|
|
constants;
|
|
<literal>'inode'</literal> - the inode number, if available, otherwise
|
|
unspecified;
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_READDIR_DIRS_FIRST</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
When this flag is specified, the names will be returned in an order
|
|
where likely directories come first, in optimal stat order.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_READDIR_STAT_ORDER</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
When this flag is specified, then the names will be returned in an order
|
|
suitable for <literal>stat</literal>'ing each one. When planning to
|
|
<function>stat</function> all files in the given directory, the
|
|
returned order will likely be
|
|
fastest.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_READDIR_FOUND_UNKNOWN</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<!--}}}-->
|
|
|
|
</variablelist>
|
|
</para>
|
|
|
|
<para>Node types:
|
|
<variablelist>
|
|
|
|
<!--{{{ EIO_DT_* -->
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_UNKNOWN</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Unknown node type(very common). Further <function>stat</function> needed.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_FIFO</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
FIFO node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_CHR</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_MPC</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Multiplexed char device (v7+coherent) node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_DIR</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Directory node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_NAM</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Xenix special named file node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_BLK</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_MPB</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Multiplexed block device (v7+coherent)
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_REG</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_NWK</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_CMP</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
HP-UX network special node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_LNK</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Link node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_SOCK</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Socket node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_DOOR</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Solaris door node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_WHT</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Node type
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>EIO_DT_MAX</constant>
|
|
(<type>integer</type>)
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Highest node type value
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<!--}}}-->
|
|
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title><function>eio_readdir</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/* Is called when eio_readdir() finishes */
|
|
function my_readdir_callback($data, $result) {
|
|
echo __FUNCTION__, " called\n";
|
|
echo "data: "; var_dump($data);
|
|
echo "result: "; var_dump($result);
|
|
echo "\n";
|
|
}
|
|
|
|
eio_readdir("/var/spool/news", EIO_READDIR_STAT_ORDER | EIO_READDIR_DIRS_FIRST,
|
|
EIO_PRI_DEFAULT, "my_readdir_callback");
|
|
eio_event_loop();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</refsect1>
|
|
|
|
|
|
</refentry>
|
|
|
|
<!-- 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:"~/.phpdoc/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
|
|
-->
|