Normalize a relative Windows path.

@param RelativeWindowsPathInterface $path The path to normalize.

@return RelativeWindowsPathInterface The normalized path.
553078
protected function normalizeRelativeWindowsPath(
        RelativeWindowsPathInterface $path
    ) {
        if ($path->isAnchored()) {
            $atoms = $this->normalizeAbsolutePathAtoms($path->atoms());
        } else {
            $atoms = $this->normalizeRelativePathAtoms($path->atoms());
        }

        return $this->factory()->createFromDriveAndAtoms(
            $atoms,
            $this->normalizeDriveSpecifier($path->drive()),
            false,
            $path->isAnchored(),
            false
        );
    }
38645
protected function normalizePath($path)
    {
        $path = parent::normalizePath($path);
        return $this->getMultiRepositoryPath($path) ?: $path;
    }
1143983
public function resolvePath($path)
    {
        if ($path[0] == '/') {
            throw new \InvalidArgumentException('Cannot resolve absolute path.');
        }

        $segments = $this->getPathSegments();
        if (!empty($segments)) {
            // Remove the last segment for relative paths.
            array_pop($segments);
        }
        $path = trim($path, '/');
        foreach (explode('/', trim($path, '/')) as $segment) {
            if ($segment == '.') {
                continue;
            }
            elseif ($segment == '..' && !empty($segments) && end($segments) != '..') {
                array_pop($segments);
            }
            else {
                $segments[] = $segment;
            }
        }

        return implode('/', $segments);
    }
114441
protected function normalizePath($path)
    {
        $path = Alias::getAlias($path, ['lang' => $this->locale]);
        $path = FileHelper::normalizePath($path, DIRECTORY_SEPARATOR, false);

        if (!pathinfo($path, PATHINFO_EXTENSION)) {
            $path .= '.' . $this->defaultExtension;
        }
        $normalizePath = $path;
        // relative path
        if ((strpos($normalizePath, DIRECTORY_SEPARATOR) === false || strpos($normalizePath, '.' . DIRECTORY_SEPARATOR) !== false) && $this->path) {
            $normalizePath = dirname($this->path) . DIRECTORY_SEPARATOR . $normalizePath;
            $normalizePath = realpath($normalizePath);
        }

        if (!file_exists($normalizePath)) {
            throw new TemplateException(TemplateException::UNKNOWN_FILE, ['path' => $path]);
        }

        return $normalizePath;
    }
20630
public function normalizePath($path)
    {
        $path = trim($path);

        $path = str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $path);

        if (ends_with($path, DIRECTORY_SEPARATOR)) {
            $path = substr($path, 0, -1);
        }

        return $path;
    }
1176848
protected function normalizePath($path) {
		$path = realpath(rtrim($path, DIRECTORY_SEPARATOR));
		
		if ($path === false || ! is_readable($path)) {
			require_once __DIR__ . '/Exceptions/InvalidPath.php';
			throw new InvalidPath('Directory "' . $path . '" does not exists or is unreadable');
		}
		
		return $path;
	}
516935
protected static function resolveRelativeToGlobal($path)
    {
        // Checks if path is relative.
        if ((strpos($path, ':') === false) && ((strlen($path) === 0) || ($path[0] !== '/'))) {
            $path = getcwd() . DIRECTORY_SEPARATOR . $path;
        }
        return $path;
    }
583719
private static function normalizePath($uri, $path = null)
    {
        if ($path instanceof PathInterface) {
            $path = $path->getContent();
        }

        $path = $path ?? $uri->getPath();
        $path = (string) $path;
        if (null !== $uri->getAuthority()
            && '' !== $uri->getAuthority()
            && '' !== $path
            && '/' != ($path[0] ?? '')
        ) {
            return $uri->withPath('/'.$path);
        }

        return $uri->withPath($path);
    }
951838
public static function normalizePath( $path )
    {
        if ( '\\' == DIRECTORY_SEPARATOR )
        {
            if ( isset( $path, $path[1], $path[2] ) && ':' === $path[1] && '\\' === $path[2] )
            {
                if ( false !== strpos( $path, '/' ) )
                {
                    $path = str_replace( '/', DIRECTORY_SEPARATOR, $path );
                }
            }
        }

        return $path;
    }
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);
    }
1026926
public function relativePath($path = null)
    {
        if (null === $path) {
            return str_replace(asset('/'), '', $this->relativePath);
        }

        $this->relativePath = $path;

        return $this;
    }
1087135
public static function windows_dir(string $path)
    {
        $path = str_replace('/', '\\', $path);
        $path = preg_replace('|(?<=.)/+|', '\\', $path);
        if (':' === substr($path, 1, 1)) {
            $path = ucfirst($path);
        }
        return $path;
    }
737527
private function normalizePipePath($path)
    {
        // Prepend slash if missing
        if (empty($path) || $path[0] !== '/') {
            $path = '/' . $path;
        }

        // Trim trailing slash if present
        if (strlen($path) > 1 && '/' === substr($path, -1)) {
            $path = rtrim($path, '/');
        }

        return $path;
    }
227271
protected function relativeTargetPath($path)
    {
        if (strpos($path, JPATH_ROOT) === 0) {
            $path = self::$resourceLocator->rewrite(
                $this->relativeJoomlaTargetPath($path),
                true
            );
        }

        return $path;
    }
1018486
public function normalizeDirectoryPath($path)
    {
        $path = $this->normalizePath($path);

        if (is_link($path)) {
            $path = realpath($path);
        }

        return $path;
    }
147980
public function findRelativePath($frompath, $topath)
    {
        Deprecated::method(3.3);

        $filesystem = new Filesystem();
        $relative = $filesystem->makePathRelative($topath, $frompath);

        return $relative;
    }
981229
protected function getAbsolutePath($relativePath)
    {
        return rtrim($this->path, DIRECTORY_SEPARATOR)
             . DIRECTORY_SEPARATOR
             . ltrim($relativePath, DIRECTORY_SEPARATOR);
    }