Summary
- File
- Package hierarchy IO\Filesystem
- Class hierarchy \FileSystemElement \File
This class represents a text file which can be read and written.
This class represents a text file which can be read and written.
__construct(string $path)
Builds a File object.
string | $path | Path of the file you want to work with. |
None found |
exists() : boolean
Allows you to know if the file system element exists.
True if the file exists, else, false.
None found |
get_path() : string
Returns the element full path.
The element full path.
None found |
get_path_from_root() : string
Returns the element path from the phpboost root.
The element from the phpboost root.
None found |
get_name() : string
Returns the element name.
The element name.
None found |
is_writable(boolean $force_chmod = false) : true
Returns true if the file or the folder is writable.
boolean | $force_chmod | If true, then, chmod will be forced to 777 if not writable. |
if the file or the folder is writable.
None found |
change_chmod(integer $chmod) : true
Changes the chmod of the element.
integer | $chmod | The new chmod of the file. Put a 0 at the begening of the number to indicate to the PHP parser that it's an octal value. |
if the chmod has been successfully changed.
None found |
delete()
Deletes the file.
if the file cannot been deleted
None found |
__destruct()
None found |
get_name_without_extension() : string
Returns the element name without extension.
The element name without extension.
None found |
get_extension() : string
Returns the extension of the element.
Element extension.
None found |
read(integer $start, integer $len = -1) : string
Returns the content of the file.
integer | $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. |
integer | $len | Number of bytes you want to read. |
The read content.
None found |
read_lines() : array<mixed,string>
Returns the content of the file grouped by lines.
The list of the lines of the file.
None found |
write(string $data)
Writes some text in the file. Erases the file previous content
string | $data | The text you want to write in the file. |
If it's not possible to write the file
None found |
append(string $data)
Appends some text at the end of the file.
string | $data | The text you want to write in the file. |
If it's not possible to write the file
None found |
erase()
empty the file
None found |
close()
Closes a file and frees the allocated memory relative to the file.
None found |
lock(boolean $blocking = true)
boolean | $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). |
if the file cannot been locked
None found |
unlock()
Unlocks a file. The file must have been locked before you call this method.
if the file cannot been unlocked
None found |
flush()
Forces the system to write all the buffered output.
None found |
get_last_modification_date() : integer
Returns the date of the last modification of the file.
The UNIX timestamp corresponding to the last modification date.
None found |
get_last_access_date() : integer
Returns the last access date of the file.
The UNIX timestamp corresponding to the last access date of the file.
None found |
get_file_size() : integer
Returns the size of the file.
The size of the file in bytes.
None found |
get_formated_size(string $file_size) : string
Get file readable size.
string | $file_size | The size of the file in bytes. |
The size of the file in Kb or Mb or Gb.
None found |
open( $mode)
Opens the file. You cannot read or write a closed file, use this method to open it.
$mode |
If the file can neither been read nor created.
None found |
get_file_checksum(string $filename) : string
Get file checksum in sha256.
string | $filename | Path of the file you want to work with. |
The hash of the file in sha256.
None found |
is_open() : boolean
Allows you to know if the file is already open.
true if the file is open, false if it's closed.
None found |
write_data( $data)
$data |
None found |
check_file_descriptor( $message)
$message |
None found |
$path : string
None found |
$BUFFER_SIZE :
None found |
$contents : string
None found |
$mode : integer
None found |
$file_descriptor : \File
None found |