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)
// type: object
\MVC\DataType\DTFileinfo::__set_state(array(
'dirname' => '/var/www/htdocs/Emvicy/modules/Foo/Controller',
'basename' => 'Index.php',
'path' => '/var/www/htdocs/Emvicy/modules/Foo/Controller/Index.php',
'is_file' => true,
'is_dir' => false,
'extension' => 'php',
'filename' => 'Index',
'name' => 'admin1',
'passwd' => 'x',
'uid' => 1000,
'gid' => 1000,
'gecos' => 'admin1,,,',
'dir' => '/var/www',
'shell' => '/bin/bash',
'filemtime' => 1703679863,
'filectime' => 1703679863,
'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'