@@ -8,6 +8,7 @@ import System.Directory
8import System.FilePath
8import System.FilePath
9import Control.Monad
9import Control.Monad
10import Data.Char
10import Data.Char
12-- | Given a path to a file, try to make the path writable by making
13-- | Given a path to a file, try to make the path writable by making
13-- all directories on the path.
14-- all directories on the path.
@@ -34,3 +35,12 @@ getRecursiveContents topdir = do
34trim :: String -> String
35trim :: String -> String
35trim = reverse . trim' . reverse . trim'
36trim = reverse . trim' . reverse . trim'
36 where trim' = dropWhile isSpace
37 where trim' = dropWhile isSpace
39+-- | Split a list at a certain element.
40+split :: (Eq a) => a -> [a] -> [[a]]
41+split element = unfoldr splitOnce
42+ where splitOnce l = let r = break (== element) l
43+ in case r of ([], []) -> Nothing
44+ (x, xs) -> if null xs
46+ else Just (x, tail xs)