From 83353fc53c88e500db3101cc1d27514a1180f2aa Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Tue, 27 Mar 2018 11:33:22 +0000 Subject: [PATCH] file : add fileinfoMimeType and filesize git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4178 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- file.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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 ()