eio_readdir

PECL eio >= 0.0.1dev
eio_readdir - Reads through a whole directory
Manual
Code Examples

eio_readdir(
     string$path,
     int$flags,
     int$pri,
     callable$callback,
     [string$data = NULL]
): resource

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

path

Directory path.

flags

Combination of EIO_READDIR_* constants.

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.

callback

callback function is called when the request is done. It should match the following prototype:

void callback(mixed $data, int $result[, resource $req]);
data

is custom data passed to the request.

result

request-specific result value; basically, the value returned by corresponding system call.

req

is optional request resource which can be used with functions like eio_get_last_error

data

Arbitrary variable passed to callback.

Return Values

eio_readdir returns request resource on success, or false on failure. Sets result argument of callback function according to flags:

EIO_READDIR_DENTS (int)

eio_readdir 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 unspecified;

EIO_READDIR_DIRS_FIRST (int)

When 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 stat'ing each one. When planning to stat all files in the given directory, the returned order will likely be fastest.

EIO_READDIR_FOUND_UNKNOWN (int)

Node types:

EIO_DT_UNKNOWN (int)

Unknown node type(very common). Further stat needed.

EIO_DT_FIFO (int)

FIFO node type

EIO_DT_CHR (int)

Node type

EIO_DT_MPC (int)

Multiplexed char device (v7+coherent) node type

EIO_DT_DIR (int)

Directory node type

EIO_DT_NAM (int)

Xenix special named file node type

EIO_DT_BLK (int)

Node type

EIO_DT_MPB (int)

Multiplexed block device (v7+coherent)

EIO_DT_REG (int)

Node type

EIO_DT_NWK (int)

EIO_DT_CMP (int)

HP-UX network special node type

EIO_DT_LNK (int)

Link node type

EIO_DT_SOCK (int)

Socket node type

EIO_DT_DOOR (int)

Solaris door node type

EIO_DT_WHT (int)

Node type

EIO_DT_MAX (int)

Highest node type value

Example of eio_readdir

Show all examples for eio_readdir

PHP Version: