deal with Cygwin rsync paths issue

This commit is contained in:
Joey Hess 2013-05-14 13:24:15 -04:00
parent 43f2de8522
commit 03a0f17fbb
4 changed files with 39 additions and 6 deletions

View file

@ -17,6 +17,11 @@ import Data.List
import Data.Maybe
import Control.Applicative
#ifdef __WINDOWS__
import Data.Char
import System.FilePath.Posix as Posix
#endif
import Utility.Monad
import Utility.UserInfo
@ -185,3 +190,22 @@ dotfile file
| otherwise = "." `isPrefixOf` f || dotfile (takeDirectory file)
where
f = takeFileName file
{- Converts a DOS style path to a Cygwin style path. Only on Windows.
- Any trailing '\' is preserved as a trailing '/' -}
toCygPath :: FilePath -> FilePath
#ifndef __WINDOWS__
toCygPath = id
#else
toCygPath p
| null drive = recombine parts
| otherwise = recombine $ "/cygdrive" : 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