OsPath transition Windows build fixes

This gets it building on Windows again, with 1 test suite failure
(addurl).

Sponsored-by: Kevin Mueller
This commit is contained in:
Joey Hess 2025-02-11 19:23:02 -08:00 committed by Joey Hess
parent 9dc43396b3
commit a149336a59
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
23 changed files with 58 additions and 62 deletions

View file

@ -25,6 +25,7 @@ import Utility.Tuple
#ifdef mingw32_HOST_OS
import qualified System.FilePath.Posix as Posix
import qualified Utility.OsString as OS
#endif
import Data.Char
@ -102,7 +103,7 @@ rsyncUrlIsShell s
rsyncUrlIsPath :: String -> Bool
rsyncUrlIsPath s
#ifdef mingw32_HOST_OS
| not (null (takeDrive s)) = True
| not (OS.null (takeDrive (toOsPath s))) = True
#endif
| rsyncUrlIsShell s = False
| otherwise = ':' `notElem` s
@ -174,15 +175,15 @@ filterRsyncSafeOptions = fst3 . getOpt Permute
#ifdef mingw32_HOST_OS
toMSYS2Path :: FilePath -> FilePath
toMSYS2Path p
| null drive = recombine parts
| otherwise = recombine $ "/" : driveletter drive : parts
| OS.null drive = recombine parts
| otherwise = recombine $ "/" : driveletter (fromOsPath drive) : parts
where
(drive, p') = splitDrive p
parts = splitDirectories p'
(drive, p') = splitDrive (toOsPath p)
parts = map fromOsPath $ splitDirectories p'
driveletter = map toLower . takeWhile (/= ':')
recombine = fixtrailing . Posix.joinPath
fixtrailing s
| hasTrailingPathSeparator p = Posix.addTrailingPathSeparator s
| hasTrailingPathSeparator (toOsPath p) = Posix.addTrailingPathSeparator s
| otherwise = s
#endif