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');
	 
	
	
	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. Parameters
					$pathstringfile name with stream protocol
$modestringmode - see fopen()
$optionsintegerSTREAM_USE_PATH, STREAM_REPORT_ERRORS
$opened_pathstringfull path
Returns
					booleanTRUE 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. ParametersReturns
					string
 | 
	
		| 
			
			 public 
			integer
			
			 | 
		#
		stream_write( string $data )
			
Writes the string to the file. 
			
Writes the string to the file. Parameters
					$datastringdata to write
Returns
					integernumber 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
					$offsetintegerposition
$whenceintegersee fseek()
Returns
					integerReturn 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
					$pathstringfile name
$flagsintegerSTREAM_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
					$pathstringfile name with stream protocol
Returns
					booleanTRUE on success or FALSE on failure
 
 | 
	
	
	Constants summary
	
		| 
			
			string
		 | 
				PROTOCOL
		 | 'safe' | 
			#
			
				
Name of stream protocol - safe:// 
				
Name of stream protocol - safe:// |