aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)