From 6a8eb8ba9317546b9e89b2c68fb6322b8c3bc00d Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 8 Oct 2008 12:42:31 +0000 Subject: Minor optimisations. Introducing exists() on filestores git-svn-id: https://code.elgg.org/elgg/trunk@2222 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/filestore.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'engine/lib/filestore.php') diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php index daed925f5..94ab26594 100644 --- a/engine/lib/filestore.php +++ b/engine/lib/filestore.php @@ -117,10 +117,17 @@ /** * Get the contents of the whole file. * - * @param mixed $f The file handle. + * @param mixed $file The file handle. * @return mixed The file contents. */ - abstract public function grabFile(ElggFile $file); + abstract public function grabFile(ElggFile $file); + + /** + * Return whether a file physically exists or not. + * + * @param ElggFile $file + */ + abstract public function exists(ElggFile $file); } @@ -243,6 +250,11 @@ return file_get_contents($file->getFilenameOnFilestore()); + } + + public function exists(ElggFile $file) + { + return file_exists($this->getFilenameOnFilestore($file)); } /** @@ -556,6 +568,13 @@ return $fs->eof($this->handle); } + public function exists() + { + $fs = $this->getFilestore(); + + return $fs->exists($this); + } + /** * Set a filestore. * -- cgit v1.2.3