Namespaces

  • Nette
    • Application
    • Caching
    • Collections
    • Config
    • Forms
    • IO
    • Loaders
    • Mail
    • Reflection
    • Security
    • Templates
    • Web
  • None
  • PHP

Classes

  • SafeStream
  • Overview
  • Namespace
  • Class
  • Tree
  • Other releases

Class SafeStream

Thread safe / atomic file manipulation. Stream safe://

file_put_contents('safe://myfile.txt', $content);

$content = file_get_contents('safe://myfile.txt');

unlink('safe://myfile.txt');
Final
Namespace: Nette\IO
Author: David Grudl
Located at Utils/SafeStream.php
Methods summary
public static boolean
# register( )

Registers protocol 'safe://'.

Registers protocol 'safe://'.

Returns

boolean
public boolean
# stream_open( string $path, string $mode, integer $options, string & $opened_path )

Opens file.

Opens file.

Parameters

$path
string
file name with stream protocol
$mode
string
mode - see fopen()
$options
integer
STREAM_USE_PATH, STREAM_REPORT_ERRORS
$opened_path
string
full path

Returns

boolean
TRUE on success or FALSE on failure
public
# stream_close( )

Closes file.

Closes file.

public string
# stream_read( integer $length )

Reads up to length bytes from the file.

Reads up to length bytes from the file.

Parameters

$length
integer
length

Returns

string
public integer
# stream_write( string $data )

Writes the string to the file.

Writes the string to the file.

Parameters

$data
string
data to write

Returns

integer
number of bytes that were successfully stored
public integer
# stream_tell( )

Returns the position of the file.

Returns the position of the file.

Returns

integer
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
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
integer
position
$whence
integer
see fseek()

Returns

integer
Return TRUE on success
public array
# stream_stat( )

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

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

Returns

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
string
file name
$flags
integer
STREAM_URL_STAT_LINK, STREAM_URL_STAT_QUIET

Returns

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
string
file name with stream protocol

Returns

boolean
TRUE on success or FALSE on failure
Constants summary
string PROTOCOL 'safe'
#

Name of stream protocol - safe://

Name of stream protocol - safe://

Nette Framework 0.9.7 API documentation generated by ApiGen 2.3.0