summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Util.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-02 13:49:42 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-02 13:49:42 +0100
commit36e4bf881b707948835bbae284ac444c80c67cc2 (patch)
tree07a1baf7b4db781c9dfd341213595dccfe8328e7 /src/Text/Hakyll/Util.hs
downloadhakyll-36e4bf881b707948835bbae284ac444c80c67cc2.tar.gz
Initial commit.
Diffstat (limited to 'src/Text/Hakyll/Util.hs')
-rw-r--r--src/Text/Hakyll/Util.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs
new file mode 100644
index 0000000..1b24d31
--- /dev/null
+++ b/src/Text/Hakyll/Util.hs
@@ -0,0 +1,21 @@
+module Text.Hakyll.Util where
+
+import System.Directory
+import System.FilePath
+import Control.Monad
+
+touchDirectories :: FilePath -> IO ()
+touchDirectories path = createDirectoryIfMissing True dir
+ where dir = takeDirectory path
+
+getRecursiveContents :: FilePath -> IO [FilePath]
+getRecursiveContents topdir = do
+ names <- getDirectoryContents topdir
+ let properNames = filter (`notElem` [".", ".."]) names
+ paths <- forM properNames $ \name -> do
+ let path = topdir </> name
+ isDirectory <- doesDirectoryExist path
+ if isDirectory
+ then getRecursiveContents path
+ else return [path]
+ return (concat paths)