cFileHandler
The cFileHandler class encapsules functionalities for dealing with files.
Â
Â
Methods:
All provided functionalities are in a public static context.
methodName | Description | Example |
---|---|---|
 chmod($filename, $mode) | This method can be used to change file permissions on a *nix system. Expected parameters:
| chmod('/var/www/index.php,777); The call of the method above grants read, write and execute rights. |
copy($filename, $destination) | This method copies a file to a given location. Existing files will be overwritten Expected parameters:
Returns: bool | copy('/var/www/index.php', '/var/www/index2.php'); The call of the method above copies the index.php file to the index2.php file. |
exists($filename) | This method checks if a file exists at the given location Expected parameters:
Returns: bool | exists('/var/www/index.php'); The call of the method above returns true if the 'var/www/index.php' file exists, otherwise false. |
fileNameIsDot($fileName) | This method checks if the given filename is '.' or '..'. Expected parameters:
Returns: bool | fileNameIsDot('.'); The call of the method above returns true. |
getExtension($basename) | This method returns the file extension of the given file Expected parameters:
Returns: string | getExtension('/var/www/index.php'); The call of the method above returns the string 'php'. |
info($filename) | This method returns information about the given file. The returing array includes the following information:
Expected parameters:
Returns: array | Â |
isDirectoryEmpty($dir) | This method was moved to cDirHandler class with version 4.9.3 and is deprecated now. | see cDirHandler |
move($filename, $destination) | This method changes the location of the given file Expected parameters:
Returns: bool | move('/var/www/index.php', '/var/www/test/index.php'); The call of the method above moves the index.php file from path '/var/www/' to '/var/www/test/'. Â |
read($filename, $length = 0, $offset = 0, $reverse = false) | This method reads bytes from the given file. Expected parameters:
Optional parameters:
Returns: bool | read('/var/www/index.php'); The call of the method above returns the content of the index.php file. |
readable($filename) | This method checks if the given file is readable. Expected parameters:
Returns: bool | readable('/var/www/index.php'); The call of the method above moves returns true if the index.php file is readable, otherwise false. |
readLine($filename, $lines = 0, $lineoffset = 0) | This method reads a line from the given file. Expected parameters:
Optional parameters:
Returns:
| readableLine('/var/www/index.php'); The call of the method above returns the first line of the content from the index.php file. |
recursiveCopy($filename, $destination) | This method was moved to cDirHandler class with version 4.9.3 and is deprecated now. | see cDirHandler |
recursiveRmdir($dirname) | This method was moved to cDirHandler class with version 4.9.3 and is deprecated now. | see cDirHandler |
remove($filename) | This method removes the given file from the filesystem. Expected parameters:
Returns: bool | remove('/var/www/index.php'); The call of the method above removes the index.php file. Â Â Â |
rename($filename, $new_filename) | This method renames the given file from the filesystem. Expected parameters:
Returns: bool | rename('/var/www/index.php','/var/www/index.html'); The call of the method above renames the index.php file to index.html. |
setDefaultDirPerms($pathname) | This method was moved to cDirHandler class with version 4.9.3 and is deprecated now. | see cDirHandler |
setDefaultFilePerms($filename) | This method sets default permissions to the given file Expected parameters:
Returns: bool | Â |
truncate($filename) | This method clears the content of the given file Expected parameters:
Returns: bool | truncate('/var/www/index.php'); The call of the method above removes the content of the index.php file. |
validateFilename($filename, $notifyAndExitOnFailure = true) | This method validates the filename of the given file with CONENTIDO standard. Expected parameters:
Optional parameters:
Returns: bool | Â |
write($filename, $content, $append = false) | This method writes data to the given file Expected parameters:
Optional parameters:
Returns: bool | write('/var/www/index.php','hello world!'); The call of the method above writes the string 'hello world!' in the index.php file. |
 writeable($filename) | This method checks if the given file is writeable Expected parameters:
Returns: bool | writeable('/var/www/index.php'); The call of the method above returns true if the index.php file is writeable, otherwise false. |
writeLine($filename, $content, $append = false) | This method writes a line to the given file Expected parameters:
Optional parameters:
Returns: bool | writeLine('/var/www/index.php','hello world!'); The call of the method above returns writes the line 'hello world!' to the index.php file. |