Fix a path so that it can be used with tar on Windows.

@see http://betterlogic.com/roger/2009/01/tar-woes-with-windows/

@param string $path

@return string
421893
protected function fixTarPath($path)
    {
        if (OsUtil::isWindows()) {
            $path = preg_replace_callback(
                '#^([A-Z]):/#i',
                function (array $matches) {
                    return '/' . strtolower($matches[1]) . '/';
                },
                str_replace('\\', '/', $path)
            );
        }

        return $path;
    }
1344369
public static function slashPath($path) {
		if (UString::startswith ( $path, "/" ) === false)
			$path = "/" . $path;
		if (! UString::endswith ( $path, "/" ))
			$path = $path . "/";
		return $path;
	}
360118
protected function wrapPath($path)
    {
        $scheme = $this->vfs->scheme().'://';
        $path   = str_replace($scheme, null, $path);

        return $scheme.$path;
    }
1237536
public static function purifyPath($path)
    {
        $path = (string)$path;
        $path = trim($path);
        $path = rtrim($path, '\\/');

        return $path;
    }
791895
static function sanify_path($path) {
            $path = rtrim(str_replace('\\', '/', $path), '/').'/';
            do {
                $old_path = $path;
                $path = str_replace('//', '/', str_replace('/./', '/', $path));
            } while ($path != $old_path);
            do {
                $path = preg_replace('_/([^/]+?)/\\.\\./_', '/', $path, -1, $count);
            } while ($count > 0);
            $path = rtrim($path, '/');

            return $path;
        }
372801
protected function fixPath($path)
    {
        $len = strlen($this->front);

        if (substr($path, 0, $len) == $this->front) {
            $path = substr($path, $len);
        }

        return '/' . ltrim($path, '/');
    }
440127
protected function relativizePath(string $path): string
    {
        $base_segments = $this->getSegments($this->base_uri->getPath());
        $target_segments = $this->getSegments($path);
        $target_basename = array_pop($target_segments);
        array_pop($base_segments);
        foreach ($base_segments as $offset => $segment) {
            if (!isset($target_segments[$offset]) || $segment !== $target_segments[$offset]) {
                break;
            }
            unset($base_segments[$offset], $target_segments[$offset]);
        }
        $target_segments[] = $target_basename;

        return $this->formatPath(
            str_repeat('../', count($base_segments)).implode('/', $target_segments)
        );
    }
1058400
private function cleanPath($path)
  {
    $path = substr($path, 0, 1) == '/' ? substr($path, 1, strlen($path) - 1) : $path;
    $path = substr($path, strlen($path) - 1, 1) == '/' ? substr($path, 0, strlen($path) - 1) : $path;

    $path = substr($path, 0, 1) == '\\' ? substr($path, 1, strlen($path) - 1) : $path;
    $path = substr($path, strlen($path) - 1, 1) == '\\' ? substr($path, 1, strlen($path) - 1) : $path;

    $path = preg_replace('#' . $this->DS . '+#', $this->DS, $path);

    return $path;
  }
740917
protected function makePath($path)
    {
        $path = $this->fs->isAbsolutePath($path)
            ? $path
            : base_path($path);
        return Paths::fix($path);
    }
1229455
def fixPath(path):
  
  path = os.path.abspath(os.path.expanduser(path))
  if path.startswith("\\"):
    return "C:" + path

  return path
798776
public static function fixPath($path)
    {
        // Detect which direction of slash is "wrong"
        switch (DIRECTORY_SEPARATOR) {
            case '\\':
                $wrongDirection = '/';
                break;

            case '/':
            default:
                $wrongDirection = '\\';
                break;
        }

        if (false !== stristr($path, $wrongDirection)) {
            $path = str_replace($wrongDirection, DIRECTORY_SEPARATOR, $path);

            // In case of mixed slashes we maybe need to cleanup
            if (stristr($path, '\\\\')) {
                $path = str_replace('\\\\', '\\', $path);
            } elseif (stristr($path, '//')) {
                $path = str_replace('//', '/', $path);
            }
        }

        // Return corrected path
        return $path;
    }
328116
public static function cleanPathname($path) {
		if (UString::isNotNull ( $path )) {
			if (\DS === "/")
				$path = \str_replace ( "\\", \DS, $path );
			else
				$path = \str_replace ( "/", \DS, $path );
			$path = \str_replace ( \DS . \DS, \DS, $path );
			if (! UString::endswith ( $path, \DS )) {
				$path = $path . \DS;
			}
		}
		return $path;
	}
809395
public function remove_path($path)
	{
		foreach ($this->paths as $i => $p)
		{
			if ($p === $path)
			{
				unset($this->paths[$i]);
				break;
			}
		}

		return $this;
	}
1207500
protected static function overlayPath($path)
    {
        $path = str_replace('\\', '/', $path);
        $hasOverlay = false;
        if (strpos($path, self::$rootPath) !== 0) {
            // Path is not below root path, ignore it
            return $path;
        }

        $newPath = ltrim(substr($path, strlen(self::$rootPath)), '/');
        foreach (self::$overlayPaths as $overlay => $replace) {
            if (strpos($newPath, $overlay) === 0) {
                $newPath = $replace . substr($newPath, strlen($overlay));
                $hasOverlay = true;
                break;
            }
        }
        return $hasOverlay ? $newPath : $path;
    }
73164
private function safePath(string $path): string
    {
        while (($newPath = \str_replace('..', '', $path)) !== $path) {
            $path = $newPath;
        }

        return $path;
    }
774056
public static function resolve_path_with_dots($path) {

		if(!is_null($path) && is_string($path) && strlen($path)) {
			while(preg_match('/\/\//', $path)) {
				$path = preg_replace('/\/\//', '/', $path);
			}
			$retval = $path;
			if(preg_match('/\./', $path)) {

				$isAbsolute = FALSE;
				if(preg_match('/^\//', $path)) {
					$isAbsolute = TRUE;
					$path = preg_replace('/^\//', '', $path);
				}
				$pieces = explode('/', $path);

				$finalPieces = array();
				for($i=0; $i < count($pieces); $i++) {
					$dirName = $pieces[$i];
					if($dirName == '.') {
						//do nothing; don't bother appending.
					}
					elseif($dirName == '..') {
						array_pop($finalPieces);
					}
					else {
						$finalPieces[] = $dirName;
					}
				}

				//$retval = cs_global::string_from_array($finalPieces, NULL, '/');
				$retval = implode('/', $finalPieces);
				if($isAbsolute) {
					$retval = '/'. $retval;
				}
			}
		}
		else {
			throw new \InvalidArgumentException(__METHOD__ .": invalid path (". $path .")");
		}

		if(is_null($retval)) {
			throw new \LogicException(__METHOD__ .": returning NULL for path (". $path .")");
		}
		return($retval);
	}
753043
private function resolveFilePath($path)
    {
        $path = str_replace(array($this->_protocol.'://', '/'), array('', DIRECTORY_SEPARATOR), $path);

        foreach ($this->_includeExtensions as $ext) {
            $filename = $path.$ext;
            File::resolveFilepath($filename, null, array('include_path' => $this->_classcontentdir));
            if (true === is_file($filename)) {
                return $filename;
            }
        }

        return $path;
    }