Skip to content

Commit

Permalink
Remove unused 2nd parameter of buildPath() and rename to getSourcePath()
Browse files Browse the repository at this point in the history
  • Loading branch information
nickvergessen committed Nov 27, 2014
1 parent 20237fb commit 4f1bbc4
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions lib/private/files/storage/mappedlocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getId() {
}

public function mkdir($path) {
return @mkdir($this->buildPath($path), 0777, true);
return @mkdir($this->getSourcePath($path), 0777, true);
}

public function rmdir($path) {
Expand All @@ -40,7 +40,7 @@ public function rmdir($path) {
}
try {
$it = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($this->buildPath($path)),
new \RecursiveDirectoryIterator($this->getSourcePath($path)),
\RecursiveIteratorIterator::CHILD_FIRST
);
/**
Expand All @@ -64,7 +64,7 @@ public function rmdir($path) {
}
$it->next();
}
if ($result = @rmdir($this->buildPath($path))) {
if ($result = @rmdir($this->getSourcePath($path))) {
$this->cleanMapper($path);
}
return $result;
Expand All @@ -75,7 +75,7 @@ public function rmdir($path) {

public function opendir($path) {
$files = array('.', '..');
$physicalPath = $this->buildPath($path);
$physicalPath = $this->getSourcePath($path);

$logicalPath = $this->mapper->physicalToLogic($physicalPath);
$dh = opendir($physicalPath);
Expand All @@ -101,15 +101,15 @@ public function is_dir($path) {
if (substr($path, -1) == '/') {
$path = substr($path, 0, -1);
}
return is_dir($this->buildPath($path));
return is_dir($this->getSourcePath($path));
}

public function is_file($path) {
return is_file($this->buildPath($path));
return is_file($this->getSourcePath($path));
}

public function stat($path) {
$fullPath = $this->buildPath($path);
$fullPath = $this->getSourcePath($path);
$statResult = stat($fullPath);
if (PHP_INT_SIZE === 4 && !$this->is_dir($path)) {
$filesize = $this->filesize($path);
Expand All @@ -120,9 +120,9 @@ public function stat($path) {
}

public function filetype($path) {
$filetype = filetype($this->buildPath($path));
$filetype = filetype($this->getSourcePath($path));
if ($filetype == 'link') {
$filetype = filetype(realpath($this->buildPath($path)));
$filetype = filetype(realpath($this->getSourcePath($path)));
}
return $filetype;
}
Expand All @@ -131,7 +131,7 @@ public function filesize($path) {
if ($this->is_dir($path)) {
return 0;
}
$fullPath = $this->buildPath($path);
$fullPath = $this->getSourcePath($path);
if (PHP_INT_SIZE === 4) {
$helper = new \OC\LargeFileHelper;
return $helper->getFilesize($fullPath);
Expand All @@ -140,43 +140,43 @@ public function filesize($path) {
}

public function isReadable($path) {
return is_readable($this->buildPath($path));
return is_readable($this->getSourcePath($path));
}

public function isUpdatable($path) {
return is_writable($this->buildPath($path));
return is_writable($this->getSourcePath($path));
}

public function file_exists($path) {
return file_exists($this->buildPath($path));
return file_exists($this->getSourcePath($path));
}

public function filemtime($path) {
return filemtime($this->buildPath($path));
return filemtime($this->getSourcePath($path));
}

public function touch($path, $mtime = null) {
// sets the modification time of the file to the given value.
// If mtime is nil the current time is set.
// note that the access time of the file always changes to the current time.
if (!is_null($mtime)) {
$result = touch($this->buildPath($path), $mtime);
$result = touch($this->getSourcePath($path), $mtime);
} else {
$result = touch($this->buildPath($path));
$result = touch($this->getSourcePath($path));
}
if ($result) {
clearstatcache(true, $this->buildPath($path));
clearstatcache(true, $this->getSourcePath($path));
}

return $result;
}

public function file_get_contents($path) {
return file_get_contents($this->buildPath($path));
return file_get_contents($this->getSourcePath($path));
}

public function file_put_contents($path, $data) {
return file_put_contents($this->buildPath($path), $data);
return file_put_contents($this->getSourcePath($path), $data);
}

public function unlink($path) {
Expand Down Expand Up @@ -208,8 +208,8 @@ public function rename($path1, $path2) {
$this->unlink($path2);
}

$physicPath1 = $this->buildPath($path1);
$physicPath2 = $this->buildPath($path2);
$physicPath1 = $this->getSourcePath($path1);
$physicPath2 = $this->getSourcePath($path2);
if ($return = rename($physicPath1, $physicPath2)) {
// mapper needs to create copies or all children
$this->copyMapping($path1, $path2);
Expand Down Expand Up @@ -237,15 +237,15 @@ public function copy($path1, $path2) {
closedir($dir);
return true;
} else {
if ($return = copy($this->buildPath($path1), $this->buildPath($path2))) {
if ($return = copy($this->getSourcePath($path1), $this->getSourcePath($path2))) {
$this->copyMapping($path1, $path2);
}
return $return;
}
}

public function fopen($path, $mode) {
return fopen($this->buildPath($path), $mode);
return fopen($this->getSourcePath($path), $mode);
}

/**
Expand All @@ -256,7 +256,7 @@ public function fopen($path, $mode) {
private function delTree($dir, $isLogicPath = true) {
$dirRelative = $dir;
if ($isLogicPath) {
$dir = $this->buildPath($dir);
$dir = $this->getSourcePath($dir);
}
if (!file_exists($dir)) {
return true;
Expand Down Expand Up @@ -288,31 +288,31 @@ private function delTree($dir, $isLogicPath = true) {
}

public function hash($type, $path, $raw = false) {
return hash_file($type, $this->buildPath($path), $raw);
return hash_file($type, $this->getSourcePath($path), $raw);
}

public function free_space($path) {
return @disk_free_space($this->buildPath($path));
return @disk_free_space($this->getSourcePath($path));
}

public function search($query) {
return $this->searchInDir($query);
}

public function getLocalFile($path) {
return $this->buildPath($path);
return $this->getSourcePath($path);
}

public function getLocalFolder($path) {
return $this->buildPath($path);
return $this->getSourcePath($path);
}

/**
* @param string $query
*/
protected function searchInDir($query, $dir = '') {
$files = array();
$physicalDir = $this->buildPath($dir);
$physicalDir = $this->getSourcePath($dir);
foreach (scandir($physicalDir) as $item) {
if ($item == '.' || $item == '..')
continue;
Expand Down Expand Up @@ -341,14 +341,15 @@ public function hasUpdated($path, $time) {
}

/**
* Get the source path (on disk) of a given path
*
* @param string $path
* @param bool $create
* @return string
*/
private function buildPath($path, $create = true) {
protected function getSourcePath($path) {
$path = $this->stripLeading($path);
$fullPath = $this->datadir . $path;
return $this->mapper->logicToPhysical($fullPath, $create);
return $this->mapper->logicToPhysical($fullPath, true);
}

/**
Expand Down

0 comments on commit 4f1bbc4

Please sign in to comment.