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

Constants

PROTOCOL

Name of stream protocol - nette.safe://

Methods

static bool
register()

Registers protocol 'nette.safe://'.

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

Opens file.

void
stream_close()

Closes file.

stream_read(int $length)

Reads up to length bytes from the file.

int
stream_write(string $data)

Writes the string to the file.

bool
stream_truncate(int $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.

bool
stream_seek(int $offset, int $whence = SEEK_SET)

Sets the file position indicator for the file.

stream_stat()

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

url_stat(string $path, int $flags)

Gets information about a file referenced by filename.

bool
unlink(string $path)

Deletes a file.

Details

at line 52
static bool register()

Registers protocol 'nette.safe://'.

Return Value

bool

at line 65
bool stream_open(string $path, string $mode, int $options)

Opens file.

Parameters

string $path
string $mode
int $options

Return Value

bool

at line 165
void stream_close()

Closes file.

Return Value

void

at line 189
stream_read(int $length)

Reads up to length bytes from the file.

Parameters

int $length

at line 198
int stream_write(string $data)

Writes the string to the file.

Parameters

string $data

Return Value

int

at line 214
bool stream_truncate(int $size)

Truncates a file to a given length.

Parameters

int $size

Return Value

bool

at line 223
int stream_tell()

Returns the position of the file.

Return Value

int

at line 232
bool stream_eof()

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

Return Value

bool

at line 241
bool stream_seek(int $offset, int $whence = SEEK_SET)

Sets the file position indicator for the file.

Parameters

int $offset
int $whence

Return Value

bool

at line 250
stream_stat()

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

at line 259
url_stat(string $path, int $flags)

Gets information about a file referenced by filename.

Parameters

string $path
int $flags

Deletes a file.

On Windows unlink is not allowed till file is opened

Parameters

string $path

Return Value

bool