Safe Haskell | None |
---|
Data.FileEmbed
- embedFile :: FilePath -> Q Exp
- embedDir :: FilePath -> Q Exp
- getDir :: FilePath -> IO [(FilePath, ByteString)]
- dummySpace :: Int -> Q Exp
- inject :: ByteString -> ByteString -> Maybe ByteString
- injectFile :: ByteString -> FilePath -> FilePath -> IO ()
Embed at compile time
embedFile :: FilePath -> Q ExpSource
Embed a single file in your source code.
import qualified Data.ByteString myFile :: Data.ByteString.ByteString myFile = $(embedFile "dirName/fileName")
embedDir :: FilePath -> Q ExpSource
Embed a directory recusrively in your source code.
import qualified Data.ByteString myDir :: [(FilePath, Data.ByteString.ByteString)] myDir = $(embedDir "dirName")
getDir :: FilePath -> IO [(FilePath, ByteString)]Source
Get a directory tree in the IO monad.
This is the workhorse of embedDir
Inject into an executable
dummySpace :: Int -> Q ExpSource
Arguments
:: ByteString | bs to inject |
-> ByteString | original BS containing dummy |
-> Maybe ByteString | new BS, or Nothing if there is insufficient dummy space |
Arguments
:: ByteString | |
-> FilePath | template file |
-> FilePath | output file |
-> IO () |