git.iko.soy/typeable/pandoc
on master help sign in
Class: added addToFileTree
commitf1407848708c9d76f0fa3a95e6af7ffc13e158d6 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 14 Jul 2017, 16:24 (9 years ago) parent42fd536
1 file changed+8
src/Text/Pandoc/Class.hs+8
src/Text/Pandoc/Class.hs+8
@@ -60,6 +60,7 @@ module Text.Pandoc.Class ( PandocMonad(..)
6060 , PandocPure(..)
6161 , FileTree(..)
6262 , FileInfo(..)
63+ , addToFileTree
6364 , runIO
6465 , runIOorExplode
6566 , runPure
@@ -479,6 +480,13 @@ newtype FileTree = FileTree {unFileTree :: M.Map FilePath FileInfo}
479480getFileInfo :: FilePath -> FileTree -> Maybe FileInfo
480481getFileInfo fp tree = M.lookup fp $ unFileTree tree
481482
483+addToFileTree :: FileTree -> FilePath -> IO FileTree
484+addToFileTree (FileTree treemap) fp = do
485+ contents <- B.readFile fp
486+ mtime <- IO.getModificationTime fp
487+ return $ FileTree $
488+ M.insert fp FileInfo{ infoFileMTime = mtime
489+ , infoFileContents = contents } treemap
482490
483491newtype PandocPure a = PandocPure {
484492 unPandocPure :: ExceptT PandocError