diff options
Diffstat (limited to 'lib/private/files')
-rw-r--r-- | lib/private/files/mount/mount.php | 2 | ||||
-rw-r--r-- | lib/private/files/storage/common.php | 14 | ||||
-rw-r--r-- | lib/private/files/storage/wrapper/wrapper.php | 21 |
3 files changed, 34 insertions, 3 deletions
diff --git a/lib/private/files/mount/mount.php b/lib/private/files/mount/mount.php index d4a4e186fb9..7c40853ac95 100644 --- a/lib/private/files/mount/mount.php +++ b/lib/private/files/mount/mount.php @@ -161,6 +161,6 @@ class Mount { * @param callable $wrapper */ public function wrapStorage($wrapper) { - $this->storage = $wrapper($this->mountPoint, $this->storage); + $this->storage = $wrapper($this->mountPoint, $this->getStorage()); } } diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 1ed0d79817b..6b11603323a 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -7,6 +7,7 @@ */ namespace OC\Files\Storage; + use OC\Files\Filesystem; use OC\Files\Cache\Watcher; @@ -21,7 +22,6 @@ use OC\Files\Cache\Watcher; * Some \OC\Files\Storage\Common methods call functions which are first defined * in classes which extend it, e.g. $this->stat() . */ - abstract class Common implements \OC\Files\Storage\Storage { protected $cache; protected $scanner; @@ -46,7 +46,7 @@ abstract class Common implements \OC\Files\Storage\Storage { protected function remove($path) { if ($this->is_dir($path)) { return $this->rmdir($path); - } else if($this->is_file($path)) { + } else if ($this->is_file($path)) { return $this->unlink($path); } else { return false; @@ -412,4 +412,14 @@ abstract class Common implements \OC\Files\Storage\Storage { protected function removeCachedFile($path) { unset($this->cachedFiles[$path]); } + + /** + * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class + * + * @param string $class + * @return bool + */ + public function instanceOfStorage($class) { + return is_a($this, $class); + } } diff --git a/lib/private/files/storage/wrapper/wrapper.php b/lib/private/files/storage/wrapper/wrapper.php index 11ea9f71da7..364475a68e0 100644 --- a/lib/private/files/storage/wrapper/wrapper.php +++ b/lib/private/files/storage/wrapper/wrapper.php @@ -440,4 +440,25 @@ class Wrapper implements \OC\Files\Storage\Storage { public function isLocal() { return $this->storage->isLocal(); } + + /** + * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class + * + * @param string $class + * @return bool + */ + public function instanceOfStorage($class) { + return is_a($this, $class) or $this->storage->instanceOfStorage($class); + } + + /** + * Pass any methods custom to specific storage implementations to the wrapped storage + * + * @param string $method + * @param array $args + * @return mixed + */ + public function __call($method, $args) { + return call_user_func_array(array($this->storage, $method), $args); + } } |