Convert path related to root dir into real path

@param  string  $path  file path
@return string
@author Dmitry (dio) Levashov
516763
protected function _abspath($path) {
		return $path == $this->separator ? $this->root : $this->root.$this->separator.$path;
	}
1207039
public function getRealPath($path, $rootDir)
    {
        if (!is_string($path)) {
            return false;
        }

        if ($this->isRelativePath($path)) {
            return realpath($rootDir . DIRECTORY_SEPARATOR . $path);
        }

        return realpath($path);
    }
833143
public function normalizePath($path)
    {
        $realpath = realpath($path);
        if ($realpath) {
            $path = $realpath;
        }

        $path = str_replace('\\', '/', $path);
        $path = rtrim($path, '/');
        if (substr($path, 1, 1) === ':') {
            $path = lcfirst($path);
        }

        return $path;
    }
930192
public static function getRealPath(string $path) : string
    {
        $exception = null;

        try {
            $result = ErrorCatcher::run(static function() use ($path) {
                return realpath($path);
            });

            if ($result !== false) {
                return $result;
            }
        } catch (\ErrorException $e) {
            $exception = $e;
        }

        throw new IoException('Error getting real path of ' . $path . ', check that the path exists', 0, $exception);
    }
500268
private function getImagePath($path)
    {
        if ($path && file_exists($this->filesystem->getRootDir() . $path)) {
            return $path;
        }

        return $this->noImagePath;
    }
1302272
public function realpath($path)
    {
        $path = str_replace('\\', '/', rtrim($path, '/'));
        if ($path[0] != '/' && (strlen($path) < 2 || $path[1] != ':')) {
            $path = getcwd() . '/' . $path;
        }
        $parts = explode('/', $path);
        $path = [];
        foreach ($parts as $part) {
            if ($part == '..') {
                array_pop($path);
            } else if ($part != '.') {
                array_push($path, $part);
            }
        }
        return implode('/', $path);
    }
1173086
private function normalizePath($path)
    {
        $path = rtrim($path, '/');

        if (empty($path) or '/' !== substr($path, 0, 1)) {
            $path = '/';
        }

        return $path;
    }
1155469
public function basePath($path = null)
    {
        if (isset($this->basePath)) {
            return $this->basePath.($path ? '/'.$path : $path);
        }

        if ($this->runningInConsole()) {
            $this->basePath = getcwd();
        } else {
            $this->basePath = realpath(getcwd().'/../');
        }

        return $this->basePath($path);
    }
642781
private function fileRelativePath($path)
    {
        $path = $this->fileWebpath($path);
        // @todo This wont work for files not located on the current server...
        $path = str_replace_first(env('APP_URL'), '', $path);
        $path = str_replace(' ', '%20', $path);

        return $path;
    }
106916
public static function diskFullPath($path)
    {
        $path = self::diskPath($path);
        if (!Str::startsWith(root, $path)) {
            $path = root . DIRECTORY_SEPARATOR . ltrim($path, '\\/');
        }
        return $path;
    }
792091
public function rootPath($path = '')
    {
        if (defined('THEMOSIS_ROOT')) {
            return THEMOSIS_ROOT.($path ? DIRECTORY_SEPARATOR.$path : $path);
        }

        return $this->webPath($path);
    }
1300808
public function get_path($path)
	{
		$pathinfo = is_dir($path) ? array('dirname' => $path, 'extension' => null, 'basename' => '') : pathinfo($path);

		// make sure we have a dirname to work with
		isset($pathinfo['dirname']) or $pathinfo['dirname'] = '';

		// do we have a basedir, and is the path already prefixed by the basedir? then just deal with the double dots...
		if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) == $this->basedir)
		{
			$pathinfo['dirname'] = realpath($pathinfo['dirname']);
		}
		else
		{
			// attempt to get the realpath(), otherwise just use path with any double dots taken out when basedir is set (for security)
			$pathinfo['dirname'] = ( ! empty($this->basedir) ? realpath($this->basedir.DS.$pathinfo['dirname']) : realpath($pathinfo['dirname']) )
					?: ( ! empty($this->basedir) ? $this->basedir.DS.str_replace('..', '', $pathinfo['dirname']) : $pathinfo['dirname']);
		}

		// basedir prefix is required when it is set (may cause unexpected errors when realpath doesn't work)
		if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) != $this->basedir)
		{
			throw new \OutsideAreaException('File operation not allowed: given path is outside the basedir for this area.');
		}

		// check file extension
		if ( ! empty(static::$extensions) && array_key_exists($pathinfo['extension'], static::$extensions))
		{
			throw new \FileAccessException('File operation not allowed: disallowed file extension.');
		}

		return $pathinfo['dirname'].DS.$pathinfo['basename'];
	}
252912
public static function realpath($path)
    {
        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);

        if (false === $parse_url = parse_url($path)) {
            return false;
        }

        if (!array_key_exists('host', $parse_url)) {
            return realpath($path);
        }

        if (!array_key_exists('scheme', $parse_url)) {
            return false;
        }

        $parts = [];
        $pathArray = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $parse_url['path']));

        foreach ($pathArray as $part) {
            if ('.' === $part) {
                continue;
            } elseif ('..' === $part) {
                array_pop($parts);
            } else {
                $parts[] = $part;
            }
        }

        $path = (isset($parse_url['scheme']) ? $parse_url['scheme'].'://' : '').
                (isset($parse_url['user']) ? $parse_url['user'] : '').
                (isset($parse_url['pass']) ? ':'.$parse_url['pass'] : '').
                (isset($parse_url['user']) || isset($parse_url['pass']) ? '@' : '').
                (isset($parse_url['host']) ? $parse_url['host'] : '').
                (isset($parse_url['port']) ? ':'.$parse_url['port'] : '').
                implode('/', $parts);

        if (!file_exists($path)) {
            return false;
        }

        return $path;
    }
996142
public function getPathRelativeToDirectory($path)
    {
        // Get the last segment of the directory as asset paths will be relative to this
        // path. We can then replace this segment with nothing in the assets path.
        $directoryLastSegment = substr($this->path, strrpos($this->path, '/') + 1);

        return trim(preg_replace('/^'.$directoryLastSegment.'/', '', $path), '/');
    }
1100684
public static function getRealPath($path)
    {
        $real = realpath(self::unify($path));

        return $real ? self::unify($real) : null;
    }
1344369
public static function slashPath($path) {
		if (UString::startswith ( $path, "/" ) === false)
			$path = "/" . $path;
		if (! UString::endswith ( $path, "/" ))
			$path = $path . "/";
		return $path;
	}
884337
protected function _relpath($path) {
	
		
		$newpath = $path;
		
		
		if (substr($path, 0, 1) != '/') {
			$newpath = "/$newpath";
		}
		
		$newpath =  preg_replace("/\/$/", "", $newpath);
	
		$ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root)+1);
		
		return $ret;
	}