aboutsummaryrefslogtreecommitdiff
path: root/Utility/Path.hs
diff options
context:
space:
mode:
authorGravatar Pieter Kitslaar <kitslaar@gmail.com>2016-01-11 11:18:58 +0100
committerGravatar Pieter Kitslaar <kitslaar@gmail.com>2016-01-11 11:18:58 +0100
commitc86a7e34614e5cbc7f3fec0bed4652d112ae8895 (patch)
treec5d319aac14a61a2c16d4b247e5cbb38ea7f93a9 /Utility/Path.hs
parent7078469251930a4dae68eec36fc8ff6d5e49963a (diff)
Added new toMSYS2Path function for use with rsync on Windows.
Diffstat (limited to 'Utility/Path.hs')
-rw-r--r--Utility/Path.hs25
1 files changed, 25 insertions, 0 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,