aboutsummaryrefslogtreecommitdiffstats
path: root/lib/files/filesystem.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-06-02 20:12:44 +0200
committerRobin Appelman <icewind@owncloud.com>2013-06-02 20:12:44 +0200
commit251527c6e65a5f88b56c2dbcfebb7d8dbe38d8fb (patch)
treeedcdac4b814573dad6fb8d47ce4af6f93bd7836d /lib/files/filesystem.php
parentb7585050b565ac8f42c3afa625037adaf1a8d92c (diff)
parentcf71a54f5d6e08020a1a574d43f7fca6642776c9 (diff)
downloadnextcloud-server-251527c6e65a5f88b56c2dbcfebb7d8dbe38d8fb.tar.gz
nextcloud-server-251527c6e65a5f88b56c2dbcfebb7d8dbe38d8fb.zip
merge master into backgroundjob
Diffstat (limited to 'lib/files/filesystem.php')
-rw-r--r--lib/files/filesystem.php67
1 files changed, 56 insertions, 11 deletions
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index c0e9d215fb5..02cce001b48 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -34,6 +34,11 @@ const FREE_SPACE_UNKNOWN = -2;
const FREE_SPACE_UNLIMITED = -3;
class Filesystem {
+ /**
+ * @var Mount\Manager $mounts
+ */
+ private static $mounts;
+
public static $loaded = false;
/**
* @var \OC\Files\View $defaultInstance
@@ -147,7 +152,7 @@ class Filesystem {
* @return string
*/
static public function getMountPoint($path) {
- $mount = Mount::find($path);
+ $mount = self::$mounts->find($path);
if ($mount) {
return $mount->getMountPoint();
} else {
@@ -163,7 +168,7 @@ class Filesystem {
*/
static public function getMountPoints($path) {
$result = array();
- $mounts = Mount::findIn($path);
+ $mounts = self::$mounts->findIn($path);
foreach ($mounts as $mount) {
$result[] = $mount->getMountPoint();
}
@@ -177,18 +182,34 @@ class Filesystem {
* @return \OC\Files\Storage\Storage
*/
public static function getStorage($mountPoint) {
- $mount = Mount::find($mountPoint);
+ $mount = self::$mounts->find($mountPoint);
return $mount->getStorage();
}
/**
+ * @param $id
+ * @return Mount\Mount[]
+ */
+ public static function getMountByStorageId($id) {
+ return self::$mounts->findByStorageId($id);
+ }
+
+ /**
+ * @param $id
+ * @return Mount\Mount[]
+ */
+ public static function getMountByNumericId($id) {
+ return self::$mounts->findByNumericId($id);
+ }
+
+ /**
* resolve a path to a storage and internal path
*
* @param string $path
* @return array consisting of the storage and the internal path
*/
static public function resolvePath($path) {
- $mount = Mount::find($path);
+ $mount = self::$mounts->find($path);
if ($mount) {
return array($mount->getStorage(), $mount->getInternalPath($path));
} else {
@@ -202,6 +223,10 @@ class Filesystem {
}
self::$defaultInstance = new View($root);
+ if(!self::$mounts) {
+ self::$mounts = new Mount\Manager();
+ }
+
//load custom mount config
self::initMountPoints($user);
@@ -210,6 +235,12 @@ class Filesystem {
return true;
}
+ static public function initMounts(){
+ if(!self::$mounts) {
+ self::$mounts = new Mount\Manager();
+ }
+ }
+
/**
* Initialize system and personal mount points for a user
*
@@ -287,9 +318,9 @@ class Filesystem {
}
/**
- * fill in the correct values for $user, and $password placeholders
+ * fill in the correct values for $user
*
- * @param string $input
+ * @param string $user
* @param string $input
* @return string
*/
@@ -311,6 +342,7 @@ class Filesystem {
*/
static public function tearDown() {
self::clearMounts();
+ self::$defaultInstance = null;
}
/**
@@ -327,7 +359,7 @@ class Filesystem {
* clear all mounts and storage backends
*/
public static function clearMounts() {
- Mount::clear();
+ self::$mounts->clear();
}
/**
@@ -338,7 +370,8 @@ class Filesystem {
* @param string $mountpoint
*/
static public function mount($class, $arguments, $mountpoint) {
- new Mount($class, $mountpoint, $arguments);
+ $mount = new Mount\Mount($class, $mountpoint, $arguments);
+ self::$mounts->addMount($mount);
}
/**
@@ -423,6 +456,19 @@ class Filesystem {
}
/**
+ * @brief check if the directory should be ignored when scanning
+ * NOTE: the special directories . and .. would cause never ending recursion
+ * @param String $dir
+ * @return boolean
+ */
+ static public function isIgnoredDir($dir) {
+ if ($dir === '.' || $dir === '..') {
+ return true;
+ }
+ return false;
+ }
+
+ /**
* following functions are equivalent to their php builtin equivalents for arguments/return values.
*/
static public function mkdir($path) {
@@ -585,9 +631,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;
}