aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/filestore.php
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-23 17:19:07 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-23 17:19:07 +0000
commit00ba1e82ea439557764d17fab1ec11f4b2e58d07 (patch)
tree6829a635cf8011899544f3f785e9940dd31255bf /engine/lib/filestore.php
parentb1177c028d19aef4abd18e87ffdb398df0f6f24a (diff)
downloadelgg-00ba1e82ea439557764d17fab1ec11f4b2e58d07.tar.gz
elgg-00ba1e82ea439557764d17fab1ec11f4b2e58d07.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* 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
Diffstat (limited to 'engine/lib/filestore.php')
-rw-r--r--engine/lib/filestore.php25
1 files 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
@@ -72,6 +72,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.
*
@@ -361,6 +376,14 @@
}
/**
+ * Return the size of the file in bytes.
+ */
+ public function size()
+ {
+ return $this->filestore->getFileSize($this);
+ }
+
+ /**
* Set a filestore.
*
* @param ElggFilestore $filestore The file store.
@@ -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)