diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-07-14 16:24:30 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-07-14 16:24:30 +0200 |
commit | f1407848708c9d76f0fa3a95e6af7ffc13e158d6 (patch) | |
tree | e57a4e5e16b7532389d2bd96571f49331860b094 /src | |
parent | 42fd536a0e66dcfddb4abd7daf6d738bf954b62a (diff) | |
download | pandoc-f1407848708c9d76f0fa3a95e6af7ffc13e158d6.tar.gz |
Class: added addToFileTree
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Class.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs index 120ba8fee..d8505e0b1 100644 --- a/src/Text/Pandoc/Class.hs +++ b/src/Text/Pandoc/Class.hs @@ -60,6 +60,7 @@ module Text.Pandoc.Class ( PandocMonad(..) , PandocPure(..) , FileTree(..) , FileInfo(..) + , addToFileTree , runIO , runIOorExplode , runPure @@ -479,6 +480,13 @@ newtype FileTree = FileTree {unFileTree :: M.Map FilePath FileInfo} getFileInfo :: FilePath -> FileTree -> Maybe FileInfo getFileInfo fp tree = M.lookup fp $ unFileTree tree +addToFileTree :: FileTree -> FilePath -> IO FileTree +addToFileTree (FileTree treemap) fp = do + contents <- B.readFile fp + mtime <- IO.getModificationTime fp + return $ FileTree $ + M.insert fp FileInfo{ infoFileMTime = mtime + , infoFileContents = contents } treemap newtype PandocPure a = PandocPure { unPandocPure :: ExceptT PandocError |