From 3d21d02d65ae809e5a6c117272bc2418226220c9 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Thu, 3 Dec 2009 14:14:48 +0100 Subject: Commented Text.Hakyll.Util. --- src/Text/Hakyll/Render.hs | 4 ++-- src/Text/Hakyll/Util.hs | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Text/Hakyll/Render.hs b/src/Text/Hakyll/Render.hs index a36ff7c..2ff1b93 100644 --- a/src/Text/Hakyll/Render.hs +++ b/src/Text/Hakyll/Render.hs @@ -33,12 +33,12 @@ renderAndWrite :: FilePath -> Page -> IO () renderAndWrite templatePath page = do rendered <- renderPage templatePath page let destination = toDestination $ getURL rendered - touchDirectories destination + makeDirectories destination writeFile destination (getBody rendered) static :: FilePath -> IO () static source = do - touchDirectories destination + makeDirectories destination copyFile source destination where destination = toDestination source diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs index f5a9954..dd84d73 100644 --- a/src/Text/Hakyll/Util.hs +++ b/src/Text/Hakyll/Util.hs @@ -1,5 +1,5 @@ module Text.Hakyll.Util - ( touchDirectories, + ( makeDirectories, getRecursiveContents ) where @@ -7,10 +7,14 @@ import System.Directory import System.FilePath import Control.Monad -touchDirectories :: FilePath -> IO () -touchDirectories path = createDirectoryIfMissing True dir +-- | Given a path to a file, try to make the path writable by making +-- all directories on the path. +makeDirectories :: FilePath -> IO () +makeDirectories path = createDirectoryIfMissing True dir where dir = takeDirectory path +-- | Get all contents of a directory. Note that files starting with a dot (.) +-- will be ignored. getRecursiveContents :: FilePath -> IO [FilePath] getRecursiveContents topdir = do names <- getDirectoryContents topdir -- cgit v1.2.3