PHP Class PHPDaemon\FS\FileSystem

Author: Vasily Zorin ([email protected])
Inheritance: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog, use trait PHPDaemon\Traits\EventLoopContainer
Show file Open project: kakserpom/phpdaemon Class Usage Examples

Public Properties

Property Type Description
$badFDttl TTL for bad descriptors in seconds
$eioVer Required EIO version
$ev Main FS event
$fd EIO file descriptor
$fdCache File descriptor cache
$fdCacheSize Maximum number of open files in cache
$modeTypes Mode types
$supported Is EIO supported?

Public Methods

Method Description
__construct ( )
checkFileReadable ( string $path ) : boolean Checks if file exists and readable
chown ( string $path, integer $uid, integer $gid, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Changes ownership of file/directory
genRndTempnam ( string $dir = null, string $prefix = 'php' ) : string Returns random temporary file name
genRndTempnamPrefix ( string $dir, string $prefix ) : string Returns random temporary file name
init ( ) : void Initialize FS driver
initEvent ( ) : void Initialize main FS event
lstat ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | true lstat()
mkdir ( string $path, integer $mode, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Creates directory
open ( string $path, string $flags, callable $cb, integer $mode = null, integer $pri = EIO_PRI_DEFAULT ) : resource Open file
readdir ( string $path, callable $cb = null, integer $flags = null, integer $pri = EIO_PRI_DEFAULT ) : resource | true Readdir()
readfile ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | true Reads whole file
readfileChunked ( string $path, callable $cb, callable $chunkcb, integer $pri = EIO_PRI_DEFAULT ) : resource Reads file chunk-by-chunk
realpath ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | true realpath()
rename ( string $path, string $newpath, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Rename
rmdir ( string $path, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Removes empty directory
sanitizePath ( string $path ) : string Sanitize path
sendfile ( mixed $outfd, string $path, callable $cb, callable $startCb = null, integer $offset, integer $length = null, integer $pri = EIO_PRI_DEFAULT ) : true sendfile()
stat ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | true Gets stat() information
statPrepare ( mixed $stat ) : array Prepare value of stat()
statvfs ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | false statvfs()
sync ( callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false sync()
syncfs ( callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false statfs()
tempnam ( string $dir, string $prefix, callable $cb ) : resource Obtain exclusive temporary file
touch ( string $path, integer $mtime, integer $atime = null, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean touch()
truncate ( string $path, integer $offset, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Truncate file
unlink ( string $path, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Unlink file
updateConfig ( ) : void Called when config is updated
waitAllEvents ( ) : void Block until all FS events are completed

Protected Methods

Method Description
tempnamHandler ( $dir, $prefix, $cb, &$tries ) Generates closure tempnam handler

Method Details

__construct() public method

public __construct ( )

checkFileReadable() public static method

Checks if file exists and readable
public static checkFileReadable ( string $path ) : boolean
$path string Path
return boolean Exists and readable?

chown() public static method

Changes ownership of file/directory
public static chown ( string $path, integer $uid, integer $gid, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$path string Path
$uid integer User ID
$gid integer Group ID
$cb callable = null Callback
$pri integer = EIO_PRI_DEFAULT Priority
return resource | boolean

genRndTempnam() public static method

Returns random temporary file name
public static genRndTempnam ( string $dir = null, string $prefix = 'php' ) : string
$dir string Directory
$prefix string Prefix
return string Path

genRndTempnamPrefix() public static method

Returns random temporary file name
public static genRndTempnamPrefix ( string $dir, string $prefix ) : string
$dir string Directory
$prefix string Prefix
return string Path

init() public static method

Initialize FS driver
public static init ( ) : void
return void

initEvent() public static method

Initialize main FS event
public static initEvent ( ) : void
return void

lstat() public static method

lstat()
public static lstat ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | true
$path string Path
$cb callable Callback
$pri integer Priority
return resource | true

mkdir() public static method

Creates directory
public static mkdir ( string $path, integer $mode, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$path string Path
$mode integer Mode (octal)
$cb callable Callback
$pri integer Priority
return resource | boolean

open() public static method

Open file
public static open ( string $path, string $flags, callable $cb, integer $mode = null, integer $pri = EIO_PRI_DEFAULT ) : resource
$path string Path
$flags string Flags
$cb callable Callback (File)
$mode integer Mode (see EIO_S_I* constants)
$pri integer Priority
return resource

readdir() public static method

Readdir()
public static readdir ( string $path, callable $cb = null, integer $flags = null, integer $pri = EIO_PRI_DEFAULT ) : resource | true
$path string Path
$cb callable = null Callback
$flags integer = null Flags
$pri integer = EIO_PRI_DEFAULT Priority
return resource | true

readfile() public static method

Reads whole file
public static readfile ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | true
$path string Path
$cb callable Callback (Path, Contents)
$pri integer Priority
return resource | true

readfileChunked() public static method

Reads file chunk-by-chunk
public static readfileChunked ( string $path, callable $cb, callable $chunkcb, integer $pri = EIO_PRI_DEFAULT ) : resource
$path string Path
$cb callable Callback (Path, Success)
$chunkcb callable Chunk callback (Path, Chunk)
$pri integer Priority
return resource

realpath() public static method

realpath()
public static realpath ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | true
$path string Path
$cb callable Callback
$pri integer Priority
return resource | true

rename() public static method

Rename
public static rename ( string $path, string $newpath, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$path string Path
$newpath string New path
$cb callable Callback
$pri integer Priority
return resource | boolean

rmdir() public static method

Removes empty directory
public static rmdir ( string $path, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$path string Path
$cb callable Callback
$pri integer Priority
return resource | boolean

sanitizePath() public static method

Sanitize path
public static sanitizePath ( string $path ) : string
$path string Path
return string Sanitized path

sendfile() public static method

sendfile()
public static sendfile ( mixed $outfd, string $path, callable $cb, callable $startCb = null, integer $offset, integer $length = null, integer $pri = EIO_PRI_DEFAULT ) : true
$outfd mixed File descriptor
$path string Path
$cb callable Callback
$startCb callable Start callback
$offset integer Offset
$length integer Length
$pri integer Priority
return true Success

stat() public static method

Gets stat() information
public static stat ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | true
$path string Path
$cb callable Callback
$pri integer Priority
return resource | true

statPrepare() public static method

Prepare value of stat()
public static statPrepare ( mixed $stat ) : array
$stat mixed Data
return array hash

statvfs() public static method

statvfs()
public static statvfs ( string $path, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$path string Path
$cb callable Callback
$pri integer Priority
return resource | false

sync() public static method

sync()
public static sync ( callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$cb callable Callback
$pri integer Priority
return resource | false

syncfs() public static method

statfs()
public static syncfs ( callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$cb callable Callback
$pri integer Priority
return resource | false

tempnam() public static method

Obtain exclusive temporary file
public static tempnam ( string $dir, string $prefix, callable $cb ) : resource
$dir string Directory
$prefix string Prefix
$cb callable Callback (File)
return resource

tempnamHandler() protected static method

Generates closure tempnam handler
protected static tempnamHandler ( $dir, $prefix, $cb, &$tries )
$dir
$prefix
$cb
$tries

touch() public static method

touch()
public static touch ( string $path, integer $mtime, integer $atime = null, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$path string Path
$mtime integer Last modification time
$atime integer Last access time
$cb callable Callback
$pri integer Priority
return resource | boolean

truncate() public static method

Truncate file
public static truncate ( string $path, integer $offset, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$path string Path
$offset integer Offset
$cb callable Callback
$pri integer Priority
return resource | boolean

updateConfig() public static method

Called when config is updated
public static updateConfig ( ) : void
return void

waitAllEvents() public static method

Block until all FS events are completed
public static waitAllEvents ( ) : void
return void

Property Details

$badFDttl public static property

TTL for bad descriptors in seconds
public static $badFDttl

$eioVer public static property

Required EIO version
public static $eioVer

$ev public static property

Main FS event
public static $ev

$fd public static property

EIO file descriptor
public static $fd

$fdCache public static property

File descriptor cache
public static $fdCache

$fdCacheSize public static property

Maximum number of open files in cache
public static $fdCacheSize

$modeTypes public static property

Mode types
public static $modeTypes

$supported public static property

Is EIO supported?
public static $supported