Class SafeStream
Provides atomicity and isolation for thread safe file manipulation using
stream nette.safe://
file_put_contents('nette.safe://myfile.txt', $content);
$content = file_get_contents('nette.safe://myfile.txt');
unlink('nette.safe://myfile.txt');
Methods summary
public static
boolean
|
#
register( )
Registers protocol 'nette.safe://'.
Registers protocol 'nette.safe://'.
Returns
boolean bool
|
public
boolean
|
#
stream_open( string $path, string $mode, integer $options )
Opens file.
Parameters
- $path
- name with stream protocol
- $mode
- - see fopen()
- $options
- STREAM_REPORT_ERRORS
Returns
boolean true on success or false on failure
|
public
|
|
public
string
|
#
stream_read( integer $length )
Reads up to length bytes from the file.
Reads up to length bytes from the file.
Parameters
Returns
string string
|
public
integer
|
#
stream_write( string $data )
Writes the string to the file.
Writes the string to the file.
Parameters
Returns
integer number of bytes that were successfully stored
|
public
boolean
|
#
stream_truncate( integer $size )
Truncates a file to a given length.
Truncates a file to a given length.
Parameters
- $size
- size to truncate to.
Returns
boolean bool
|
public
integer
|
#
stream_tell( )
Returns the position of the file.
Returns the position of the file.
Returns
integer int
|
public
boolean
|
#
stream_eof( )
Returns true if the file pointer is at end-of-file.
Returns true if the file pointer is at end-of-file.
Returns
boolean bool
|
public
integer
|
#
stream_seek( integer $offset, integer $whence )
Sets the file position indicator for the file.
Sets the file position indicator for the file.
Parameters
- $offset
- position
- $whence
- fseek()
Returns
integer Return true on success
|
public
array
|
#
stream_stat( )
Gets information about a file referenced by $this->tempHandle.
Gets information about a file referenced by $this->tempHandle.
Returns
array array
|
public
array
|
#
url_stat( string $path, integer $flags )
Gets information about a file referenced by filename.
Gets information about a file referenced by filename.
Parameters
- $path
- name
- $flags
- STREAM_URL_STAT_QUIET
Returns
array array
|
public
boolean
|
#
unlink( string $path )
Deletes a file. On Windows unlink is not allowed till file is opened
Deletes a file. On Windows unlink is not allowed till file is opened
Parameters
- $path
- name with stream protocol
Returns
boolean true on success or false on failure
|
Constants summary
string |
PROTOCOL
Name of stream protocol - nette.safe://
Name of stream protocol - nette.safe://
|
|