diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-04-30 15:47:28 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-04-30 15:47:28 -0400 |
| commit | eb0a945d43c909273ffd9472c091db917ed6c1e2 (patch) | |
| tree | 0c9f95a3a543cf8fa85dfede4ab565fa00b43736 /src/Utility/Path.hs | |
| parent | 6e09ae96c03ebc589ae9bb647e30de19fbe2f2e7 (diff) | |
| parent | 60b12654b0746f9c35a38002d34e9ac69f76c738 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Utility/Path.hs')
| -rw-r--r-- | src/Utility/Path.hs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/Utility/Path.hs b/src/Utility/Path.hs index f3290d8d..3ee5ff39 100644 --- a/src/Utility/Path.hs +++ b/src/Utility/Path.hs @@ -12,7 +12,6 @@ module Utility.Path where import Data.String.Utils import System.FilePath -import System.Directory import Data.List import Data.Maybe import Data.Char @@ -29,6 +28,7 @@ import Utility.Exception import qualified "MissingH" System.Path as MissingH import Utility.Monad import Utility.UserInfo +import Utility.Directory {- Simplifies a path, removing any "." component, collapsing "dir/..", - and removing the trailing path separator. @@ -60,7 +60,7 @@ simplifyPath path = dropTrailingPathSeparator $ {- Makes a path absolute. - - The first parameter is a base directory (ie, the cwd) to use if the path - - is not already absolute. + - is not already absolute, and should itsef be absolute. - - Does not attempt to deal with edge cases or ensure security with - untrusted inputs. @@ -252,15 +252,21 @@ dotfile 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 +{- 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 -toCygPath = id +toMSYS2Path = id #else -toCygPath p +toMSYS2Path p | null drive = recombine parts - | otherwise = recombine $ "/cygdrive" : driveletter drive : parts + | otherwise = recombine $ "/" : driveletter drive : parts where (drive, p') = splitDrive p parts = splitDirectories p' |
