@@ -4,15 +4,21 @@ module Hakyll.Core.Util.File
4 ( makeDirectories
4 ( makeDirectories
5 , getRecursiveContents
5 , getRecursiveContents
6 , isFileObsolete
6 , isFileObsolete
9−import System.FilePath (normalise, takeDirectory, (</>))
10import System.Time (ClockTime)
10import System.Time (ClockTime)
11import Control.Monad (forM, filterM)
11import Control.Monad (forM, filterM)
12+import Data.List (isPrefixOf)
12import System.Directory ( createDirectoryIfMissing, doesDirectoryExist
13import System.Directory ( createDirectoryIfMissing, doesDirectoryExist
13 , doesFileExist, getModificationTime
14 , doesFileExist, getModificationTime
14 , getDirectoryContents
15 , getDirectoryContents
17+import System.FilePath ( normalise, takeDirectory, splitPath
18+ , dropTrailingPathSeparator, (</>)
21+import Hakyll.Core.Configuration
17-- | Given a path to a file, try to make the path writable by making
23-- | Given a path to a file, try to make the path writable by making
18-- all directories on the path.
24-- all directories on the path.
@@ -65,3 +71,17 @@ isFileObsolete file depends = do
65 then return True
71 then return True
66 else do timeStamp <- getModificationTime file
72 else do timeStamp <- getModificationTime file
67 isObsolete timeStamp depends
73 isObsolete timeStamp depends
75+-- | Check if a file is meant for Hakyll internal use, i.e. if it is located in
76+-- the destination or store directory
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
84+ split = map dropTrailingPathSeparator . splitPath
85+ dirs = map (split . ($ configuration)) [ destinationDirectory