summaryrefslogtreecommitdiff
path: root/src/Utility/Path.hs
diff options
context:
space:
mode:
authorJoey Hess2016-04-28 15:31:35 -0400
committerJoey Hess2016-04-28 15:31:35 -0400
commit2e513dc98c51eca1cdfce3715b4a017be39734f7 (patch)
treed043e76be4a9300b6dec2ae27075ee6775f6502a /src/Utility/Path.hs
parent73f07cb6622e891022b88cd13593ff660c7bd327 (diff)
Fix build with directory-1.2.6.2.
It's now exporting a conflicting isSymbolicLink https://github.com/haskell/directory/issues/52 Only a few places in propellor use isSymbolicLink, but to prevent future problems, made as much of it as possible import Utility.Directory, which re-exports System.Directory without the conflicting symbol. (Utility.Tmp and System.Console.Concurrent.Internal cannot import Utility.Directory due to cycles, and don't use isSymbolicLink anyway.)
Diffstat (limited to 'src/Utility/Path.hs')
-rw-r--r--src/Utility/Path.hs22
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'