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');
public static
bool
|
#
register(
)
Registers protocol ‚safe://‘. Registers protocol ‚safe://‘. |
public
bool
|
#
stream_open(
string
$path,
string
$mode,
int
$options,
string
& $opened_path
)
Opens file. Opens file. Parameters$path string file name with stream protocol$mode string mode - see fopen()$options int STREAM_USE_PATH, STREAM_REPORT_ERRORS$opened_path string full pathReturnsbool TRUE on success or FALSE on failure
|
public
void
|
#
stream_close(
)
Closes file. Closes file. |
public
string
|
#
stream_read(
int
$length
)
Reads up to length bytes from the file. Reads up to length bytes from the file. Parameters$length int length |
public
int
|
#
stream_write(
string
$data
)
Writes the string to the file. Writes the string to the file. Parameters$data string data to writeReturnsint number of bytes that were successfully stored
|
public
int
|
#
stream_tell(
)
Returns the position of the file. Returns the position of the file. |
public
bool
|
#
stream_eof(
)
Returns TRUE if the file pointer is at end-of-file. Returns TRUE if the file pointer is at end-of-file. |
public
int
|
#
stream_seek(
int
$offset,
int
$whence
)
Sets the file position indicator for the file. Sets the file position indicator for the file. Parameters$offset int position$whence int see fseek()Returnsint 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. |
public
array
|
#
url_stat(
string
$path,
int
$flags
)
Gets information about a file referenced by filename. Gets information about a file referenced by filename. Parameters$path string file name$flags int STREAM_URL_STAT_LINK, STREAM_URL_STAT_QUIET |
public
bool
|
#
unlink(
string
$path
)
Deletes a file. Deletes a file. On Windows unlink is not allowed till file is opened Parameters$path string file name with stream protocolReturnsbool TRUE on success or FALSE on failure
|
PROTOCOL |
'safe' # |