summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <id@joeyh.name>2013-05-12 16:36:44 -0500
committerGravatar Joey Hess <id@joeyh.name>2013-05-12 16:36:44 -0500
commita7fb393fabd328b4a49198f4740521d8656f673d (patch)
treebb3fe4afce3058f3a86cc75d89880a70971e8b6f
parentf72b983a7008c9dcebae05a1878d83899414b3eb (diff)
work around MissingH's absNormPath not working on Windows
-rwxr-xr-x[-rw-r--r--]Common.hs1
-rwxr-xr-xUtility/Path.hs21
2 files changed, 19 insertions, 3 deletions
diff --git a/Common.hs b/Common.hs
index fea69f0f8..5dc3cfbb2 100644..100755
--- a/Common.hs
+++ b/Common.hs
@@ -12,7 +12,6 @@ import Data.Maybe as X
import Data.List as X hiding (head, tail, init, last)
import Data.String.Utils as X hiding (join)
-import "MissingH" System.Path as X
import System.FilePath as X
import System.Directory as X
import System.IO as X hiding (FilePath)
diff --git a/Utility/Path.hs b/Utility/Path.hs
index 3152480f5..2c2fc35ff 100755
--- a/Utility/Path.hs
+++ b/Utility/Path.hs
@@ -5,12 +5,12 @@
- Licensed under the GNU GPL version 3 or higher.
-}
-{-# LANGUAGE PackageImports #-}
+{-# LANGUAGE PackageImports, CPP #-}
module Utility.Path where
import Data.String.Utils
-import "MissingH" System.Path
+import qualified "MissingH" System.Path as MissingH
import System.FilePath
import System.Directory
import Data.List
@@ -20,6 +20,23 @@ import Control.Applicative
import Utility.Monad
import Utility.UserInfo
+{- Makes a path absolute if it's not already.
+ - The first parameter is a base directory (ie, the cwd) to use if the path
+ - is not already absolute.
+ -
+ - On Unix, collapses and normalizes ".." etc in the path. May return Nothing
+ - if the path cannot be normalized.
+ -
+ - MissingH's absNormPath does not work on Windows, so on Windows
+ - no normalization is done.
+ -}
+absNormPath :: FilePath -> FilePath -> Maybe FilePath
+#ifndef __WINDOWS__
+absNormPath dir path = MissingH.absNormPath dir path
+#else
+absNormPath dir path = Just $ combine dir path
+#endif
+
{- Returns the parent directory of a path.
-
- To allow this to be easily used in loops, which terminate upon reaching the