diff --git a/file.php b/file.php index 6bc5c19..642bc3a 100644 --- a/file.php +++ b/file.php @@ -226,6 +226,33 @@ class file 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 string the current working directory */ public function getcwd ()