@@ -2,6 +2,7 @@
22module Data.FileEmbed
33 ( embedFile
44 , embedDir
5+ , getDir
56 ) where
67
78import Language.Haskell.TH (runQ,
@@ -36,6 +37,12 @@ embedFile fp = (runIO $ B.readFile fp) >>= bsToExp
3637embedDir :: FilePath -> Q Exp
3738embedDir fp = ListE <$> ((runIO $ fileList fp) >>= mapM pairToExp)
3839
40+-- | Get a directory tree in the IO monad.
41+--
42+-- This is the workhorse of 'embedDir'
43+getDir :: FilePath -> IO [(FilePath, B.ByteString)]
44+getDir = fileList
45+
3946pairToExp :: (FilePath, B.ByteString) -> Q Exp
4047pairToExp (path, bs) = do
4148 exp' <- bsToExp bs