From 00ba1e82ea439557764d17fab1ec11f4b2e58d07 Mon Sep 17 00:00:00 2001 From: icewing Date: Wed, 23 Apr 2008 17:19:07 +0000 Subject: Marcus Povey * Filesize support added, now possible to get all file contents with $file->read($file->size()); git-svn-id: https://code.elgg.org/elgg/trunk@512 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/filestore.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php index ba370d557..98cba7ade 100644 --- a/engine/lib/filestore.php +++ b/engine/lib/filestore.php @@ -71,6 +71,13 @@ */ abstract public function delete(ElggFile $file); + /** + * Return the size in bytes for a given file. + * + * @param ElggFile $file + */ + abstract public function getFileSize(ElggFile $file); + /** * Get the filestore's creation parameters as an associative array. * Used for serialisation and for storing the creation details along side a file object. @@ -167,6 +174,14 @@ return fseek($f, $position); } + public function getFileSize(ElggFile $file) + { + $name = $file->getFilename(); + $matrix = $this->make_file_matrix($name); + + return filesize($this->dir_root . $matrix . $name); + } + /** * Make the directory root. * @@ -360,6 +375,14 @@ return $fs->seek($this->handle, $position); } + /** + * Return the size of the file in bytes. + */ + public function size() + { + return $this->filestore->getFileSize($this); + } + /** * Set a filestore. * @@ -423,8 +446,6 @@ if (!parent::save()) return false; - // Get filestore if necessary - // Save datastore metadata $params = $this->filestore->getParameters(); foreach ($params as $k => $v) -- cgit v1.2.3