From 5e4adaecb232231d87a6bb4dd0b041daf86a4cdb Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 3 Apr 2013 12:02:06 +0200 Subject: Account for absolute paths in `shouldIgnoreFile` --- src/Hakyll/Core/Util/File.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/Hakyll/Core/Util') 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) -- cgit v1.2.3