diff options
| author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-21 14:30:27 +0000 | 
|---|---|---|
| committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-21 14:30:27 +0000 | 
| commit | 3b3c733cab12d2f87fc6cf5a2fd5693cf8b3fda8 (patch) | |
| tree | 177e081578f0653c21e0ecdaa3abff8663634126 | |
| parent | 923b8585734658a4eb4af089696b3ae718871c80 (diff) | |
| download | elgg-3b3c733cab12d2f87fc6cf5a2fd5693cf8b3fda8.tar.gz elgg-3b3c733cab12d2f87fc6cf5a2fd5693cf8b3fda8.tar.bz2  | |
Marcus Povey <marcus@dushka.co.uk>
* 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
| -rw-r--r-- | engine/lib/filestore.php | 24 | 
1 files changed, 15 insertions, 9 deletions
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;  		}  | 
