file : add fileinfoMimeType and filesize

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4178 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2018-03-27 11:33:22 +00:00
parent 4a681bf314
commit 83353fc53c

View File

@@ -226,6 +226,33 @@ class file
return filemtime ($filename); return filemtime ($filename);
} }
/** Get the file size
* @param string $filename Path to the file
* @return the size of the file or FALSE on failure.
* @throws If parent directory not exists, is not writeable
*/
public function filesize ($filename)
{
$this->debug (2, "filesize ($filename)");
$filename = $this->realpath ($filename);
$this->checkPathRO (dirname ($filename));
return filesize ($filename);
}
/** Get the file info of the provided filename
* @param string $filename Path to the file
* @return the mimetype of the file
* @throws If parent directory not exists, is not writeable
*/
public function fileinfoMimeType ($filename)
{
$this->debug (2, "filesize ($filename)");
$filename = $this->realpath ($filename);
$this->checkPathRO (dirname ($filename));
$finfo = new \finfo (FILEINFO_MIME_TYPE);
return $finfo->file ($filename);
}
/** Return the current working directory /** Return the current working directory
* @return string the current working directory */ * @return string the current working directory */
public function getcwd () public function getcwd ()