From 7a92a0f90800fc05fa03e8b8a80f1921bfbbafe4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 12 May 2013 16:36:44 -0500 Subject: [PATCH] work around MissingH's absNormPath not working on Windows --- Common.hs | 1 - Utility/Path.hs | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) mode change 100644 => 100755 Common.hs diff --git a/Common.hs b/Common.hs old mode 100644 new mode 100755 index fea69f0f84..5dc3cfbb23 --- 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 3152480f56..2c2fc35ff9 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