Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-02-15 20:42:17 +0400
committerThomas Mueller <thomas.mueller@tmit.eu>2013-02-15 20:42:17 +0400
commit40739350c9b674551f0b218220054ec4f303f154 (patch)
treea281c87bcbffa7c893eec3d12930c80ec851f856 /lib/files/mapper.php
parentb488800bd5665eaa11b54002509e9e8b85c0780e (diff)
class Mapper no respects an unchanged physical root which will be excluded from slugifying the path
Diffstat (limited to 'lib/files/mapper.php')
-rw-r--r--lib/files/mapper.php24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/files/mapper.php b/lib/files/mapper.php
index cd163dcbfcd..520fadbd8c6 100644
--- a/lib/files/mapper.php
+++ b/lib/files/mapper.php
@@ -7,6 +7,12 @@ namespace OC\Files;
*/
class Mapper
{
+ private $unchangedPhysicalRoot;
+
+ public function __construct($rootDir) {
+ $this->unchangedPhysicalRoot = $rootDir;
+ }
+
/**
* @param string $logicPath
* @param bool $create indicates if the generated physical name shall be stored in the database or not
@@ -23,7 +29,7 @@ class Mapper
/**
* @param string $physicalPath
- * @return string|null
+ * @return string
*/
public function physicalToLogic($physicalPath) {
$logicPath = $this->resolvePhysicalPath($physicalPath);
@@ -39,6 +45,7 @@ class Mapper
* @param string $path
* @param bool $isLogicPath indicates if $path is logical or physical
* @param $recursive
+ * @return void
*/
public function removePath($path, $isLogicPath, $recursive) {
if ($recursive) {
@@ -159,14 +166,11 @@ class Mapper
}
private function slugifyPath($path, $index=null) {
+ $path = $this->stripRootFolder($path, $this->unchangedPhysicalRoot);
+
$pathElements = explode('/', $path);
$sluggedElements = array();
- // skip slugging the drive letter on windows - TODO: test if local path
- if (\OC_Util::runningOnWindows()) {
- $sluggedElements[]= $pathElements[0];
- array_shift($pathElements);
- }
foreach ($pathElements as $pathElement) {
// remove empty elements
if (empty($pathElement)) {
@@ -186,12 +190,8 @@ class Mapper
array_push($sluggedElements, $last.'-'.$index);
}
- // on non-windows systems add the leading / if necessary
- if (!\OC_Util::runningOnWindows() and $path[0] === '/') {
- return DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $sluggedElements);
- }
-
- return implode(DIRECTORY_SEPARATOR, $sluggedElements);
+ $sluggedPath = $this->unchangedPhysicalRoot.implode(DIRECTORY_SEPARATOR, $sluggedElements);
+ return $this->stripLast($sluggedPath);
}
/**