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 $directory
Go in the provided directory@return
bool 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 $path
The path to test in the filesystem@return
boolean true if RO access, false if not
/** External function allowed to be overloaded to test the RW access to a resource@param string $path
The path to test in the filesystem@return
boolean true if RW access, false if not
/** Change the group for a file/dir...@param string $filename
The file/directory to change@param mixed $group
The 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 $filename
The file/directory to change@param integer $mode
The 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 $filename
The file/directory to change@param mixed $user
The user name or user UID @throws If filename not exists, or the directory is not RW
/** Chroot in the provided directory@param string $directory
The directory to chroot@return
boolean 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 $oldname
The file to copy@param string $newname
The new name of the file. It will be overwrited if it already exists@return
bool
/** Get the file contents in an array (like 'file' function, but can not have the same name as the class...)@param string $filename
Name of the file to read@return
string 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 $filename
The file or directory to verify@return
bool true if the file exists, false otherwise @throws If parent directory not exists, or is not executable
/** Get the file contents@param string $filename
Name of the file to read@return
string 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 $filename
Path to the file where to write the data@param string|integer $data
The data to write@param integer|null $flags
The optional flags@return
integer 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 $filename
Path to the file@return
string the mimetype of the file @throws If parent directory not exists, is not writeable
/** Get the file modification time of a file@param string $filename
Path to the file@return
integer|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 $filename
Path to the file@return
integer|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 $pattern
The pattern to found@param integer|null $flags
The additional flags@return
array 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 $filename
The filename to test@return
bool 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 $filename
The filename to test@return
bool 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 $filename
The filename to test@return
bool 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 $filename
The filename to test@return
bool 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 $filename
The filename to test@return
bool 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 $filename
The file to lock@return
bool 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 $filename
The file to lock@return
bool 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 $filename
The file to lock@return
bool 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 $filename
The file to hash@return
string the calulated hash @throws If the file doesn't exists
/** Create a new directory@param string $pathname
The directory to create@param integer $mode
The mode to create (0777 by default)@param boolean $recursive
(false by default)@return
bool 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 $filename
The filename of the ini file being parsed. @param boolean $process_sections Process the sections@return
array
/** 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 $path
the path to analyze@return
string the canonical absolute path
/** Renames a file or directory@param string $oldname
The file or directory to rename@param string $newname
The new name of the file or directory. It will be overwrited if it already exists@return
bool
/** Remove the provided directory If the recurse flag is true, remove the content too (files and directories)@param string $dirname
The directory to remove@param boolean $recursive
Remove recursively@return
bool 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 $directory
The directory to read@return
array 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 $directory
The directory to read@return
array the list of files and dirs @throws If directory not exists, or is not executable
/** Calculate the sha1 sum of a file@param string $filename
The file to hash@return
string the calulated hash @throws If the file doesn't exists
/** Create a new file or update the timestamp if the file exists@param string $filename
the filename@param integer|null $time
the timestamp to use (actual timestamp if not defined)@param integer|null $atime
the access timestamp to use (actual timestamp if not defined)@return
bool true or false on failure @throws If parent directory not exists, is not writeable
/** Delete an existing file.@param string $filename
The filename to remove@return
bool true if the file si removed, false otherwise @throws If parent directory not exists, or is not executable