diff options
Diffstat (limited to 'lib/files/filesystem.php')
-rw-r--r-- | lib/files/filesystem.php | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index b10625e20de..3d7d5abf8fe 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -30,6 +30,7 @@ namespace OC\Files; +use OC\Files\Storage\Loader; const FREE_SPACE_UNKNOWN = -2; const FREE_SPACE_UNLIMITED = -3; @@ -143,6 +144,18 @@ class Filesystem { const signal_param_run = 'run'; /** + * @var \OC\Files\Storage\Loader $loader + */ + private static $loader; + + public static function getLoader(){ + if (!self::$loader) { + self::$loader = new Loader(); + } + return self::$loader; + } + + /** * get the mountpoint of the storage object for a path * ( note: because a storage is not always mounted inside the fakeroot, the * returned mountpoint is relative to the absolute root of the filesystem @@ -152,6 +165,9 @@ class Filesystem { * @return string */ static public function getMountPoint($path) { + if (!self::$mounts) { + \OC_Util::setupFS(); + } $mount = self::$mounts->find($path); if ($mount) { return $mount->getMountPoint(); @@ -167,6 +183,9 @@ class Filesystem { * @return string[] */ static public function getMountPoints($path) { + if (!self::$mounts) { + \OC_Util::setupFS(); + } $result = array(); $mounts = self::$mounts->findIn($path); foreach ($mounts as $mount) { @@ -182,6 +201,9 @@ class Filesystem { * @return \OC\Files\Storage\Storage */ public static function getStorage($mountPoint) { + if (!self::$mounts) { + \OC_Util::setupFS(); + } $mount = self::$mounts->find($mountPoint); return $mount->getStorage(); } @@ -191,6 +213,9 @@ class Filesystem { * @return Mount\Mount[] */ public static function getMountByStorageId($id) { + if (!self::$mounts) { + \OC_Util::setupFS(); + } return self::$mounts->findByStorageId($id); } @@ -199,6 +224,9 @@ class Filesystem { * @return Mount\Mount[] */ public static function getMountByNumericId($id) { + if (!self::$mounts) { + \OC_Util::setupFS(); + } return self::$mounts->findByNumericId($id); } @@ -209,6 +237,9 @@ class Filesystem { * @return array consisting of the storage and the internal path */ static public function resolvePath($path) { + if (!self::$mounts) { + \OC_Util::setupFS(); + } $mount = self::$mounts->find($path); if ($mount) { return array($mount->getStorage(), $mount->getInternalPath($path)); @@ -221,9 +252,10 @@ class Filesystem { if (self::$defaultInstance) { return false; } + self::getLoader(); self::$defaultInstance = new View($root); - if(!self::$mounts) { + if (!self::$mounts) { self::$mounts = new Mount\Manager(); } @@ -235,8 +267,8 @@ class Filesystem { return true; } - static public function initMounts(){ - if(!self::$mounts) { + static public function initMounts() { + if (!self::$mounts) { self::$mounts = new Mount\Manager(); } } @@ -359,7 +391,9 @@ class Filesystem { * clear all mounts and storage backends */ public static function clearMounts() { - self::$mounts->clear(); + if (self::$mounts) { + self::$mounts->clear(); + } } /** @@ -370,7 +404,10 @@ class Filesystem { * @param string $mountpoint */ static public function mount($class, $arguments, $mountpoint) { - $mount = new Mount\Mount($class, $mountpoint, $arguments); + if (!self::$mounts) { + \OC_Util::setupFS(); + } + $mount = new Mount\Mount($class, $mountpoint, $arguments, self::getLoader()); self::$mounts->addMount($mount); } @@ -631,9 +668,8 @@ class Filesystem { $path = substr($path, 0, -1); } //normalize unicode if possible - if (class_exists('Normalizer')) { - $path = \Normalizer::normalize($path); - } + $path = \OC_Util::normalizeUnicode($path); + return $path; } |