The file module allow the same functions as PHP file section, but allow to chroot the commands in a jail, event if the possibilty is not offered by the system.
Each command test if the user have the right to execute any parent directory and generate an exception if the user don't have the right to do an action on the filesystem.
Namespace Domframework
/** The file method allow to manage files like PHP with a working chroot on all plateforms, and a right management compatible with database Don't follow links ! To allow an external authorization test in plus of the filesystem check, you must extends the class and overload checkExternalPathRO and checkExternalPathRW.
/** Activate the debug and define the minimum priority to save
/** Change the current working directory@param string $directoryGo in the provided directory@returnbool true if the directory is changed @throws If directory not exists, or the directory is not executable
/** External function allowed to be overloaded to test the RO access to a resource@param string $pathThe path to test in the filesystem@returnboolean true if RO access, false if not
/** External function allowed to be overloaded to test the RW access to a resource@param string $pathThe path to test in the filesystem@returnboolean true if RW access, false if not
/** Change the group for a file/dir...@param string $filenameThe file/directory to change@param mixed $groupThe group name or group GID @throws If filename not exists, or the directory is not RW
/** Change the rights mode for a file/dir...@param string $filenameThe file/directory to change@param integer $modeThe mode to use for the filename @throws If filename not exists, or the directory is not RW
/** Change the owner for a file/dir...@param string $filenameThe file/directory to change@param mixed $userThe user name or user UID @throws If filename not exists, or the directory is not RW
/** Chroot in the provided directory@param string $directoryThe directory to chroot@returnboolean true if the chroot is done, false if there is a failure @throws If directory not exists, or the directory is not executable
/** Copy a file or a directory@param string $oldnameThe file to copy@param string $newnameThe new name of the file. It will be overwrited if it already exists@returnbool
/** Get the file contents in an array (like 'file' function, but can not have the same name as the class...)@param string $filenameName of the file to read@returnstring Content of the file @throws If parent directory not exists, is not readable, the file is not exists or is not readable
/** Checks whether a file or directory exists@param string $filenameThe file or directory to verify@returnbool true if the file exists, false otherwise @throws If parent directory not exists, or is not executable
/** Get the file contents@param string $filenameName of the file to read@returnstring Content of the file @throws If parent directory not exists, is not readable, the file is not exists or is not readable
/** Write a string to a file@param string $filenamePath to the file where to write the data@param string|integer $dataThe data to write@param integer|null $flagsThe optional flags@returninteger the length of the data stored @throws If parent directory not exists, is not writeable, or the file exists and is not writeable
/** Get the file info of the provided filename@param string $filenamePath to the file@returnstring the mimetype of the file @throws If parent directory not exists, is not writeable
/** Get the file modification time of a file@param string $filenamePath to the file@returninteger|boolean the time the file was last modified, or FALSE on failure. The time is returned as a Unix timestamp, which is suitable for the date() function. @throws If parent directory not exists, is not writeable
/** Get the file size@param string $filenamePath to the file@returninteger|boolean the size of the file or FALSE on failure. @throws If parent directory not exists, is not writeable
/**
Return the current working directory
@return string the current working directory
/** Find pathnames matching a pattern If there is some unreadable files, skip them quietly@param string $patternThe pattern to found@param integer|null $flagsThe additional flags@returnarray Return an array if there is an error @throws If parent directory not exists, or is not executable or if there is one file unreadable
/** Tells whether the given filename is a directory@param string $filenameThe filename to test@returnbool true if the $filename is a directory and exists, false otherwise @throws If parent directory not exists, or is not executable
/** Tells whether a file exists and is executable@param string $filenameThe filename to test@returnbool true if the $filename is a file exists and is writeable @throws If parent directory not exists, or is not executable
/** Tells whether the given filename is a valid file@param string $filenameThe filename to test@returnbool true if the $filename is a file and exists, false otherwise @throws If parent directory not exists, or is not executable
/** Tells whether a file exists and is readable@param string $filenameThe filename to test@returnbool true if the $filename is a file exists and is readable @throws If parent directory not exists, or is not executable
/** Tells whether a file exists and is writeable@param string $filenameThe filename to test@returnbool true if the $filename is a file exists and is writeable @throws If parent directory not exists, or is not executable
/** Lock a file exclusively@param string $filenameThe file to lock@returnbool true if the lock is acquired, false otherwise @throws If parent directory not exists, or is not writeable
/** Lock a file shared (allow multiple read)@param string $filenameThe file to lock@returnbool true if the lock is acquired, false otherwise @throws If parent directory not exists, or is not writeable
/** Unlock a file previously locked@param string $filenameThe file to lock@returnbool true if the lock is acquired, false otherwise @throws If parent directory not exists, or is not writeable
/** Calculate the md5 sum of a file@param string $filenameThe file to hash@returnstring the calulated hash @throws If the file doesn't exists
/** Create a new directory@param string $pathnameThe directory to create@param integer $modeThe mode to create (0777 by default)@param boolean $recursive(false by default)@returnbool true if the directory is correctely created, false if the directory already exists @throws If parent directory not exists, is not writeable
/** Return a ini file converted to an array@param string $filenameThe filename of the ini file being parsed. @param boolean $process_sections Process the sections@returnarray
/** Return the canonical absolute path. Do not check if the directory exists, if there is links. Just calculate the realpath based on the chroot value@param string $paththe path to analyze@returnstring the canonical absolute path
/** Renames a file or directory@param string $oldnameThe file or directory to rename@param string $newnameThe new name of the file or directory. It will be overwrited if it already exists@returnbool
/** Remove the provided directory If the recurse flag is true, remove the content too (files and directories)@param string $dirnameThe directory to remove@param boolean $recursiveRemove recursively@returnbool true if all is removed, false otherwise @throws If parent directory not exists, is not writeable or the current dir is not writeable
/** Return the list of files and directories in the directory. Do not return the . and .. virtual dirs. The result is sorted@param string $directoryThe directory to read@returnarray the list of files and dirs @throws If directory not exists, or is not executable
/** Return the list of files and directories in the directory. Do not return the . and .. virtual dirs. The result is NOT sorted@param string $directoryThe directory to read@returnarray the list of files and dirs @throws If directory not exists, or is not executable
/** Calculate the sha1 sum of a file@param string $filenameThe file to hash@returnstring the calulated hash @throws If the file doesn't exists
/** Create a new file or update the timestamp if the file exists@param string $filenamethe filename@param integer|null $timethe timestamp to use (actual timestamp if not defined)@param integer|null $atimethe access timestamp to use (actual timestamp if not defined)@returnbool true or false on failure @throws If parent directory not exists, is not writeable
/** Delete an existing file.@param string $filenameThe filename to remove@returnbool true if the file si removed, false otherwise @throws If parent directory not exists, or is not executable