Fix max path issues on windows with 'ghcup run'

This commit is contained in:
Julian Ospald 2022-03-17 22:51:17 +01:00
parent 8eeb32c495
commit cfe6c47cd7
Signed by: hasufell
GPG Key ID: 3786C5262ECB4A3F

View File

@ -339,13 +339,15 @@ useXDG = isJust <$> lookupEnv "GHCUP_USE_XDG_DIRS"
relativeSymlink :: FilePath -- ^ the path in which to create the symlink relativeSymlink :: FilePath -- ^ the path in which to create the symlink
-> FilePath -- ^ the symlink destination -> FilePath -- ^ the symlink destination
-> FilePath -> FilePath
relativeSymlink p1 p2 = relativeSymlink p1 p2
let d1 = splitDirectories p1 | isWindows = p2 -- windows quickly gets into MAX_PATH issues so we don't care about relative symlinks
d2 = splitDirectories p2 | otherwise =
common = takeWhile (\(x, y) -> x == y) $ zip d1 d2 let d1 = splitDirectories p1
cPrefix = drop (length common) d1 d2 = splitDirectories p2
in joinPath (replicate (length cPrefix) "..") common = takeWhile (\(x, y) -> x == y) $ zip d1 d2
<> joinPath ([pathSeparator] : drop (length common) d2) cPrefix = drop (length common) d1
in joinPath (replicate (length cPrefix) "..")
<> joinPath ([pathSeparator] : drop (length common) d2)
cleanupTrash :: ( MonadIO m cleanupTrash :: ( MonadIO m