function chmodFile Try to chmod a file (a dir is redirected to makeExecutable method).
static boolean
chmodFile
( $right, $file, string $right,, string $file,)
-
string
$right,: the 3 or 4 octal numbers to set (775, 664, 0664, etc.)
-
string
$file,: the full filename of the file or dir
-
$right
-
$file
function copyTo
Try to copy a file (and create all parents if needed)
static boolean
copyTo
( $from, $to, string $from,, string $to,)
-
string
$from,: the full filename of the file to copy
-
string
$to,: the full filename of the file copied
-
$from
-
$to
function deleteFile
Delete a file or folder (recursively)
static boolean
deleteFile
( $file, string $file,)
-
string
$file,: the full filename of the file or dir
-
$file
function deltree (rm -rf)
Delete a directory and all subdirectories and files (recursively)
static boolean
deltree
( $dir, [ $withDir = false], string $file,, boolean $withDir,)
-
string
$file,: the full filename of the file or dir
-
boolean
$withDir,: delete also the dir $file
-
$dir
-
$withDir
function deltreeSimulation (rm -rf)
Simulate the delete a directory and all subdirectories and files (recursively)
static boolean
deltreeSimulation
( $dir, [ $withDir = false], string $file,, boolean $withDir,)
-
string
$file,: the full filename of the file or dir
-
boolean
$withDir,: delete also the dir $file
-
$dir
-
$withDir
Send the current file for download (inline or attachment)
static void
download
([boolean $inline = true], [boolean $deleteFile = false], [mixed $forceContentType = false])
-
boolean
$inline: : the file is sent inline (default) or as attachment
-
boolean
$deleteFile: : delete the sended file at end of download (default : false)
-
mixed
$forceContentType: : false to auto get the mime type to send, or string to force a mime type
Send a given file for download (inline or attachment)
static void
downloadFile
(string $source, [boolean $inline = true], [boolean $deleteFile = false], [mixed $forceContentType = false])
-
string
$source: : the file to download (FS relative)
-
boolean
$inline: : the file is sent inline (default) or as attachment
-
boolean
$deleteFile: : delete the sended file at end of download (default : false)
-
mixed
$forceContentType: : false to auto get the mime type to send, or string to force a mime type
function fileIsExecutable
Is file or dir executable (this function exists because php function is_executable does not work on directories)
static boolean
fileIsExecutable
( $f, string $f,)
-
string
$f,: the full filename of the file or dir
-
$f
function getFileList
Get an entire listing of files
static array
getFileList
( $file, string $file,)
-
string
$file,: the full filename of the file to get
-
$file
function getFilePerms
get current file permissions
static octal
getFilePerms
( $file, [ $type = "octal"], string $file,, string $type,)
-
string
$file,: the full filename of the file or dir
-
string
$type,: type of the return : octal value or decimal value
-
$file
-
$type
return the max uploadable file size
static string
getMaxUploadFileSize
([string $unit = 'M'])
-
string
$unit: : the unit to return the value, accept 'M' or 'K' (default : 'M')
function getParent
Get the first parent dir who exists of a file
static string
getParent
( $file, string $file,)
-
string
$file,: the full filename of the file to get
-
$file
get temporary path
static string
getTmpPath
()
Gzip a given file into another given file
static boolean
gzipfile
(string $source, string $dest, [integer $level = 6])
-
string
$source: : the file to gzip (FS relative)
-
string
$dest: : the destination file gzipped (FS relative)
-
integer
$level: : the level of compression to apply (0 to 9, default 6)
function isDeletable
is file deletable ?
static boolean
isDeletable
( $f, string $file,)
-
string
$file,: the full filename of the file or dir
-
$f
function makeDir
Try to create a dir (and all parents if needed)
static boolean
makeDir
( $f, string $f,)
-
string
$f,: the full filename of the file or dir
-
$f
function makeExecutable Try to make a file executable if it's not the case On windows platform, this function always return true.
static boolean
makeExecutable
( $f, string $f,)
-
string
$f,: the full filename of the file or dir
-
$f
function makeReadable
Try to make a file readable if it's not the case (and executable for a dir)
static boolean
makeReadable
( $f, string $f,)
-
string
$f,: the full filename of the file or dir
-
$f
function makeWritable
Try to make a file writable if it's not the case (and executable for a dir)
static boolean
makeWritable
( $f, string $f,)
-
string
$f,: the full filename of the file or dir
-
$f
get mime type of a given file
static string
mimeContentType
([string $file = ''])
-
string
$file: : the file location to get mime type (relative to FS) or none to use method on current object
function moveTo
Try to move a file (and create all parents if needed)
static boolean
moveTo
( $from, $to, string $from,, string $to,)
-
string
$from,: the full filename of the file to move
-
string
$to,: the full filename of the file moved
-
$from
-
$to
Send a group of files to client (ie : JS or CSS files) Provide coherent user caching infos (1 month) for files and allow gzip when possible
static void
sendFiles
(array $files, [string $contentType = 'text/html'])
-
array
$files: : array of files path to send to client (FS relative)
-
string
$contentType: : the content type to send to client (default : text/html)
Constructor
void
__construct
( $name, [ $from = self::FILE_SYSTEM], [ $type = self::TYPE_FILE], string $name,, integer $from,, integer $type,)
-
string
$name,: the full filename of the file or dir
-
integer
$from,: the file path is : self::FILE_SYSTEM or self::WEBROOT
-
integer
$type,: the type of the current object : self::TYPE_FILE for a file, self::TYPE_DIRECTORY for a dir, false for undefined
-
$name
-
$from
-
$type
Redefined in descendants as:
Check a file to avoid upload threat
boolean
checkUploadedFile
()
function chmod Try to chmod this file / directory.
boolean
chmod
( $right, string $right,)
-
string
$right,: the 3 or 4 octal numbers to set (775, 664, 0664, etc.)
-
$right
function delete
Delete the file or folder (recursively)
boolean
delete
()
Gets the FS existence status of the file
boolean
exists
()
Get the content of the file as string
string
getContent
()
Get the file extension if any (lowercase)
string
getExtension
()
Get the file icon if any
string
getFileIcon
([ $from = self::FILE_SYSTEM], integer $from,)
-
integer
$from,: the file path is : self::FILE_SYSTEM or self::WEBROOT (default : file system)
-
$from
Get the full filesystem filename of the file or dir
string
getFilename
([ $withPath = true])
Get the file path
string
getFilePath
([ $from = self::FILE_SYSTEM], integer $from,)
-
integer
$from,: the file path is : self::FILE_SYSTEM or self::WEBROOT (default : file system)
-
$from
Get the file size
string
getFileSize
([string $unit = false])
-
string
$unit: : the unit to return the value, accept 'M', 'K', '' or false to get the better one (default : false)
Alias of getFilename
string
getName
([ $withPath = true])
Read the content of the file
string/array
readContent
([string $returnAs = "string"], [string $array_map_function = "trim"], [array $csvargs = array('delimiter' => ';', 'enclosure' => '"', 'strict' => true)])
-
string
$returnAs: : the content format to get : string / array (array of lines) / csv (explode csv file) if requested file is a directory then return the content of the directory (always array in this case)
-
string
$array_map_function: : the function to apply at all the content (only for a file content returned as an array). trim by default.
-
array
$csvargs: : only for csv format : the csv file delimiter and enclosure chars (default : array('delimiter' => ';', 'enclosure' => '"', 'strict' => true))
Set the content of the file
boolean
setContent
(string/array $content, [ $allowSetBlank = false])
-
string/array
$content: : the content to set
-
$allowSetBlank
Upload a file with as much as security we can
array
uploadFile
([ $fileVarName = 'Filedata'], [ $destinationDirFS = PATH_UPLOAD_FS], string $fileVarName,, string $destinationDirFS,)
-
string
$fileVarName,: var name in which we can found the file in $_FILES
-
string
$destinationDirFS,: the destination dir in which we want the file to be moved
-
$fileVarName
-
$destinationDirFS
Writes the file into persistence (FS)
boolean
writeToPersistence
([boolean $allowWriteBlank = false], [boolean $createFolder = false])
-
boolean
$allowWriteBlank: : allow write of an empty file (default false)
-
boolean
$createFolder: : allow the creation of file folder if not exists (default : false)
Inherited Methods
Inherited From CMS_grandFather
CMS_grandFather::autoload()
CMS_grandFather::hasError()
CMS_grandFather::log()
CMS_grandFather::PHPErrorHandler()
CMS_grandFather::raiseError()
CMS_grandFather::setDebug()
CMS_grandFather::setLog()
CMS_grandFather::_raiseError()
CMS_grandFather::__call()