@@ -8,11 +8,13 @@ module Hakyll.Core.Configuration
88
99
1010--------------------------------------------------------------------------------
11−import Control.Monad (void)
12−import Data.Default (Default(..))
13−import Data.List (isPrefixOf, isSuffixOf)
14−import System.FilePath (normalise, takeFileName)
15−import System.Process (system)
11+import Control.Monad (void)
12+import Data.Default (Default (..))
13+import Data.List (isPrefixOf, isSuffixOf)
14+import System.Directory (canonicalizePath)
15+import System.FilePath (isAbsolute, normalise, takeFileName)
16+import System.IO.Error (catchIOError)
17+import System.Process (system)
1618
1719
1820--------------------------------------------------------------------------------
@@ -99,11 +101,23 @@ defaultConfiguration = Configuration
99101
100102--------------------------------------------------------------------------------
101103-- | Check if a file should be ignored
102−shouldIgnoreFile :: Configuration -> FilePath -> Bool
103−shouldIgnoreFile conf path =
104− destinationDirectory conf `isPrefixOf` path' ||
105− storeDirectory conf `isPrefixOf` path' ||
106− tmpDirectory conf `isPrefixOf` path' ||
107− ignoreFile conf path'
104+shouldIgnoreFile :: Configuration -> FilePath -> IO Bool
105+shouldIgnoreFile conf path = orM
106+ [ inDir (destinationDirectory conf)
107+ , inDir (storeDirectory conf)
108+ , inDir (tmpDirectory conf)
109+ , return (ignoreFile conf path')
110+ ]
108111 where
109− path' = normalise path
112+ path' = normalise path
113+ absolute = isAbsolute path
114+
115+ inDir dir
116+ | absolute = do
117+ dir' <- catchIOError (canonicalizePath dir) (const $ return dir)
118+ return $ dir' `isPrefixOf` path'
119+ | otherwise = return $ dir `isPrefixOf` path'
120+
121+ orM :: [IO Bool] -> IO Bool
122+ orM [] = return False
123+ orM (x : xs) = x >>= \b -> if b then return True else orM xs