aboutsummaryrefslogtreecommitdiffstats
path: root/lib/files/filesystem.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/files/filesystem.php')
-rw-r--r--lib/files/filesystem.php49
1 files changed, 35 insertions, 14 deletions
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index f4530868077..0bbd7550d74 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -29,6 +29,8 @@
namespace OC\Files;
+const FREE_SPACE_UNKNOWN = -2;
+
class Filesystem {
public static $loaded = false;
/**
@@ -215,9 +217,18 @@ class Filesystem {
if ($user == '') {
$user = \OC_User::getUser();
}
+ $parser = new \OC\ArrayParser();
+
+ $root = \OC_User::getHome($user);
+ self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
+
// Load system mount points
- if (is_file(\OC::$SERVERROOT . '/config/mount.php')) {
- $mountConfig = include 'config/mount.php';
+ if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file(\OC::$SERVERROOT . '/config/mount.json')) {
+ if (is_file(\OC::$SERVERROOT . '/config/mount.json')) {
+ $mountConfig = json_decode(file_get_contents(\OC::$SERVERROOT . '/config/mount.json'), true);
+ } elseif (is_file(\OC::$SERVERROOT . '/config/mount.php')) {
+ $mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php'));
+ }
if (isset($mountConfig['global'])) {
foreach ($mountConfig['global'] as $mountPoint => $options) {
self::mount($options['class'], $options['options'], $mountPoint);
@@ -251,10 +262,12 @@ class Filesystem {
}
}
// Load personal mount points
- $root = \OC_User::getHome($user);
- self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
- if (is_file($root . '/mount.php')) {
- $mountConfig = include $root . '/mount.php';
+ if (is_file($root . '/mount.php') or is_file($root . '/mount.json')) {
+ if (is_file($root . '/mount.json')) {
+ $mountConfig = json_decode(file_get_contents($root . '/mount.json'), true);
+ } elseif (is_file($root . '/mount.php')) {
+ $mountConfig = $parser->parsePHP(file_get_contents($root . '/mount.php'));
+ }
if (isset($mountConfig['user'][$user])) {
foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
self::mount($options['class'], $options['options'], $mountPoint);
@@ -377,21 +390,29 @@ class Filesystem {
* @param array $data from hook
*/
static public function isBlacklisted($data) {
- $blacklist = \OC_Config::getValue('blacklisted_files', array('.htaccess'));
if (isset($data['path'])) {
$path = $data['path'];
} else if (isset($data['newpath'])) {
$path = $data['newpath'];
}
if (isset($path)) {
- $filename = strtolower(basename($path));
- if (in_array($filename, $blacklist)) {
+ if (self::isFileBlacklisted($path)) {
$data['run'] = false;
}
}
}
/**
+ * @param string $filename
+ * @return bool
+ */
+ static public function isFileBlacklisted($filename) {
+ $blacklist = \OC_Config::getValue('blacklisted_files', array('.htaccess'));
+ $filename = strtolower(basename($filename));
+ return (in_array($filename, $blacklist));
+ }
+
+ /**
* following functions are equivalent to their php builtin equivalents for arguments/return values.
*/
static public function mkdir($path) {
@@ -613,11 +634,11 @@ class Filesystem {
}
/**
- * Get the owner for a file or folder
- *
- * @param string $path
- * @return string
- */
+ * Get the owner for a file or folder
+ *
+ * @param string $path
+ * @return string
+ */
public static function getOwner($path) {
return self::$defaultInstance->getOwner($path);
}