summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Util
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-04-03 12:02:06 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2013-04-03 12:02:06 +0200
commit5e4adaecb232231d87a6bb4dd0b041daf86a4cdb (patch)
treedab51fae19d9c062fdc9697c1ac410a93e8f4517 /src/Hakyll/Core/Util
parent792fcdf4c6c5a86a6dcaf969f807ae86a58090b1 (diff)
downloadhakyll-5e4adaecb232231d87a6bb4dd0b041daf86a4cdb.tar.gz
Account for absolute paths in `shouldIgnoreFile`
Diffstat (limited to 'src/Hakyll/Core/Util')
-rw-r--r--src/Hakyll/Core/Util/File.hs15
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)