diff options
-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 |