summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-13 12:36:30 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-13 12:36:30 -0400
commitc5c97062132407dcbd2978d966da4b74aef2faf5 (patch)
tree8187dbc5ebf8095d98f121336cfd0a09fb81ac2f
parenteef87d34e85e88d6047ad7b7688d8ff369dce7a5 (diff)
parentc86a7e34614e5cbc7f3fec0bed4652d112ae8895 (diff)
Merge remote-tracking branch 'pkitslaar/master'
-rw-r--r--Utility/Path.hs25
-rw-r--r--Utility/Rsync.hs6
2 files changed, 28 insertions, 3 deletions
diff --git a/Utility/Path.hs b/Utility/Path.hs
index 2f7802048..6172629a5 100644
--- a/Utility/Path.hs
+++ b/Utility/Path.hs
@@ -271,6 +271,31 @@ toCygPath p
| otherwise = s
#endif
+{- Converts a DOS style path to a msys2 style path. Only on Windows.
+ - Any trailing '\' is preserved as a trailing '/'
+ -
+ - Taken from: http://sourceforge.net/p/msys2/wiki/MSYS2%20introduction/i
+ -
+ - The virtual filesystem contains:
+ - /c, /d, ... mount points for Windows drives
+ -}
+toMSYS2Path :: FilePath -> FilePath
+#ifndef mingw32_HOST_OS
+toMSYS2Path = id
+#else
+toMSYS2Path p
+ | null drive = recombine parts
+ | otherwise = recombine $ "/" : driveletter drive : parts
+ where
+ (drive, p') = splitDrive p
+ parts = splitDirectories p'
+ driveletter = map toLower . takeWhile (/= ':')
+ recombine = fixtrailing . Posix.joinPath
+ fixtrailing s
+ | hasTrailingPathSeparator p = Posix.addTrailingPathSeparator s
+ | otherwise = s
+#endif
+
{- Maximum size to use for a file in a specified directory.
-
- Many systems have a 255 byte limit to the name of a file,
diff --git a/Utility/Rsync.hs b/Utility/Rsync.hs
index 3aaf9281b..d3fe98120 100644
--- a/Utility/Rsync.hs
+++ b/Utility/Rsync.hs
@@ -54,16 +54,16 @@ rsyncUseDestinationPermissions = Param "--chmod=ugo=rwX"
rsync :: [CommandParam] -> IO Bool
rsync = boolSystem "rsync" . rsyncParamsFixup
-{- On Windows, rsync is from Cygwin, and expects to get Cygwin formatted
+{- On Windows, rsync is from msys2, and expects to get msys2 formatted
- paths to files. (It thinks that C:foo refers to a host named "C").
- Fix up the Params appropriately. -}
rsyncParamsFixup :: [CommandParam] -> [CommandParam]
#ifdef mingw32_HOST_OS
rsyncParamsFixup = map fixup
where
- fixup (File f) = File (toCygPath f)
+ fixup (File f) = File (toMSYS2Path f)
fixup (Param s)
- | rsyncUrlIsPath s = Param (toCygPath s)
+ | rsyncUrlIsPath s = Param (toMSYS2Path s)
fixup p = p
#else
rsyncParamsFixup = id