[commit: packages/filepath] master: Merge pull request #19 from thomie/splitDirectories (cdeba89)

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


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

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

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

commit cdeba8910025e568a9003273e463daade5bb422d
Merge: ab0fc3a ba8bae5
Author: Neil Mitchell <ndmitchell at gmail.com>
Date:   Sun Oct 26 21:24:14 2014 +0000

    Merge pull request #19 from thomie/splitDirectories
    
    Refactor splitDirectories



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

cdeba8910025e568a9003273e463daade5bb422d
 System/FilePath/Internal.hs | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --cc System/FilePath/Internal.hs
index 8fc9314,c684070..832192d
--- a/System/FilePath/Internal.hs
+++ b/System/FilePath/Internal.hs
@@@ -641,18 -640,10 +641,10 @@@ splitPath x = [drive | drive /= ""] ++ 
  -- >          splitDirectories "test/file" == ["test","file"]
  -- >          splitDirectories "/test/file" == ["/","test","file"]
  -- > Windows: splitDirectories "C:\\test\\file" == ["C:\\", "test", "file"]
 --- > Valid x => joinPath (splitDirectories x) `equalFilePath` x
 +-- > Posix:   Valid x => joinPath (splitDirectories x) `equalFilePath` x
  -- > splitDirectories "" == []
  splitDirectories :: FilePath -> [FilePath]
- splitDirectories path =
-         if hasDrive path then head pathComponents : f (tail pathComponents)
-         else f pathComponents
-     where
-         pathComponents = splitPath path
- 
-         f = map g
-         g x = if null res then x else res
-             where res = takeWhile (not . isPathSeparator) x
+ splitDirectories = map dropTrailingPathSeparator . splitPath
  
  
  -- | Join path elements back together.



More information about the ghc-commits mailing list