The cDirHandler class encapsules functionalities for dealing with directories.
Methods:
All provided functionalities are in a public static context.
Method name | Description | Example |
---|---|---|
chmod($dirname, $mode) | This method can be used to change directory permissions on a *nix system. Expected parameters:
Returns: bool | chmod('/var/www/test/',777); The call of the method above grants read, write and execute rights. |
create($pathname, $recursive = false) | This method can be used to create a new folder. Expected parameters:
Optional parameters:
Returns: bool | create('/var/www/test/'); The call of the method above create the new folder test. |
fileNameIsDot($fileName) | This method checks if the given filename is '.' or '..'. Expected parameters:
Returns: bool In my opinion this method should be transfered to the cFileHandler class, highly recommended! | fileNameIsDot('.'); The call of the method above returns true. |
isDirectoryEmpty($dir) | This method returns checks if the given directory is empty. Expected parameters:
Returns: bool | isDirectoryEmpty('/var/www/test'); The call of the method above returns true if the given directory exists, otherwise false. |
move($dirname, $destination) | This method can be used to move a folder to another location. Expected parameters:
Returns: bool | move('/var/www/test/','/var/www/test1/'); The call of the method above grants moves the folder test to folder test1. |
read($dirName, $recursive = false, $dirOnly = false) | This method reads the content from given directory. Expected parameters:
Optional parameters:
Returns: bool | read('/var/www/test/'); The call of the method above lists the content of the folder test. |
recursiveCopy($filename, $destination) | ||
recursiveRmdir($dirname) | This method deletes the given folder recursively, that means including all of its subfolders and files. Expected parameters:
Returns: bool | recursiveRmdir('/var/www/test/'); The call of the method above deletes the folder test recursively. |
remove($dirname) | This method removes the given directory from the filesystem. Expected parameters:
Returns: bool | remove('/var/www/test/'); The call of the method above deletes the folder test. |
rename($dirname, $new_dirname) | This method renames the given file from the filesystem. Expected parameters:
Returns: bool | rename('/var/www/test/','/var/www/test1/'); The call of the method above renames the folder test to test1. |
setDefaultDirPerms($dirname) | This method sets default permissions to the given directory Expected parameters:
Returns: bool | setDefaultDirPerms('/var/www/test/'); The call of the method sets the default permissions to the the given folder. |