git.iko.soy/typeable/pandoc
on master help sign in
Moved withTempDir from PDF to Shared, export from Shared.

API change.

commitd3cf53a956f7054cfad4ea6df7ed13f02068cc0a authorJohn MacFarlane <jgm@berkeley.edu> dateWed 30 Jul 2014, 12:29 (12 years ago) parentb5210bc
2 files changed+17−11
src/Text/Pandoc/PDF.hs+1−10 src/Text/Pandoc/Shared.hs+16−1
src/Text/Pandoc/PDF.hs+1−10
@@ -30,7 +30,6 @@ Conversion of LaTeX documents to PDF.
3030-}
3131module Text.Pandoc.PDF ( makePDF ) where
3232
33−import System.IO.Temp
3433import Data.ByteString.Lazy (ByteString)
3534import qualified Data.ByteString.Lazy as B
3635import qualified Data.ByteString.Lazy.Char8 as BC
@@ -46,7 +45,7 @@ import Data.Maybe (fromMaybe)
4645import qualified Text.Pandoc.UTF8 as UTF8
4746import Text.Pandoc.Definition
4847import Text.Pandoc.Walk (walkM)
49−import Text.Pandoc.Shared (fetchItem, warn)
48+import Text.Pandoc.Shared (fetchItem, warn, withTempDir)
5049import Text.Pandoc.Options (WriterOptions(..))
5150import Text.Pandoc.MIME (extensionFromMimeType)
5251import Text.Pandoc.Process (pipeProcess)
@@ -55,14 +54,6 @@ import qualified Data.ByteString.Lazy as BL
5554import Data.List (intercalate)
5655#endif
5756
58−withTempDir :: String -> (FilePath -> IO a) -> IO a
59−withTempDir =
60−#ifdef _WINDOWS
61− withTempDirectory "."
62−#else
63− withSystemTempDirectory
64−#endif
65−
6657#ifdef _WINDOWS
6758changePathSeparators :: FilePath -> FilePath
6859changePathSeparators = intercalate "/" . splitDirectories
src/Text/Pandoc/Shared.hs+16−1
@@ -84,7 +84,9 @@ module Text.Pandoc.Shared (
8484 err,
8585 warn,
8686 -- * Safe read
87− safeRead
87+ safeRead,
88+ -- * Temp directory
89+ withTempDir
8890 ) where
8991
9092import Text.Pandoc.Definition
@@ -112,6 +114,7 @@ import Text.Pandoc.Pretty (charWidth)
112114import System.Locale (defaultTimeLocale)
113115import Data.Time
114116import System.IO (stderr)
117+import System.IO.Temp
115118import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..),
116119 renderOptions)
117120import qualified Data.ByteString as BS
@@ -846,3 +849,15 @@ safeRead s = case reads s of
846849 (d,x):_
847850 | all isSpace x -> return d
848851 _ -> fail $ "Could not read `" ++ s ++ "'"
852+
853+--
854+-- Temp directory
855+--
856+
857+withTempDir :: String -> (FilePath -> IO a) -> IO a
858+withTempDir =
859+#ifdef _WINDOWS
860+ withTempDirectory "."
861+#else
862+ withSystemTempDirectory
863+#endif