work around MissingH's absNormPath not working on Windows

This commit is contained in:
Joey Hess 2013-05-12 16:36:44 -05:00
parent 2f3ce4c02f
commit 7a92a0f908
2 changed files with 19 additions and 3 deletions

1
Common.hs Normal file → Executable file
View file

@ -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)

View file

@ -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