[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:50:31 UTC 2010
The following commit has been merged in the master branch:
commit a1eaa0af69c1e5e776bd25435ade7d49013329ea
Author: John Goerzen <jgoerzen at complete.org>
Date: Fri Dec 10 00:21:17 2004 +0100
Added temporary dir support to Path.hs
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.7--patch-58)
diff --git a/ChangeLog b/ChangeLog
index 34cf79a..bd972cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
#
+2004-12-09 17:21:17 GMT John Goerzen <jgoerzen at complete.org> patch-58
+
+ Summary:
+ Added temporary dir support to Path.hs
+ Revision:
+ missingh--head--0.7--patch-58
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/Path.hs
+
+
2004-12-09 17:09:48 GMT John Goerzen <jgoerzen at complete.org> patch-57
Summary:
diff --git a/libsrc/MissingH/Path.hs b/libsrc/MissingH/Path.hs
index 9b06a2d..f1c20af 100644
--- a/libsrc/MissingH/Path.hs
+++ b/libsrc/MissingH/Path.hs
@@ -35,13 +35,19 @@ Written by John Goerzen, jgoerzen\@complete.org
module MissingH.Path(-- * Name processing
splitExt,
-- * Directory Processing
- recurseDir, recurseDirStat
+ recurseDir, recurseDirStat, recursiveRemove,
+ -- * Temporary Directories
+ mktmpdir, brackettmpdir
)
where
import Data.List
import MissingH.List
-import System.Directory
+import System.Directory hiding (createDirectory)
import System.Posix.Files
+import System.Posix.Directory (createDirectory)
+import System.Posix.Temp
+import Control.Exception
+import System.IO
{- | Splits a pathname into a tuple representing the root of the name and
the extension. The extension is considered to be all characters from the last
@@ -99,3 +105,27 @@ recursiveRemove fn =
worker xs
in
recurseDirStat fn >>= worker
+
+{- | Creates a temporary directory for your use.
+
+The passed string should be a template suitable for mkstemp; that is, end with
+@\"XXXXXX\"@.
+
+The name of the directory created will be returned.
+-}
+mktmpdir :: String -> IO String
+mktmpdir x =
+ do y <- mkstemp x
+ let (dirname, h) = y
+ hClose h
+ removeFile dirname
+ createDirectory dirname 0o700
+ return dirname
+
+{- | Creates a temporary directory for your use via 'mktmpdir',
+runs the specified action (passing in the directory name), then
+removes the directory and all its contents when the action completes (or raises
+an exception. -}
+brackettmpdir :: String -> (String -> IO a) -> IO a
+brackettmpdir x action = do tmpdir <- mktmpdir x
+ finally (action tmpdir) (recursiveRemove tmpdir)
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list