From 3b3c733cab12d2f87fc6cf5a2fd5693cf8b3fda8 Mon Sep 17 00:00:00 2001 From: icewing Date: Mon, 21 Apr 2008 14:30:27 +0000 Subject: Marcus Povey * Save and Load (read/write) work * TODO: Loaded can not be loaded via name, only guid... correct? git-svn-id: https://code.elgg.org/elgg/trunk@501 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/filestore.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php index 7ad82b31a..d4a53f1c9 100644 --- a/engine/lib/filestore.php +++ b/engine/lib/filestore.php @@ -115,12 +115,12 @@ public function open(ElggFile $file, $mode) { - // Try and create the directory - try { $this->make_directory_root($this->dir_root); } catch (Exception $e){} - $name = $file->getFilename(); $matrix = $this->make_file_matrix($name); + // Try and create the directory + try { $this->make_directory_root($this->dir_root . $matrix); } catch (Exception $e){} + switch ($mode) { case "read" : $mode = "r+b"; break; @@ -174,7 +174,7 @@ */ protected function make_directory_root($dirroot) { - if (!mkdir($dir, 0700, true)) + if (!@mkdir($dirroot, 0700, true)) throw new IOException("Could not make $dirroot"); return true; @@ -189,12 +189,12 @@ { $matrix = ""; - $len = strlen($ident); + $len = strlen($filename); if ($len>$this->matrix_depth) $len = $this->matrix_depth; - for ($n = 0; $n < strlen($ident); $n++) - $matrix .= $ident[$n] . "/"; + for ($n = 0; $n < $len; $n++) + $matrix .= $filename[$n] . "/"; return $matrix; } @@ -247,12 +247,12 @@ * * @param string $name The filename. */ - public function setFilename($name) { $this->name = $name; } + public function setFilename($name) { $this->title = $name; } /** * Return the filename. */ - public function getFilename() { return $this->name; } + public function getFilename() { return $this->title; } /** * Set the optional file description. @@ -270,6 +270,9 @@ { if (!$this->name) throw new IOException("You must specify a name before opening a file."); + + // See if file has already been saved + // seek on datastore, parameters and name // Sanity check if ( @@ -423,6 +426,9 @@ foreach ($params as $k => $v) $this->setMetaData("filestore::$k", $v); + // Now make a note of the filestore class + $this->setMetaData("filestore::filestore", get_class($this)); + return true; } -- cgit v1.2.3