eio_readdir
eio_readdir
Reads through a whole directory
resource **eio_readdir** string $path int $flags int $pri callable $callback string $data
Reads through a whole directory(via the , and
system calls) and returns either the names or an array in
argument of
function, depending on the argument.
opendir``readdir``closedir``result``callback``flags
pathDirectory path.
flags
Combination of constants.
EIO_READDIR_*
pri``callback``data
Arbitrary variable passed to .
callback
returns request resource on success,return.falseforfailure.
Sets argument of
function according to
:
eio_readdir``result``callback``flags
EIO_READDIR_DENTS``int
flag. If specified, the result argument of the callback
becomes an array with the following keys:
- array of directory names
- array of -like arrays having the following keys each:
- the directory name;
- one of
constants;
- the inode number, if available, otherwise
unspecified;
eio_readdir``'names'``'dents'``struct eio_dirent``'name'``'type'*EIO_DT_**'inode'
EIO_READDIR_DIRS_FIRST``intWhen this flag is specified, the names will be returned in an order
where likely directories come first, in optimal stat order.
EIO_READDIR_STAT_ORDER``int
When this flag is specified, then the names will be returned in an order
suitable for 'ing each one. When planning to
all files in the given directory, the
returned order will likely be
fastest.
stat``stat
EIO_READDIR_FOUND_UNKNOWN``int
Node types:
EIO_DT_UNKNOWN``int
Unknown node type(very common). Further needed.
stat
EIO_DT_FIFO``intFIFO node type
EIO_DT_CHR``intNode type
EIO_DT_MPC``intMultiplexed char device (v7+coherent) node type
EIO_DT_DIR``intDirectory node type
EIO_DT_NAM``intXenix special named file node type
EIO_DT_BLK``intNode type
EIO_DT_MPB``intMultiplexed block device (v7+coherent)
EIO_DT_REG``intNode type
EIO_DT_NWK``int
EIO_DT_CMP``intHP-UX network special node type
EIO_DT_LNK``intLink node type
EIO_DT_SOCK``intSocket node type
EIO_DT_DOOR``intSolaris door node type
EIO_DT_WHT``intNode type
EIO_DT_MAX``intHighest node type value
Voorbeeld: example
<?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();
?>
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)
}
}
}