File
info
get infos about a file via stat
, posix_getpwuid
, pathinfo
.
info(string $sFilePathAbs = '') : DTFileinfo
Example
$oDTFileinfo = File::info(__FILE__);
return Datatype object $oDTFileinfo
(see DTFileinfo)
MVC\DataType\DTFileinfo {#91 ▼
#dirname: "/var/www/html/modules/Foo/Controller"
#basename: "Index.php"
#path: "/var/www/html/modules/Foo/Controller/Index.php"
#is_file: true
#is_dir: false
#extension: "php"
#filename: "Index"
#name: "admin1"
#passwd: "x"
#uid: 1000
#gid: 1000
#filemtime: 1739435042
#filectime: 1739435042
#filesize: 7562
#gecos: ""
#dir: "/home/admin1"
#shell: "/bin/bash"
#mimetype: "text/x-php"
}
Example: get Extension
$sExtension = File::info(__FILE__)->get_extension();
Result
php
getMimeType
returns mimetype of a given file.
getMimeType(string $sFileAbsolute = '') : string
Example
$sMimeType = File::getMimeType(__FILE__);
Result
// type: string
'text/x-php'
secureFilePath
removes doubleDot+Slashes (../) from string, replaces multiple forwardSlashes (//) from string by a single forwardSlash.
secureFilePath(string $sAbsoluteFilePath = '', bool $bIgnoreProtocols = false) : string
Example
$sPath = File::secureFilePath('../../../../../../../../../../../var/www/htdocs/../../..////////Emvicy/modules/Foo/Controller/Index.php');
Result
// type: string
'var/www/htdocs/Emvicy/modules/Foo/Controller/Index.php'