diff options
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/filestore.php | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php index 1fd292b83..293122586 100644 --- a/engine/lib/filestore.php +++ b/engine/lib/filestore.php @@ -72,6 +72,14 @@ * @return int */ abstract public function tell($f); +
+ /**
+ * Get the contents of the whole file.
+ *
+ * @param mixed $f The file handle.
+ * @return mixed The file contents.
+ */
+ abstract public function grabFile($f);
/** * Close a given file handle. @@ -191,8 +199,13 @@ } public function delete(ElggFile $file) - { - return unlink($this->getFilenameOnFilestore($file)); + {
+ $filename = $this->getFilenameOnFilestore($file);
+ if (file_exists($filename)) { + return unlink($filename);
+ } else {
+ return true;
+ } } public function seek($f, $position) @@ -225,6 +238,12 @@ return $this->dir_root . $this->make_file_matrix($owner->username) . $file->getFilename(); } +
+ public function grabFile(ElggFile $file) {
+
+ return file_get_contents($file->getFilenameOnFilestore());
+
+ }
/** * Make the directory root. @@ -418,6 +437,18 @@ return $fs->read($this->handle, $length, $offset); } +
+ /**
+ * Gets the full contents of this file.
+ *
+ * @return mixed The file contents.
+ */
+ public function grabFile() {
+
+ $fs = $this->getFilestore();
+ return $fs->grabFile($this);
+
+ }
/** * Close the file and commit changes |