diff options
author | Joey Hess <id@joeyh.name> | 2013-05-12 16:36:44 -0500 |
---|---|---|
committer | Joey Hess <id@joeyh.name> | 2013-05-12 16:36:44 -0500 |
commit | a7fb393fabd328b4a49198f4740521d8656f673d (patch) | |
tree | bb3fe4afce3058f3a86cc75d89880a70971e8b6f /Utility/Path.hs | |
parent | f72b983a7008c9dcebae05a1878d83899414b3eb (diff) |
work around MissingH's absNormPath not working on Windows
Diffstat (limited to 'Utility/Path.hs')
-rwxr-xr-x | Utility/Path.hs | 21 |
1 files changed, 19 insertions, 2 deletions
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 |