@@ -4,15 +4,21 @@ module Hakyll.Core.Util.File
44 ( makeDirectories
55 , getRecursiveContents
66 , isFileObsolete
7+ , isFileInternal
78 ) where
89
9−import System.FilePath (normalise, takeDirectory, (</>))
1010import System.Time (ClockTime)
1111import Control.Monad (forM, filterM)
12+import Data.List (isPrefixOf)
1213import System.Directory ( createDirectoryIfMissing, doesDirectoryExist
1314 , doesFileExist, getModificationTime
1415 , getDirectoryContents
1516 )
17+import System.FilePath ( normalise, takeDirectory, splitPath
18+ , dropTrailingPathSeparator, (</>)
19+ )
20+
21+import Hakyll.Core.Configuration
1622
1723-- | Given a path to a file, try to make the path writable by making
1824-- all directories on the path.
@@ -65,3 +71,17 @@ isFileObsolete file depends = do
6571 then return True
6672 else do timeStamp <- getModificationTime file
6773 isObsolete timeStamp depends
74+
75+-- | Check if a file is meant for Hakyll internal use, i.e. if it is located in
76+-- the destination or store directory
77+--
78+isFileInternal :: HakyllConfiguration -- ^ Configuration
79+ -> FilePath -- ^ File to check
80+ -> Bool -- ^ If the given file is internal
81+isFileInternal configuration file =
82+ any (`isPrefixOf` split file) dirs
83+ where
84+ split = map dropTrailingPathSeparator . splitPath
85+ dirs = map (split . ($ configuration)) [ destinationDirectory
86+ , storeDirectory
87+ ]