class SafeStream

internal  
 

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');

Constants

PROTOCOL

Name of stream protocol - nette.safe://

Methods

static bool
register()

Registers protocol 'nette.safe://'.

bool
stream_open($path, $mode, $options)

Opens file.

void
stream_close()

Closes file.

string
stream_read($length)

Reads up to length bytes from the file.

int
stream_write($data)

Writes the string to the file.

bool
stream_truncate($size)

Truncates a file to a given length.

int
stream_tell()

Returns the position of the file.

bool
stream_eof()

Returns true if the file pointer is at end-of-file.

int
stream_seek($offset, $whence)

Sets the file position indicator for the file.

array
stream_stat()

Gets information about a file referenced by $this->tempHandle.

array
url_stat($path, $flags)

Gets information about a file referenced by filename.

bool
unlink($path)

Deletes a file.

Details

at line 51
static bool register()

Registers protocol 'nette.safe://'.

Return Value

bool

at line 68
bool stream_open($path, $mode, $options)

Opens file.

Parameters

$path
$mode
$options

Return Value

bool

true on success or false on failure

at line 170
void stream_close()

Closes file.

Return Value

void

at line 196
string stream_read($length)

Reads up to length bytes from the file.

Parameters

$length

Return Value

string

at line 207
int stream_write($data)

Writes the string to the file.

Parameters

$data

Return Value

int

number of bytes that were successfully stored

at line 225
bool stream_truncate($size)

Truncates a file to a given length.

Parameters

$size

Return Value

bool

at line 235
int stream_tell()

Returns the position of the file.

Return Value

int

at line 245
bool stream_eof()

Returns true if the file pointer is at end-of-file.

Return Value

bool

at line 257
int stream_seek($offset, $whence)

Sets the file position indicator for the file.

Parameters

$offset
$whence

Return Value

int

Return true on success

at line 267
array stream_stat()

Gets information about a file referenced by $this->tempHandle.

Return Value

array

at line 279
array url_stat($path, $flags)

Gets information about a file referenced by filename.

Parameters

$path
$flags

Return Value

array

Deletes a file.

On Windows unlink is not allowed till file is opened

Parameters

$path

Return Value

bool

true on success or false on failure