@@ -21,6 +21,7 @@ module Data.FileEmbed
22 , embedOneFileOf
22 , embedOneFileOf
23 , embedDir
23 , embedDir
25 -- * Embed as a IsString
26 -- * Embed as a IsString
26 , embedStringFile
27 , embedStringFile
@@ -118,6 +119,18 @@ embedDir fp = do
118 e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
119 e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
119 return $ SigE e typ
120 return $ SigE e typ
122+-- | Embed a directory listing recursively in your source code.
124+-- > myFiles :: [FilePath]
125+-- > myFiles = $(embedDirListing "dirName")
128+embedDirListing :: FilePath -> Q Exp
129+embedDirListing fp = do
130+ typ <- [t| [FilePath] |]
131+ e <- ListE <$> ((runIO $ fmap fst <$> fileList fp) >>= mapM strToExp)
121-- | Get a directory tree in the IO monad.
134-- | Get a directory tree in the IO monad.
123-- This is the workhorse of 'embedDir'
136-- This is the workhorse of 'embedDir'