Methods summary
public
|
#
__construct( string $path, integer $mode,…, boolean $whenopen,… )
Builds a File object.
Parameters
- $path
- Path of the file you want to work with.
- $mode,…
- If you want to open it only to read it, use the flag File::READ, if it's to write it use the File::WRITE flag, you also can use the File::READ_WRITE flag.
- $whenopen,…
- If you want to open the file now, use the File::DIRECT_OPENING constant, if you want to open it only when you will need it, use the File::LAZY_OPENING constant.
Overrides
|
public
|
|
public
string
|
#
get_name_without_extension( )
Returns the element name without extension.
Returns the element name without extension.
Returns
string The element name without extension.
|
public
string
|
#
get_extension( )
Returns the extension of the element.
Returns the extension of the element.
Returns
string Element extension.
|
public
string
|
#
read( integer $start = 0, integer $len = -1 )
Returns the content of the file.
Returns the content of the file.
Parameters
- $start
- Byte from which you want to start. 0 if you want to read the file from its begening, 1 to start with the second etc.
- $len
- Number of bytes you want to read.
Returns
string The read content.
|
public
string[]
|
#
read_lines( )
Returns the content of the file grouped by lines.
Returns the content of the file grouped by lines.
Returns
string[] The list of the lines of the file.
|
public
|
#
write( string $data )
Writes some text in the file. Erases the file previous content
Writes some text in the file. Erases the file previous content
Parameters
- $data
- The text you want to write in the file.
Throws
|
public
|
#
append( string $data )
Appends some text at the end of the file.
Appends some text at the end of the file.
Parameters
- $data
- The text you want to write in the file.
Throws
|
public
|
|
public
|
#
close( )
Closes a file and frees the allocated memory relative to the file.
Closes a file and frees the allocated memory relative to the file.
|
public
|
|
public
|
#
lock( boolean $blocking = true )
Parameters
- $blocking
if true, block the script, if false, non blocking operation
Locks the file (it won't be readable by another thread which could try to access it).
Throws
|
public
|
#
unlock( )
Unlocks a file. The file must have been locked before you call this method.
Unlocks a file. The file must have been locked before you call this method.
Throws
|
public
|
#
flush( )
Forces the system to write all the buffered output.
Forces the system to write all the buffered output.
|
public
integer
|
#
get_last_modification_date( )
Returns the date of the last modification of the file.
Returns the date of the last modification of the file.
Returns
integer The UNIX timestamp corresponding to the last modification date.
|
public
integer
|
#
get_last_access_date( )
Returns the last access date of the file.
Returns the last access date of the file.
Returns
integer The UNIX timestamp corresponding to the last access date of the file.
|
public
integer
|
#
get_file_size( )
Returns the size of the file.
Returns the size of the file.
Returns
integer The size of the file in bytes.
|
public
|
#
open( $mode )
Opens the file. You cannot read or write a closed file, use this method to open it.
Opens the file. You cannot read or write a closed file, use this method to open it.
Throws
IOException If the file can neither been read nor created.
|
public static
string
|
#
get_file_checksum( string $filename )
Get file checksum in sha256.
Get file checksum in sha256.
Parameters
- $filename
- Path of the file you want to work with.
Returns
string The hash of the file in sha256.
|