M_READ_EXISTING_BEGIN
M_READ_EXISTING_BEGIN
Open for reading only; place the file pointer at the beginning of the file.
Object-oriented file handler
M_WRITE_NONEXIST_BEGIN
Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
M_WRITE_BEGIN
Open the file for writing only. If the file does not exist, it is created.
If it exists, it is neither truncated (as opposed to M_WRITE_TRUNCATE_BEGIN), nor the call to this function fails (as is the case with M_WRITE_NONEXIST_BEGIN). The file pointer is positioned on the beginning of the file. This may be useful if it's desired to get an advisory lock (see flock()) before attempting to modify the file, as using M_WRITE_NONEXIST_BEGIN could truncate the file before the lock was obtained (if truncation is desired, ftruncate() can be used after the lock is requested).
get_extension(string $filename, integer $depth = 1, boolean $only_that_member = false) : string
Gets the file extension based on name
string | $filename | The file name |
integer | $depth | The depth to search for, e.g. if the file name is foo.tar.gz, depth=1 would return "gz" while depth=2 would return .tar.gz |
boolean | $only_that_member | Only effective if $depth > 1. If FALSE and the extension is tar.gz, will return "tar.gz", if TRUE, will return "tar". |
getExtension(integer $depth = 1, boolean $only_that_member = false) : string
Gets the file extension based on the currently set filename
integer | $depth | The depth to search for, e.g. if the file name is foo.tar.gz, depth=1 would return "gz" while depth=2 would return .tar.gz |
boolean | $only_that_member | Only effective if $depth > 1. If FALSE and the extension is tar.gz, will return "tar.gz", if TRUE, will return "tar". |
write() : \Alo\File
Overwrites the file contents on the disc
name(string $name = '') : \Alo\File|string
If no argument is passed, gets the file name, otherwise sets it
string | $name | The name |
When the name is invalid
dir(string $dir = '') : \Alo\File|string
If no argument is passed, gets the directory name, otherwise sets it
string | $dir | The directory |
When the name is invalid
content(string $content = '~none~') : \Alo\File|string
If no argument is passed, gets the currently set content, otherwise sets it
string | $content | Content to set |
When content is not scalar
clearContent() : \Alo\File
Clears the file content
addContent(string $c) : \Alo\File
Appends the file content
string | $c | The content |
doWrite(string $mode) : \Alo\File
Performs a write operation
string | $mode | The write mode - see class constants |
When fopen fails
checkParams() : \Alo\File
Checks if the dir and name are set
When the file path is not set
updatePath() : \Alo\File
Updates the file path when the directory or file name are changed