From a7fb393fabd328b4a49198f4740521d8656f673d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 12 May 2013 16:36:44 -0500 Subject: work around MissingH's absNormPath not working on Windows --- Utility/Path.hs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'Utility/Path.hs') 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 -- cgit v1.2.3