summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-09-07 18:30:48 +0200
committerRobin Appelman <icewind@owncloud.com>2012-09-07 18:30:48 +0200
commitbd834220959bf7edcc4cce4bfe6c77e0a4649b8b (patch)
tree6bf7987e57de953924f47f06b3018f14e0807934 /lib
parentedcd29747692ff1ffbec927b9f31ac239c5e192d (diff)
downloadnextcloud-server-bd834220959bf7edcc4cce4bfe6c77e0a4649b8b.tar.gz
nextcloud-server-bd834220959bf7edcc4cce4bfe6c77e0a4649b8b.zip
put filestorages in a namespace
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php3
-rw-r--r--lib/files/storage/common.php (renamed from lib/filestorage/common.php)44
-rw-r--r--lib/files/storage/commontest.php (renamed from lib/filestorage/commontest.php)10
-rw-r--r--lib/files/storage/local.php (renamed from lib/filestorage/local.php)17
-rw-r--r--lib/files/storage/storage.php (renamed from lib/filestorage.php)28
-rw-r--r--lib/files/storage/temporary.php26
-rw-r--r--lib/filestorage/temporary.php17
-rw-r--r--lib/filesystem.php12
-rw-r--r--lib/filesystemview.php12
-rwxr-xr-xlib/util.php4
10 files changed, 86 insertions, 87 deletions
diff --git a/lib/base.php b/lib/base.php
index 1c6cc70b0e8..3b2ab8d5ebe 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -81,6 +81,9 @@ class OC{
elseif(strpos($className, 'OC_')===0) {
$path = strtolower(str_replace('_', '/', substr($className, 3)) . '.php');
}
+ elseif(strpos($className, 'OC\\')===0) {
+ $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
+ }
elseif(strpos($className, 'OCP\\')===0) {
$path = 'public/'.strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
}
diff --git a/lib/filestorage/common.php b/lib/files/storage/common.php
index 351714437c5..0a60ff757eb 100644
--- a/lib/filestorage/common.php
+++ b/lib/files/storage/common.php
@@ -1,38 +1,26 @@
<?php
-
/**
-* ownCloud
-*
-* @author Michael Gapczynski
-* @copyright 2012 Michael Gapczynski GapczynskiM@gmail.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
+ * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files\Storage;
/**
* Storage backend class for providing common filesystem operation methods
* which are not storage-backend specific.
*
- * OC_Filestorage_Common is never used directly; it is extended by all other
+ * \OC\Files\Storage\Common is never used directly; it is extended by all other
* storage backends, where its methods may be overridden, and additional
* (backend-specific) methods are defined.
*
- * Some OC_Filestorage_Common methods call functions which are first defined
+ * Some \OC\Files\Storage\Common methods call functions which are first defined
* in classes which extend it, e.g. $this->stat() .
*/
-abstract class OC_Filestorage_Common extends OC_Filestorage {
+abstract class Common extends \OC\Files\Storage\Storage {
public function __construct($parameters) {}
// abstract public function mkdir($path);
@@ -104,7 +92,7 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
public function copy($path1,$path2) {
$source=$this->fopen($path1,'r');
$target=$this->fopen($path2,'w');
- $count=OC_Helper::streamCopy($source,$target);
+ $count=\OC_Helper::streamCopy($source,$target);
return $count>0;
}
// abstract public function fopen($path,$mode);
@@ -198,9 +186,9 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
}else{
$extension='';
}
- $tmpFile=OC_Helper::tmpFile($extension);
+ $tmpFile=\OC_Helper::tmpFile($extension);
file_put_contents($tmpFile,$head);
- $mime=OC_Helper::getMimeType($tmpFile);
+ $mime=\OC_Helper::getMimeType($tmpFile);
unlink($tmpFile);
return $mime;
}
@@ -227,13 +215,13 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
}else{
$extension='';
}
- $tmpFile=OC_Helper::tmpFile($extension);
+ $tmpFile=\OC_Helper::tmpFile($extension);
$target=fopen($tmpFile,'w');
- OC_Helper::streamCopy($source,$target);
+ \OC_Helper::streamCopy($source,$target);
return $tmpFile;
}
public function getLocalFolder($path) {
- $baseDir=OC_Helper::tmpFolder();
+ $baseDir=\OC_Helper::tmpFolder();
$this->addLocalFolder($path,$baseDir);
return $baseDir;
}
diff --git a/lib/filestorage/commontest.php b/lib/files/storage/commontest.php
index b88bb232c36..773bfffcb49 100644
--- a/lib/filestorage/commontest.php
+++ b/lib/files/storage/commontest.php
@@ -22,18 +22,20 @@
*/
/**
- * test implementation for OC_FileStorage_Common with OC_FileStorage_Local
+ * test implementation for \OC\Files\Storage\Common with \OC\Files\Storage\Local
*/
-class OC_Filestorage_CommonTest extends OC_Filestorage_Common{
+namespace OC\Files\Storage;
+
+class CommonTest extends \OC\Files\Storage\Common{
/**
* underlying local storage used for missing functions
- * @var OC_FileStorage_Local
+ * @var \OC\Files\Storage\Local
*/
private $storage;
public function __construct($params) {
- $this->storage=new OC_Filestorage_Local($params);
+ $this->storage=new \OC\Files\Storage\Local($params);
}
public function mkdir($path) {
diff --git a/lib/filestorage/local.php b/lib/files/storage/local.php
index e26d3d3ef91..e47441499a1 100644
--- a/lib/filestorage/local.php
+++ b/lib/files/storage/local.php
@@ -1,8 +1,17 @@
<?php
/**
+ * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files\Storage;
+
+/**
* for local filestore, we only have to map the paths
*/
-class OC_Filestorage_Local extends OC_Filestorage_Common{
+class Local extends \OC\Files\Storage\Common{
protected $datadir;
public function __construct($arguments) {
$this->datadir=$arguments['datadir'];
@@ -86,11 +95,11 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
}
public function rename($path1,$path2) {
if (!$this->isUpdatable($path1)) {
- OC_Log::write('core','unable to rename, file is not writable : '.$path1,OC_Log::ERROR);
+ \OC_Log::write('core','unable to rename, file is not writable : '.$path1,\OC_Log::ERROR);
return false;
}
if(! $this->file_exists($path1)) {
- OC_Log::write('core','unable to rename, file does not exists : '.$path1,OC_Log::ERROR);
+ \OC_Log::write('core','unable to rename, file does not exists : '.$path1,\OC_Log::ERROR);
return false;
}
@@ -129,7 +138,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
public function getMimeType($path) {
if($this->isReadable($path)) {
- return OC_Helper::getMimeType($this->datadir.$path);
+ return \OC_Helper::getMimeType($this->datadir.$path);
}else{
return false;
}
diff --git a/lib/filestorage.php b/lib/files/storage/storage.php
index 5bfd09253d5..a2f6cb7ec34 100644
--- a/lib/filestorage.php
+++ b/lib/files/storage/storage.php
@@ -1,29 +1,17 @@
<?php
-
/**
-* ownCloud
-*
-* @author Frank Karlitschek
-* @copyright 2012 Frank Karlitschek frank@owncloud.org
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
+ * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files\Storage;
/**
* Provde a common interface to all different storage options
*/
-abstract class OC_Filestorage{
+abstract class Storage{
abstract public function __construct($parameters);
abstract public function mkdir($path);
abstract public function rmdir($path);
diff --git a/lib/files/storage/temporary.php b/lib/files/storage/temporary.php
new file mode 100644
index 00000000000..0e69c9112ac
--- /dev/null
+++ b/lib/files/storage/temporary.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files\Storage;
+
+/**
+ * local storage backnd in temporary folder for testing purpores
+ */
+class Temporary extends OC\Files\Storage\Local{
+ public function __construct($arguments) {
+ $this->datadir=\OC_Helper::tmpFolder();
+ }
+
+ public function cleanUp() {
+ \OC_Helper::rmdirr($this->datadir);
+ }
+
+ public function __destruct() {
+ $this->cleanUp();
+ }
+}
diff --git a/lib/filestorage/temporary.php b/lib/filestorage/temporary.php
deleted file mode 100644
index 876ba045a63..00000000000
--- a/lib/filestorage/temporary.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-/**
- * local storage backnd in temporary folder for testing purpores
- */
-class OC_Filestorage_Temporary extends OC_Filestorage_Local{
- public function __construct($arguments) {
- $this->datadir=OC_Helper::tmpFolder();
- }
-
- public function cleanUp() {
- OC_Helper::rmdirr($this->datadir);
- }
-
- public function __destruct() {
- $this->cleanUp();
- }
-}
diff --git a/lib/filesystem.php b/lib/filesystem.php
index 92eb4fa4778..9b022d8fef5 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -48,7 +48,7 @@ class OC_Filesystem{
static private $mounts=array();
public static $loaded=false;
/**
- * @var OC_Filestorage $defaultInstance
+ * @var \OC\Files\Storage\Storage $defaultInstance
*/
static private $defaultInstance;
@@ -181,7 +181,7 @@ class OC_Filesystem{
/**
* get the storage object for a path
* @param string path
- * @return OC_Filestorage
+ * @return \OC\Files\Storage\Storage
*/
static public function getStorage($path) {
$mountpoint=self::getMountPoint($path);
@@ -276,7 +276,7 @@ class OC_Filesystem{
* create a new storage of a specific type
* @param string type
* @param array arguments
- * @return OC_Filestorage
+ * @return \OC\Files\Storage\Storage
*/
static private function createStorage($class,$arguments) {
if(class_exists($class)) {
@@ -320,9 +320,9 @@ class OC_Filesystem{
}
/**
- * mount an OC_Filestorage in our virtual filesystem
- * @param OC_Filestorage storage
- * @param string mountpoint
+ * mount an \OC\Files\Storage\Storage in our virtual filesystem
+ * @param \OC\Files\Storage\Storage storage
+ * @param string mountpoint
*/
static public function mount($class,$arguments,$mountpoint) {
if($mountpoint[0]!='/') {
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index 743f9403011..36fef485513 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -35,7 +35,7 @@
* are triggered correctly.
*
* Filesystem functions are not called directly; they are passed to the correct
- * OC_Filestorage object
+ * \OC\Files\Storage\Storage object
*/
class OC_FilesystemView {
@@ -115,7 +115,7 @@ class OC_FilesystemView {
/**
* get the storage object for a path
* @param string path
- * @return OC_Filestorage
+ * @return \OC\Files\Storage\Storage
*/
public function getStorage($path) {
if (!isset($this->storage_cache[$path])) {
@@ -161,7 +161,7 @@ class OC_FilesystemView {
/**
* the following functions operate with arguments and return values identical
* to those of their PHP built-in equivalents. Mostly they are merely wrappers
- * for OC_Filestorage via basicOperation().
+ * for \OC\Files\Storage\Storage via basicOperation().
*/
public function mkdir($path) {
return $this->basicOperation('mkdir', $path, array('create', 'write'));
@@ -173,7 +173,7 @@ class OC_FilesystemView {
return $this->basicOperation('opendir', $path, array('read'));
}
public function readdir($handle) {
- $fsLocal= new OC_Filestorage_Local( array( 'datadir' => '/' ) );
+ $fsLocal= new \OC\Files\Storage\Local( array( 'datadir' => '/' ) );
return $fsLocal->readdir( $handle );
}
public function is_dir($path) {
@@ -540,7 +540,7 @@ class OC_FilesystemView {
}
/**
- * @brief abstraction layer for basic filesystem functions: wrapper for OC_Filestorage
+ * @brief abstraction layer for basic filesystem functions: wrapper for \OC\Files\Storage\Storage
* @param string $operation
* @param string #path
* @param array (optional) hooks
@@ -549,7 +549,7 @@ class OC_FilesystemView {
*
* This method takes requests for basic filesystem functions (e.g. reading & writing
* files), processes hooks and proxies, sanitises paths, and finally passes them on to
- * OC_Filestorage for delegation to a storage backend for execution
+ * \OC\Files\Storage\Storage for delegation to a storage backend for execution
*/
private function basicOperation($operation, $path, $hooks=array(), $extraParam=null) {
$postFix=(substr($path,-1,1)==='/')?'/':'';
diff --git a/lib/util.php b/lib/util.php
index 5046550d6a2..78976c96606 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -34,7 +34,7 @@ class OC_Util {
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
//first set up the local "root" storage
if(!self::$rootMounted) {
- OC_Filesystem::mount('OC_Filestorage_Local',array('datadir'=>$CONFIG_DATADIRECTORY),'/');
+ OC_Filesystem::mount('\OC\Files\Storage\Local',array('datadir'=>$CONFIG_DATADIRECTORY),'/');
self::$rootMounted=true;
}
@@ -46,7 +46,7 @@ class OC_Util {
mkdir( $userdirectory, 0755, true );
}
//jail the user into his "home" directory
- OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $user_root), $user);
+ OC_Filesystem::mount('\OC\Files\Storage\Local', array('datadir' => $user_root), $user);
OC_Filesystem::init($user_dir);
$quotaProxy=new OC_FileProxy_Quota();
OC_FileProxy::register($quotaProxy);