mirror of
https://github.com/typeable/file-embed.git
synced 2024-09-11 07:45:30 +03:00
Add embedDirListing
Use case: need the file listing to be embedded, but without their contents (which can be huge).
This commit is contained in:
parent
47ad3a5e55
commit
a21f18d8b3
@ -21,6 +21,7 @@ module Data.FileEmbed
|
|||||||
embedFile
|
embedFile
|
||||||
, embedOneFileOf
|
, embedOneFileOf
|
||||||
, embedDir
|
, embedDir
|
||||||
|
, embedDirListing
|
||||||
, getDir
|
, getDir
|
||||||
-- * Embed as a IsString
|
-- * Embed as a IsString
|
||||||
, embedStringFile
|
, embedStringFile
|
||||||
@ -118,6 +119,16 @@ embedDir fp = do
|
|||||||
e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
|
e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
|
||||||
return $ SigE e typ
|
return $ SigE e typ
|
||||||
|
|
||||||
|
-- | Embed a directory listing recursively in your source code.
|
||||||
|
--
|
||||||
|
-- > myFiles :: [FilePath]
|
||||||
|
-- > myFiles = $(embedDirListing "dirName")
|
||||||
|
embedDirListing :: FilePath -> Q Exp
|
||||||
|
embedDirListing fp = do
|
||||||
|
typ <- [t| [FilePath] |]
|
||||||
|
e <- ListE <$> ((runIO $ fmap fst <$> fileList fp) >>= mapM strToExp)
|
||||||
|
return $ SigE e typ
|
||||||
|
|
||||||
-- | Get a directory tree in the IO monad.
|
-- | Get a directory tree in the IO monad.
|
||||||
--
|
--
|
||||||
-- This is the workhorse of 'embedDir'
|
-- This is the workhorse of 'embedDir'
|
||||||
|
Loading…
Reference in New Issue
Block a user