diff options
author | Joey Hess <id@joeyh.name> | 2013-05-12 13:58:46 -0500 |
---|---|---|
committer | Joey Hess <id@joeyh.name> | 2013-05-12 13:58:46 -0500 |
commit | 4763094eb17e6b6cf984f047e7f00fd10a056f00 (patch) | |
tree | bac35fc6f07cf1299f409572b15997c3efa2fe53 /Utility/Path.hs | |
parent | eab42d8d8232ead13c7a2d21e1f703949d06fe14 (diff) |
fixes for windows
Diffstat (limited to 'Utility/Path.hs')
-rwxr-xr-x[-rw-r--r--] | Utility/Path.hs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Utility/Path.hs b/Utility/Path.hs index 4ffcf1c65..3152480f5 100644..100755 --- a/Utility/Path.hs +++ b/Utility/Path.hs @@ -1,6 +1,6 @@ {- path manipulation - - - Copyright 2010-2011 Joey Hess <joey@kitenet.net> + - Copyright 2010-2013 Joey Hess <joey@kitenet.net> - - 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. -} |