diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-02-10 16:42:26 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-02-10 16:42:26 +0100 |
commit | 48da85b3418e7805d27cd2703f83570027d66a2a (patch) | |
tree | bc58d62e8afd394adbc614ba9dd37604e155aa35 /src/Hakyll | |
parent | d66155968fa02b85eb751c68f20d3a6bb708b5e6 (diff) | |
download | hakyll-48da85b3418e7805d27cd2703f83570027d66a2a.tar.gz |
Add isFileInternal
Diffstat (limited to 'src/Hakyll')
-rw-r--r-- | src/Hakyll/Core/Util/File.hs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Hakyll/Core/Util/File.hs b/src/Hakyll/Core/Util/File.hs index 45f3760..71de322 100644 --- a/src/Hakyll/Core/Util/File.hs +++ b/src/Hakyll/Core/Util/File.hs @@ -4,15 +4,21 @@ module Hakyll.Core.Util.File ( makeDirectories , getRecursiveContents , isFileObsolete + , isFileInternal ) where -import System.FilePath (normalise, takeDirectory, (</>)) import System.Time (ClockTime) import Control.Monad (forM, filterM) +import Data.List (isPrefixOf) import System.Directory ( createDirectoryIfMissing, doesDirectoryExist , doesFileExist, getModificationTime , getDirectoryContents ) +import System.FilePath ( normalise, takeDirectory, splitPath + , dropTrailingPathSeparator, (</>) + ) + +import Hakyll.Core.Configuration -- | Given a path to a file, try to make the path writable by making -- all directories on the path. @@ -65,3 +71,17 @@ isFileObsolete file depends = do then return True else do timeStamp <- getModificationTime file isObsolete timeStamp depends + +-- | Check if a file is meant for Hakyll internal use, i.e. if it is located in +-- the destination or store directory +-- +isFileInternal :: HakyllConfiguration -- ^ Configuration + -> FilePath -- ^ File to check + -> Bool -- ^ If the given file is internal +isFileInternal configuration file = + any (`isPrefixOf` split file) dirs + where + split = map dropTrailingPathSeparator . splitPath + dirs = map (split . ($ configuration)) [ destinationDirectory + , storeDirectory + ] |