aboutsummaryrefslogtreecommitdiff
path: root/Text/Pandoc/Shared.hs
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-08-10 17:33:07 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-08-10 17:33:07 +0000
commitf435d14f28e2323120f215996a979030e93f393d (patch)
tree81ab521f876d7283b4316de5a530fd0700cfea00 /Text/Pandoc/Shared.hs
parent9d54611d874a9555a64bfeabd8e7c1da6611ebb2 (diff)
downloadpandoc-f435d14f28e2323120f215996a979030e93f393d.tar.gz
Use 'bracket' to improve withTempDir Text.Pandoc.Shared.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1393 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Text/Pandoc/Shared.hs')
-rw-r--r--Text/Pandoc/Shared.hs7
1 files changed, 2 insertions, 5 deletions
diff --git a/Text/Pandoc/Shared.hs b/Text/Pandoc/Shared.hs
index 6f37f633b..d14a49d82 100644
--- a/Text/Pandoc/Shared.hs
+++ b/Text/Pandoc/Shared.hs
@@ -112,6 +112,7 @@ import Text.Pandoc.CharacterReferences ( characterReference )
import Data.Char ( toLower, toUpper, ord, isLower, isUpper )
import Data.List ( find, isPrefixOf )
import Control.Monad ( join )
+import Control.Exception ( bracket )
import Network.URI ( parseURI, URI (..), isAllowedInURI )
import System.FilePath ( (</>), (<.>) )
import System.IO.Error ( catch, ioError, isAlreadyExistsError )
@@ -925,11 +926,7 @@ defaultWriterOptions =
-- | Perform a function in a temporary directory and clean up.
withTempDir :: FilePath -> (FilePath -> IO a) -> IO a
-withTempDir baseName func = do
- tempDir <- createTempDir 0 baseName
- result <- catch (func tempDir) $ \e -> removeDirectoryRecursive tempDir >> ioError e
- removeDirectoryRecursive tempDir
- return result
+withTempDir baseName = bracket (createTempDir 0 baseName) (removeDirectoryRecursive)
-- | Create a temporary directory with a unique name.
createTempDir :: Integer -> FilePath -> IO FilePath