Convert relative path to full path.

@param  string                   $path
@return string
@throws InvalidArgumentException
964964
public function getFullPath($path = '/')
    {
        if (mb_substr($path, 0, 1) == '/') {
            $path = mb_substr($path, 1);
        }

        $full_path = $this->getSandboxPath() . $path;

        if (strpos($full_path, '..')) {
            $full_path = realpath($full_path);

            if (mb_substr($full_path, 0, $this->sandbox_path_length) != $this->sandbox_path) {
                throw new InvalidArgumentException('$path is outside of the sanbox path');
            }
        }

        return $full_path;
    }
317963
public static function getFolder(string $path)
    {
        $arrFolders = explode(DIRECTORY_SEPARATOR, $path);
        $fullPath = "";
        if ($arrFolders[0] !== "") {
            $fullPath = $arrFolders[0];
        }
        unset($arrFolders[0]);
        foreach ($arrFolders as $folder) {
            $fullPath .= DIRECTORY_SEPARATOR . $folder;
            if (file_exists($fullPath) && is_dir($fullPath)) {
                continue;
            }
            mkdir($fullPath, 0775);
        }
        return $path;
    }
1086547
public function toPath($path)
    {
        $uri = $this->request->getUri()->withPath($path);

        return $this->toAbsoluteUri($uri);
    }
512115
public function getNode($path)
    {
        if (!is_string($path) || $path[0] !== '/') {
            throw new \InvalidArgumentException('Only absolute paths are allowed for Context::getNode()', 1284975105);
        }

        $path = strtolower($path);

        $workspaceRootNode = $this->getWorkspace()->getRootNodeData();
        $rootNode = $this->nodeFactory->createFromNodeData($workspaceRootNode, $this);
        if ($path !== '/') {
            $node = $this->firstLevelNodeCache->getByPath($path);
            if ($node === false) {
                $node = $rootNode->getNode(substr($path, 1));
                $this->firstLevelNodeCache->setByPath($path, $node);
            }
        } else {
            $node = $rootNode;
        }

        return $node;
    }
1179098
public function path(string $path) : PathList
    {
        if (!file_exists($path)) {
            throw new \InvalidArgumentException(
                'Arg path doesn\'t exist, path[' . $path . '].'
            );
        }
        if (!is_dir($path)) {
            throw new \InvalidArgumentException(
                'Arg path is not a directory, path[' . $path . '].'
            );
        }
        $this->path = $path;
        return $this;
    }
1342527
public function getPath(string $path): Path
    {
        if (!$this->hasPath($path)) {
            throw new \InvalidArgumentException(
                "Path '$path' does not exist (have " . implode(', ', array_keys($this->paths)) . ')'
            );
        }

        return $this->paths[$path];
    }
799758
private function asPath($path)
    {
        $expr = explode(";", $path);
        $fullPath = "$";
        for ($i = 1, $n = count($expr); $i < $n; $i++) {
            $fullPath .= preg_match("/^[0-9*]+$/", $expr[$i]) ? ("[" . $expr[$i] . "]") : ("['" . $expr[$i] . "']");
        }

        return $fullPath;
    }
602291
public static function getRealPath($path)
    {
        $path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path);

        return rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
    }
1041885
public function setPath($path)
    {
        if (!is_readable($path)) {
            throw new \InvalidArgumentException('The passed path is not readable: ' . $path);
        }

        $this->path = $path;
        $this->source = file_get_contents($path);

        return $this;
    }
287038
protected function absolutePath($path = '')
    {
        if (!$path) {
            $path = $this->path();
        }

        return '/'.$this->container().($path ? '/'.ltrim($path, '/') : '');
    }
1081072
protected function findRelativePath($path)
    {
        if (null !== $this->basePath) {
            return strtr($path, array($this->basePath . DIRECTORY_SEPARATOR => ''));
        }

        return $path;
    }
961370
public static function normalizeRelativePath($path)
	{
		// Path remove self referring paths ("/./").
		$path = preg_replace('#/\.(?=/)|^\./|/\./?$#', '', $path);

		// Regex for resolving relative paths
		$regex = '#/*[^/\.]+/\.\.#Uu';

		while (preg_match($regex, $path))
		{
			$path = preg_replace($regex, '', $path);
		}

		return $path;
	}
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);
    }
558578
public function withPath($path)
    {
        if (!is_string($path)) {
            throw new InvalidArgumentException('Uri path must be a string');
        }

        $clone = clone $this;
        $clone->path = Validator::checkPath($path);

        // if the path is absolute, then clear basePath
        if (substr($path, 0, 1) == '/') {
            $clone->basePath = '';
        }

        return $clone;
    }
332506
public static function normalizePath($path)
    {
        if (isset(self::$normalizePath[$path])) {
            return self::$normalizePath[$path];
        }

        $path = \str_replace('\\', '/', $path);
        $path = static::removeFunkyWhiteSpace($path);

        $parts = [];

        foreach (\explode('/', $path) as $part) {
            switch ($part) {
                case '':
                case '.':
                    break;

                case '..':
                    if (empty($parts)) {
                        throw new \LogicException('Path is outside of the defined root, path: [' . $path . ']');
                    }
                    \array_pop($parts);
                    break;

                default:
                    $parts[] = $part;
                    break;
            }
        }

        return self::$normalizePath[$path] = implode('/', $parts);
    }
50003
protected function filterPath($path) : string
    {
        if (!is_string($path)) {
            throw new \InvalidArgumentException('Path must be a string');
        }

        $unreservedCharacter = preg_quote($this->unReservedCharacter, '/');
        $characterSubDelimiter = preg_quote($this->characterSubDelimiter, '/');
        return preg_replace_callback(
            '/(?:[^' . $unreservedCharacter . $characterSubDelimiter . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
            [$this, 'rawURLEncodeMatchZero'],
            $path
        );
    }
948014
public static function setBaseDir($path)
    {
        $path = realpath(rtrim($path, '/\\ '));
        if ($path === false) {
            throw new \InvalidArgumentException("cat`t get real path: seems like path does`t exists: $path");
        }

        return static::$baseDir = $path;
    }