temporary 1.0 → 1.1
raw patch · 2 files changed
+33/−4 lines, 2 files
Files
- System/IO/Temp.hs +32/−3
- temporary.cabal +1/−1
System/IO/Temp.hs view
@@ -18,11 +18,38 @@ import Distribution.Compat.TempFile +-- | Create and use a temporary directory in the system standard temporary directory.+--+-- Behaves exactly the same as 'withTempDirectory', except that the parent temporary directory+-- will be that returned by 'getTemporaryDirectory'.+withSystemTempFile :: String -- ^ File name template. See 'openTempFile'.+ -> (FilePath -> Handle -> IO a) -- ^ Callback that can use the file+ -> IO a+withSystemTempFile template action = getTemporaryDirectory >>= \tmpDir -> withTempFile tmpDir template action++-- | Create and use a temporary directory in the system standard temporary directory.+--+-- Behaves exactly the same as 'withTempDirectory', except that the parent temporary directory+-- will be that returned by 'getTemporaryDirectory'.+withSystemTempDirectory :: String -- ^ Directory name template. See 'openTempFile'.+ -> (FilePath -> IO a) -- ^ Callback that can use the directory+ -> IO a+withSystemTempDirectory template action = getTemporaryDirectory >>= \tmpDir -> withTempDirectory tmpDir template action++ -- | Use a temporary filename that doesn't already exist. --+-- Creates a new temporary file inside the given directory, making use of the+-- template. The temp file is deleted after use. For example:+--+-- > withTempFile "src" "sdist." $ \tmpFile hFile -> do ...+--+-- The @tmpFlie@ will be file in the given directory, e.g.+-- @src/sdist.342@. withTempFile :: FilePath -- ^ Temp dir to create the file in -> String -- ^ File name template. See 'openTempFile'.- -> (FilePath -> Handle -> IO a) -> IO a+ -> (FilePath -> Handle -> IO a) -- ^ Callback that can use the file+ -> IO a withTempFile tmpDir template action = Exception.bracket (openTempFile tmpDir template)@@ -38,8 +65,10 @@ -- -- The @tmpDir@ will be a new subdirectory of the given directory, e.g. -- @src/sdist.342@.----withTempDirectory :: FilePath -> String -> (FilePath -> IO a) -> IO a+withTempDirectory :: FilePath -- ^ Temp directory to create the directory in+ -> String -- ^ Directory name template. See 'openTempFile'.+ -> (FilePath -> IO a) -- ^ Callback that can use the directory+ -> IO a withTempDirectory targetDir template = Exception.bracket (createTempDirectory targetDir template)
temporary.cabal view
@@ -1,5 +1,5 @@ name: temporary-version: 1.0+version: 1.1 cabal-version: >= 1.6 synopsis: Portable temporary file and directory support for Windows and Unix, based on code from Cabal description: The functions for creating temporary files and directories in the base library are quite limited. The unixutils