Normalizes a path to directory separators, used by current system.

@param  string $path
@return string
180140
public static function Normalize( string $path ) : string
   {

      if ( empty( static::$NoFolderSeparator ) )
      {
         static::$NoFolderSeparator = File::IS_WIN ? '/' : '\\';
      }

      $tmpPath = ( File::IS_WIN
         ? \trim(
            \str_replace(
               static::$NoFolderSeparator,
               \DIRECTORY_SEPARATOR,
               $path
            ),
            \DIRECTORY_SEPARATOR
         )
         : \rtrim(
            \str_replace(
               static::$NoFolderSeparator,
               \DIRECTORY_SEPARATOR,
               $path
            ),
            \DIRECTORY_SEPARATOR
         )
      );

      // return the resulting path and replace /./ or \.\ with a single directory separator
      return str_replace(
         \DIRECTORY_SEPARATOR . '.' . \DIRECTORY_SEPARATOR,
         \DIRECTORY_SEPARATOR,
         $tmpPath
      );

   }
1170637
protected function normalizeFilename($path)
	{
		if (file_exists($path)) {
			$path = realpath($path);
		}
		return substr($path,mb_strlen(realpath(dirname($_SERVER['DOCUMENT_ROOT']))));
	}
210192
public static function normalizePath(?string $path): string
  {
    // With thanks to monkeysuffrage, see https://github.com/monkeysuffrage/phpuri/blob/master/phpuri.php.

    if ($path===null || $path==='')
    {
      return '';
    }

    $normalized_path = $path;
    $normalized_path = preg_replace('`//+`', '/', $normalized_path, -1, $c0);
    $normalized_path = preg_replace('`^/\\.\\.?/`', '/', $normalized_path, -1, $c1);
    $normalized_path = preg_replace('`/\\.(/|$)`', '/', $normalized_path, -1, $c2);
    $normalized_path = preg_replace('`/[^/]*?/\\.\\.(/|$)`', '/', $normalized_path, 1, $c3);
    $_num_matches    = $c0 + $c1 + $c2 + $c3;

    return ($_num_matches>0) ? self::normalizePath($normalized_path) : $normalized_path;
  }
38645
protected function normalizePath($path)
    {
        $path = parent::normalizePath($path);
        return $this->getMultiRepositoryPath($path) ?: $path;
    }
937221
protected function sanitizePath($path)
    {
        if (is_array($path)) {
            return array_map([$this, 'sanitizePath'], $path);
        }

        $path = iconv($encoding = 'UTF-8', "$encoding//IGNORE//TRANSLIT", $path);

        $parts = explode('/', $path);
        $safe = [];
        foreach ($parts as $part) {
            if (empty($part) || ('.' === $part)) {
                continue;
            }

            if ('..' === $part) {
                array_pop($safe);

                continue;
            }

            $safe[] = $part;
        }

        return implode(DIRECTORY_SEPARATOR, $safe);
    }
907762
public static function normalizePath(string $path): string
    {
        $path = \str_replace('/./', '/', \str_replace('\\', '/', $path));
        $m = null;
        
        while (\preg_match("'/([^/]+/\.\./)'", $path, $m)) {
            $path = \str_replace($m[1], '', $path);
        }
        
        return $path;
    }
857711
public static function getPath($path = '')
    {
        $path = ltrim($path, '/\\');
        $path = sprintf('%s%s%s', self::$applicationRoot, DIRECTORY_SEPARATOR, $path);
        $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
        return $path;
    }
279738
private function normalizePath($path)
    {
        if (!is_string($path) && !method_exists($path, '__toString')) {
            throw new InvalidArgumentException('Uri path must be a string');
        }

        $path = $this->urlEncode($path);

        if (empty($path)) {
            return '';
        }

        if ($path[0] !== '/') {
            return $path;
        }

        // Ensure only one leading slash
        return '/' . ltrim($path, '/');
    }
1075945
protected function formatPath($path)
    {
        $path = trim($path, '/') . '/';
        if (strlen($path) > 1) {
            $path = '/' . $path;
        }

        return $path;
    }
768264
protected static function normalizePath($path)
    {
        if ('/' === substr($path, 0, 1)) {
            $path = static::removePathDotSegments($path);
        }

        $path = static::encodePath(
            static::decodeUrlEncodedChars(
                $path,
                '/[' . static::CHAR_UNRESERVED . ':@&=\+\$,\/;%]/'
            )
        );

        if (strlen($path) > 1 && '/' === substr($path, -1)) {
            $path = substr($path, 0, -1);
        }

        return $path;
    }
52182
protected function normalizeFilename($path)
    {
        if (file_exists($path)) {
            $path = realpath($path);
        }
        return str_replace(base_path(), '', $path);
    }
1374212
public static function delete($path)
    {
        $files = self::getContent($path);
        foreach ($files as $file) {
            if (is_dir($path.DIRECTORY_SEPARATOR.$file)) {
                self::delete($path.DIRECTORY_SEPARATOR.$file);
            } else {
                @unlink($path.DIRECTORY_SEPARATOR.$file);
            }
        }

        return @rmdir($path);
    }
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;
    }
1373181
public function normalize($path) {
        $path = strtr(trim($path), '\\', '/');
        $scheme = "";
        $matches = array();
        if (preg_match('#([a-zA-Z]+:/)/(.+)#', $path, $matches)) {
            $scheme = $matches[1];
            $path = "/" . $matches[2];
        }
        $result = substr(
                array_reduce(
                        explode('/', $path)
                        , create_function('$a, $b', '
                            if($a === 0){
                                    if($b === "." 
                                        || $b === ".." 
                                        || substr($b,1,1) === ":" 
                                        || $b === ""){
                                        return preg_replace("/\/+/", "/", "$b/");
                                    } else {
                                        return preg_replace("/\/+/", "/", "./$b/");
                                    }
                            }
                            if($b === "" || $b === "."){
                                    return preg_replace("/\/+/", "/", "$a/");
                            }
                            if($b === ".." && substr($a, -4) === "/../"){
                                    return preg_replace("/\/+/", "/", "$a/$b/");
                            }
                            if($b === ".." && $a === "../"){
                                    return preg_replace("/\/+/", "/", "$a/$b/");
                            }
                            if($b === ".." && $a === "./"){
                                    return "../";
                            }
                            if($b === ".." && $a === "/"){
                                    return "//";
                            }
                            if($b === ".."){
                                    return preg_replace("/\/+/", "/", strtr(dirname($a), \'\\\\\', \'/\') . "/");
                            }
                            return preg_replace("/\/+/", "/", "$a/$b/");
                        ')
                        , 0)
                , 0, -1);
        return $scheme . ($result === "" ? "/" : $result);
    }
890372
private function normalizePath($path, $removeTrailingSeparator = false)
    {
        $newPath = str_replace('/', DIRECTORY_SEPARATOR, $path);
        $newPath = str_replace('\\', DIRECTORY_SEPARATOR, $newPath);

        $newPath = str_replace(':'.DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, '://', $newPath);

        if ($removeTrailingSeparator) {
            return rtrim($newPath, DIRECTORY_SEPARATOR);
        }

        return $newPath;
    }
1266805
public static function normalizePath($path){

		$segments = explode('/',$path);
		$segments = array_reverse($segments);

		$path = array();
		$path_len = 0;

		while( $segments ){
			$segment = array_pop($segments);
			switch( $segment ) {

				case '.':
				break;

				case '..':
					if( !$path_len || ( $path[$path_len-1] === '..') ){
						$path[] = $segment;
						$path_len++;
					}else{
						array_pop($path);
						$path_len--;
					}
				break;

				default:
					$path[] = $segment;
					$path_len++;
				break;
			}
		}

		return implode('/',$path);
	}
1018828
private function formatPath($path) {
	if($this->dynamic_fileroot != '') {
		$a = explode($this->separator, $path);
		return end($a);
	} else {
		return $path;
	}
}