diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2013-04-03 13:11:15 +0300 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2013-04-03 13:11:15 +0300 |
| commit | b5e34c64a78c687fa8c0fef6c4afb2fd77cc2414 (patch) | |
| tree | 411f88aa5679bf9176dfa84a4a45fa2cd069288f /src/Hakyll/Core/Util/File.hs | |
| parent | 259190e30bb9136aef5b06546d47306edc2ad3ee (diff) | |
| parent | c40cf286afacd130c1ddd28abacb3c484895076b (diff) | |
| download | hakyll-b5e34c64a78c687fa8c0fef6c4afb2fd77cc2414.tar.gz | |
Merge github.com:jaspervdj/hakyll into fsnotify
Diffstat (limited to 'src/Hakyll/Core/Util/File.hs')
| -rw-r--r-- | src/Hakyll/Core/Util/File.hs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Hakyll/Core/Util/File.hs b/src/Hakyll/Core/Util/File.hs index 20cfbbc..b20576f 100644 --- a/src/Hakyll/Core/Util/File.hs +++ b/src/Hakyll/Core/Util/File.hs @@ -9,7 +9,7 @@ module Hakyll.Core.Util.File -------------------------------------------------------------------------------- import Control.Applicative ((<$>)) -import Control.Monad (forM, when) +import Control.Monad (filterM, forM, when) import System.Directory (createDirectoryIfMissing, doesDirectoryExist, getDirectoryContents, removeDirectoryRecursive) @@ -25,18 +25,21 @@ makeDirectories = createDirectoryIfMissing True . takeDirectory -------------------------------------------------------------------------------- -- | Get all contents of a directory. -getRecursiveContents :: (FilePath -> Bool) -- ^ Ignore this file/directory - -> FilePath -- ^ Directory to search - -> IO [FilePath] -- ^ List of files found +getRecursiveContents :: (FilePath -> IO Bool) -- ^ Ignore this file/directory + -> FilePath -- ^ Directory to search + -> IO [FilePath] -- ^ List of files found getRecursiveContents ignore top = go "" where - isProper x = notElem x [".", ".."] && not (ignore x) + isProper x + | x `elem` [".", ".."] = return False + | otherwise = not <$> ignore x + go dir = do dirExists <- doesDirectoryExist (top </> dir) if not dirExists then return [] else do - names <- filter isProper <$> getDirectoryContents (top </> dir) + names <- filterM isProper =<< getDirectoryContents (top </> dir) paths <- forM names $ \name -> do let rel = dir </> name isDirectory <- doesDirectoryExist (top </> rel) |
