mirror of
https://github.com/typeable/file-embed.git
synced 2024-08-15 18:50:29 +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
|
||||
, embedOneFileOf
|
||||
, embedDir
|
||||
, embedDirListing
|
||||
, getDir
|
||||
-- * Embed as a IsString
|
||||
, embedStringFile
|
||||
@ -118,6 +119,16 @@ embedDir fp = do
|
||||
e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
|
||||
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.
|
||||
--
|
||||
-- This is the workhorse of 'embedDir'
|
||||
|
Loading…
Reference in New Issue
Block a user