PHP Class PHPDaemon\FS\File

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

Public Properties

Property Type Description
$append Append?
$chunkSize Chunk size
$closed Closed?
$fdCacheKey Cache key
$offset Current offset
$path Path
$priority Priority
$writing Writing?

Protected Properties

Property Type Description
$fd File descriptor
$onWriteOnce Stack of callbacks called when writing is done
$stat string hash Stat
$statvfs Cache of statvfs()

Public Methods

Method Description
__construct ( resource $fd, string $path ) File constructor
__destruct ( ) Destructor
__toString ( ) : string toString handler
chown ( integer $uid, integer $gid, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false Changes ownership of this file
clearStatCache ( ) : void Clears cache of stat() and statvfs()
close ( ) : resource | false Close the file
convertFlags ( string $mode, boolean $text = false ) : mixed Converts string of flags to integer or standard text representation
datasync ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | false Datasync()
getFd ( ) : resource Get file descriptor
read ( integer $length, integer $offset = null, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : boolean Reads data from file
readAll ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : boolean Reads whole file
readAllChunked ( callable $cb = null, callable $chunkcb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false Reads file chunk-by-chunk
readahead ( integer $length, integer $offset = null, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false readahead()
seek ( integer $offset, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | false Move pointer to arbitrary position
sendfile ( mixed $outfd, callable $cb, callable $startCb = null, integer $offset, integer $length = null, integer $pri = EIO_PRI_DEFAULT ) : boolean sendfile()
setChunkSize ( integer $n ) : void Set chunk size
stat ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Stat()
statRefresh ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Stat() non-cached
statvfs ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Statvfs()
sync ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | false Sync()
tell ( ) : integer Get current pointer position
touch ( integer $mtime, integer $atime = null, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false touch()
truncate ( integer $offset, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean Truncates this file
write ( string $data, callable $cb = null, integer $offset = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false Writes data to file

Protected Methods

Method Description
readAllChunkedGenHandler ( callable $cb, callable $chunkcb, integer $size, integer &$offset, integer $pri ) : callable Generates closure-callback for readAllChunked
readAllGenHandler ( callable $cb, integer $size, &$offset, &$pri, &$buf ) : callable Generates closure-callback for readAll

Method Details

__construct() public method

File constructor
public __construct ( resource $fd, string $path )
$fd resource Descriptor
$path string Path

__destruct() public method

Destructor
public __destruct ( )

__toString() public method

toString handler
public __toString ( ) : string
return string

chown() public method

Changes ownership of this file
public chown ( integer $uid, integer $gid, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$uid integer User ID
$gid integer Group ID
$cb callable = null Callback
$pri integer = EIO_PRI_DEFAULT Priority
return resource | false

clearStatCache() public method

Clears cache of stat() and statvfs()
public clearStatCache ( ) : void
return void

close() public method

Close the file
public close ( ) : resource | false
return resource | false

convertFlags() public static method

Converts string of flags to integer or standard text representation
public static convertFlags ( string $mode, boolean $text = false ) : mixed
$mode string Mode
$text boolean Text?
return mixed

datasync() public method

Datasync()
public datasync ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$cb callable Callback
$pri integer Priority
return resource | false

getFd() public method

Get file descriptor
public getFd ( ) : resource
return resource File descriptor

read() public method

Reads data from file
public read ( integer $length, integer $offset = null, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : boolean
$length integer Length
$offset integer Offset
$cb callable Callback
$pri integer Priority
return boolean

readAll() public method

Reads whole file
public readAll ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : boolean
$cb callable Callback
$pri integer Priority
return boolean Success

readAllChunked() public method

Reads file chunk-by-chunk
public readAllChunked ( callable $cb = null, callable $chunkcb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$cb callable Callback
$chunkcb callable Callback of chunk
$pri integer Priority
return resource | false

readAllChunkedGenHandler() protected method

Generates closure-callback for readAllChunked
protected readAllChunkedGenHandler ( callable $cb, callable $chunkcb, integer $size, integer &$offset, integer $pri ) : callable
$cb callable
$chunkcb callable
$size integer
$offset integer
$pri integer
return callable

readAllGenHandler() protected method

Generates closure-callback for readAll
protected readAllGenHandler ( callable $cb, integer $size, &$offset, &$pri, &$buf ) : callable
$cb callable
$size integer
return callable

readahead() public method

readahead()
public readahead ( integer $length, integer $offset = null, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$length integer Length
$offset integer Offset
$cb callable Callback
$pri integer Priority
return resource | false

seek() public method

Move pointer to arbitrary position
public seek ( integer $offset, callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$offset integer Offset
$cb callable Callback
$pri integer Priority
return resource | false

sendfile() public method

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

setChunkSize() public method

Set chunk size
public setChunkSize ( integer $n ) : void
$n integer Chunk size
return void

stat() public method

Stat()
public stat ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$cb callable Callback
$pri integer Priority
return resource | boolean

statRefresh() public method

Stat() non-cached
public statRefresh ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$cb callable Callback
$pri integer Priority
return resource | boolean

statvfs() public method

Statvfs()
public statvfs ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$cb callable Callback
$pri integer Priority
return resource | boolean

sync() public method

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

tell() public method

Get current pointer position
public tell ( ) : integer
return integer

touch() public method

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

truncate() public method

Truncates this file
public truncate ( integer $offset, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$offset integer Offset. Default is 0
$cb callable Callback
$pri integer Priority
return resource | boolean

write() public method

Writes data to file
public write ( string $data, callable $cb = null, integer $offset = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$data string Data
$cb callable Callback
$offset integer Offset
$pri integer Priority
return resource | false

Property Details

$append public_oe property

Append?
public $append

$chunkSize public_oe property

Chunk size
public $chunkSize

$closed public_oe property

Closed?
public $closed

$fd protected_oe property

File descriptor
protected $fd

$fdCacheKey public_oe property

Cache key
public $fdCacheKey

$offset public_oe property

Current offset
public $offset

$onWriteOnce protected_oe property

Stack of callbacks called when writing is done
protected $onWriteOnce

$path public_oe property

Path
public $path

$priority public_oe property

Priority
public $priority

$stat protected_oe property

hash Stat
protected string $stat
return string

$statvfs protected_oe property

Cache of statvfs()
protected $statvfs

$writing public_oe property

Writing?
public $writing