From 167bee746ca291ca8edd28f591ba72a8bb17b25a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 12 May 2013 13:58:46 -0500 Subject: [PATCH] fixes for windows --- Utility/Path.hs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) mode change 100644 => 100755 Utility/Path.hs diff --git a/Utility/Path.hs b/Utility/Path.hs old mode 100644 new mode 100755 index 4ffcf1c653..3152480f56 --- a/Utility/Path.hs +++ b/Utility/Path.hs @@ -1,6 +1,6 @@ {- path manipulation - - - Copyright 2010-2011 Joey Hess + - Copyright 2010-2013 Joey Hess - - Licensed under the GNU GPL version 3 or higher. -} @@ -20,14 +20,18 @@ import Control.Applicative import Utility.Monad import Utility.UserInfo -{- Returns the parent directory of a path. Parent of / is "" -} +{- Returns the parent directory of a path. + - + - To allow this to be easily used in loops, which terminate upon reaching the + - top, the parent of / is "" -} parentDir :: FilePath -> FilePath parentDir dir - | not $ null dirs = slash ++ join s (init dirs) - | otherwise = "" + | null dirs = "" + | otherwise = joinDrive drive (join s $ init dirs) where - dirs = filter (not . null) $ split s dir - slash = if isAbsolute dir then s else "" + -- on Unix, the drive will be "/" when the dir is absolute, otherwise "" + (drive, path) = splitDrive dir + dirs = filter (not . null) $ split s path s = [pathSeparator] prop_parentDir_basics :: FilePath -> Bool @@ -43,7 +47,7 @@ prop_parentDir_basics dir - are all equivilant. -} dirContains :: FilePath -> FilePath -> Bool -dirContains a b = a == b || a' == b' || (a'++"/") `isPrefixOf` b' +dirContains a b = a == b || a' == b' || (a'++[pathSeparator]) `isPrefixOf` b' where norm p = fromMaybe "" $ absNormPath p "." a' = norm a @@ -108,7 +112,7 @@ prop_relPathDirToFile_regressionTest = same_dir_shortcurcuits_at_difference {- Given an original list of paths, and an expanded list derived from it, - generates a list of lists, where each sublist corresponds to one of the - - original paths. When the original path is a direcotry, any items + - original paths. When the original path is a directory, any items - in the expanded list that are contained in that directory will appear in - its segment. -}