[commit: packages/filepath] master: Refactor takeDirectory (c8521d6)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 11:34:16 UTC 2015


Repository : ssh://git@git.haskell.org/filepath

On branch  : master
Link       : http://git.haskell.org/packages/filepath.git/commitdiff/c8521d6b327007a288c3c3dbab7f26214882ff97

>---------------------------------------------------------------

commit c8521d6b327007a288c3c3dbab7f26214882ff97
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Thu Oct 23 14:17:20 2014 +0200

    Refactor takeDirectory
    
    Do not reimplement `dropTrailingPathSeparator`.


>---------------------------------------------------------------

c8521d6b327007a288c3c3dbab7f26214882ff97
 System/FilePath/Internal.hs | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs
index 138fd85..c101610 100644
--- a/System/FilePath/Internal.hs
+++ b/System/FilePath/Internal.hs
@@ -88,7 +88,6 @@ module System.FilePath.MODULE_NAME
 
 import Data.Char(toLower, toUpper, isAsciiLower, isAsciiUpper)
 import Data.Maybe(isJust, fromJust)
-import Data.List(isPrefixOf)
 
 import System.Environment(getEnv)
 
@@ -552,11 +551,7 @@ dropTrailingPathSeparator x =
 -- > Windows:  takeDirectory "foo\\bar\\\\" == "foo\\bar"
 -- > Windows:  takeDirectory "C:\\" == "C:\\"
 takeDirectory :: FilePath -> FilePath
-takeDirectory x = if isDrive dir || null res then dir else res
-    where
-        res = reverse $ dropWhile isPathSeparator $ reverse dir
-        dir = dropFileName x
-        _ = isPrefixOf x -- warning suppression
+takeDirectory = dropTrailingPathSeparator . dropFileName
 
 -- | Set the directory, keeping the filename the same.
 --



More information about the ghc-commits mailing list