summaryrefslogtreecommitdiffstats
path: root/lib/private/files/storage/local.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/files/storage/local.php')
-rw-r--r--lib/private/files/storage/local.php77
1 files changed, 46 insertions, 31 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index 1c5fafc12fa..7b4abf08f44 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -35,7 +35,7 @@ if (\OC_Util::runningOnWindows()) {
}
public function mkdir($path) {
- return @mkdir($this->datadir . $path, 0777, true);
+ return @mkdir($this->getSourcePath($path), 0777, true);
}
public function rmdir($path) {
@@ -44,7 +44,7 @@ if (\OC_Util::runningOnWindows()) {
}
try {
$it = new \RecursiveIteratorIterator(
- new \RecursiveDirectoryIterator($this->datadir . $path),
+ new \RecursiveDirectoryIterator($this->getSourcePath($path)),
\RecursiveIteratorIterator::CHILD_FIRST
);
/**
@@ -68,30 +68,30 @@ if (\OC_Util::runningOnWindows()) {
}
$it->next();
}
- return rmdir($this->datadir . $path);
+ return rmdir($this->getSourcePath($path));
} catch (\UnexpectedValueException $e) {
return false;
}
}
public function opendir($path) {
- return opendir($this->datadir . $path);
+ return opendir($this->getSourcePath($path));
}
public function is_dir($path) {
if (substr($path, -1) == '/') {
$path = substr($path, 0, -1);
}
- return is_dir($this->datadir . $path);
+ return is_dir($this->getSourcePath($path));
}
public function is_file($path) {
- return is_file($this->datadir . $path);
+ return is_file($this->getSourcePath($path));
}
public function stat($path) {
clearstatcache();
- $fullPath = $this->datadir . $path;
+ $fullPath = $this->getSourcePath($path);
$statResult = stat($fullPath);
if (PHP_INT_SIZE === 4 && !$this->is_dir($path)) {
$filesize = $this->filesize($path);
@@ -102,9 +102,9 @@ if (\OC_Util::runningOnWindows()) {
}
public function filetype($path) {
- $filetype = filetype($this->datadir . $path);
+ $filetype = filetype($this->getSourcePath($path));
if ($filetype == 'link') {
- $filetype = filetype(realpath($this->datadir . $path));
+ $filetype = filetype(realpath($this->getSourcePath($path)));
}
return $filetype;
}
@@ -113,7 +113,7 @@ if (\OC_Util::runningOnWindows()) {
if ($this->is_dir($path)) {
return 0;
}
- $fullPath = $this->datadir . $path;
+ $fullPath = $this->getSourcePath($path);
if (PHP_INT_SIZE === 4) {
$helper = new \OC\LargeFileHelper;
return $helper->getFilesize($fullPath);
@@ -122,19 +122,19 @@ if (\OC_Util::runningOnWindows()) {
}
public function isReadable($path) {
- return is_readable($this->datadir . $path);
+ return is_readable($this->getSourcePath($path));
}
public function isUpdatable($path) {
- return is_writable($this->datadir . $path);
+ return is_writable($this->getSourcePath($path));
}
public function file_exists($path) {
- return file_exists($this->datadir . $path);
+ return file_exists($this->getSourcePath($path));
}
public function filemtime($path) {
- return filemtime($this->datadir . $path);
+ return filemtime($this->getSourcePath($path));
}
public function touch($path, $mtime = null) {
@@ -145,30 +145,30 @@ if (\OC_Util::runningOnWindows()) {
return false;
}
if (!is_null($mtime)) {
- $result = touch($this->datadir . $path, $mtime);
+ $result = touch($this->getSourcePath($path), $mtime);
} else {
- $result = touch($this->datadir . $path);
+ $result = touch($this->getSourcePath($path));
}
if ($result) {
- clearstatcache(true, $this->datadir . $path);
+ clearstatcache(true, $this->getSourcePath($path));
}
return $result;
}
public function file_get_contents($path) {
- return file_get_contents($this->datadir . $path);
+ return file_get_contents($this->getSourcePath($path));
}
- public function file_put_contents($path, $data) { //trigger_error("$path = ".var_export($path, 1));
- return file_put_contents($this->datadir . $path, $data);
+ public function file_put_contents($path, $data) {
+ return file_put_contents($this->getSourcePath($path), $data);
}
public function unlink($path) {
if ($this->is_dir($path)) {
return $this->rmdir($path);
} else if ($this->is_file($path)) {
- return unlink($this->datadir . $path);
+ return unlink($this->getSourcePath($path));
} else {
return false;
}
@@ -200,27 +200,27 @@ if (\OC_Util::runningOnWindows()) {
$this->unlink($path2);
}
- return rename($this->datadir . $path1, $this->datadir . $path2);
+ return rename($this->getSourcePath($path1), $this->getSourcePath($path2));
}
public function copy($path1, $path2) {
if ($this->is_dir($path1)) {
return parent::copy($path1, $path2);
} else {
- return copy($this->datadir . $path1, $this->datadir . $path2);
+ return copy($this->getSourcePath($path1), $this->getSourcePath($path2));
}
}
public function fopen($path, $mode) {
- return fopen($this->datadir . $path, $mode);
+ return fopen($this->getSourcePath($path), $mode);
}
public function hash($type, $path, $raw = false) {
- return hash_file($type, $this->datadir . $path, $raw);
+ return hash_file($type, $this->getSourcePath($path), $raw);
}
public function free_space($path) {
- $space = @disk_free_space($this->datadir . $path);
+ $space = @disk_free_space($this->getSourcePath($path));
if ($space === false || is_null($space)) {
return \OCP\Files\FileInfo::SPACE_UNKNOWN;
}
@@ -232,11 +232,11 @@ if (\OC_Util::runningOnWindows()) {
}
public function getLocalFile($path) {
- return $this->datadir . $path;
+ return $this->getSourcePath($path);
}
public function getLocalFolder($path) {
- return $this->datadir . $path;
+ return $this->getSourcePath($path);
}
/**
@@ -244,12 +244,16 @@ if (\OC_Util::runningOnWindows()) {
*/
protected function searchInDir($query, $dir = '') {
$files = array();
- foreach (scandir($this->datadir . $dir) as $item) {
- if ($item == '.' || $item == '..') continue;
+ $physicalDir = $this->getSourcePath($dir);
+ foreach (scandir($physicalDir) as $item) {
+ if ($item == '.' || $item == '..')
+ continue;
+ $physicalItem = $physicalDir . '/' . $item;
+
if (strstr(strtolower($item), strtolower($query)) !== false) {
$files[] = $dir . '/' . $item;
}
- if (is_dir($this->datadir . $dir . '/' . $item)) {
+ if (is_dir($physicalItem)) {
$files = array_merge($files, $this->searchInDir($query, $dir . '/' . $item));
}
}
@@ -272,6 +276,17 @@ if (\OC_Util::runningOnWindows()) {
}
/**
+ * Get the source path (on disk) of a given path
+ *
+ * @param string $path
+ * @return string
+ */
+ protected function getSourcePath($path) {
+ $fullPath = $this->datadir . $path;
+ return $fullPath;
+ }
+
+ /**
* {@inheritdoc}
*/
public function isLocal() {