Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

eio_readdir(3) [php man page]

EIO_READDIR(3)								 1							    EIO_READDIR(3)

eio_readdir - Reads through a whole directory

SYNOPSIS
resource eio_readdir (string $path, int $flags, int $pri, callable $callback, [string $data = NULL]) DESCRIPTION
Reads through a whole directory(via the opendir, readdir and closedir system calls) and returns either the names or an array in $result argument of $callback function, depending on the $flags argument. PARAMETERS
o $path - Directory path. o $flags - Combination of EIO_READDIR_* constants. o $pri -The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL. If NULL passed, $pri internally is set to EIO_PRI_DEFAULT. o $callback -$callback function is called when the request is done. It should match the following prototype: void callback(mixed $data, int $result[, resource $req]); o $data -is custom data passed to the request. o $result -request-specific result value; basically, the value returned by corresponding system call. o $req -is optional request resource which can be used with functions like eio_get_last_error(3) o $data - Arbitrary variable passed to $callback. RETURN VALUES
eio_readdir(3) returns request resource on success, or FALSE on error. Sets $result argument of $callback function according to $flags: o EIO_READDIR_DENTS ( integer) -eio_readdir(3) flag. If specified, the result argument of the callback becomes an array with the following keys: 'names' - array of directory names 'dents' - array of struct eio_dirent-like arrays having the following keys each: 'name' - the directory name; 'type' - one of EIO_DT_* constants; 'inode' - the inode number, if available, otherwise unspec- ified; o EIO_READDIR_DIRS_FIRST ( integer) - When this flag is specified, the names will be returned in an order where likely directories come first, in optimal stat order. o EIO_READDIR_STAT_ORDER ( integer) - When this flag is specified, then the names will be returned in an order suitable for stat'ing each one. When planning to stat(3) all files in the given directory, the returned order will likely be fastest. o EIO_READDIR_FOUND_UNKNOWN ( integer) - Node types: o EIO_DT_UNKNOWN ( integer) - Unknown node type(very common). Further stat(3) needed. o EIO_DT_FIFO ( integer) - FIFO node type o EIO_DT_CHR ( integer) - Node type o EIO_DT_MPC ( integer) - Multiplexed char device (v7+coherent) node type o EIO_DT_DIR ( integer) - Directory node type o EIO_DT_NAM ( integer) - Xenix special named file node type o EIO_DT_BLK ( integer) - Node type o EIO_DT_MPB ( integer) - Multiplexed block device (v7+coherent) o EIO_DT_REG ( integer) - Node type o EIO_DT_NWK ( integer) - o EIO_DT_CMP ( integer) - HP-UX network special node type o EIO_DT_LNK ( integer) - Link node type o EIO_DT_SOCK ( integer) - Socket node type o EIO_DT_DOOR ( integer) - Solaris door node type o EIO_DT_WHT ( integer) - Node type o EIO_DT_MAX ( integer) - Highest node type value EXAMPLES
Example #1 eio_readdir(3) example <?php /* Is called when eio_readdir() finishes */ function my_readdir_callback($data, $result) { echo __FUNCTION__, " called "; echo "data: "; var_dump($data); echo "result: "; var_dump($result); echo " "; } eio_readdir("/var/spool/news", EIO_READDIR_STAT_ORDER | EIO_READDIR_DIRS_FIRST, EIO_PRI_DEFAULT, "my_readdir_callback"); eio_event_loop(); ?> The above example will output something similar to: 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) } } } PHP Documentation Group EIO_READDIR(3)
Man Page