packages feed

temporary 1.1.2.5 → 1.2

raw patch · 2 files changed

+30/−24 lines, 2 filesdep +exceptionsdep +transformers

Dependencies added: exceptions, transformers

Files

System/IO/Temp.hs view
@@ -11,8 +11,9 @@ -- file in the Cabal checkout.  -import qualified Control.Exception as Exception+import Control.Monad.Catch as Exception +import Control.Monad.IO.Class import System.Directory import System.IO @@ -21,21 +22,23 @@  -- | Create and use a temporary directory in the system standard temporary directory. ----- Behaves exactly the same as 'withTempDirectory', except that the parent temporary directory+-- Behaves exactly the same as 'withTempFile', 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+withSystemTempFile :: (MonadIO m, MonadCatch m) =>+                      String   -- ^ File name template. See 'openTempFile'.+                   -> (FilePath -> Handle -> m a) -- ^ Callback that can use the file+                   -> m a+withSystemTempFile template action = liftIO 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+withSystemTempDirectory :: (MonadIO m, MonadCatch m) =>+                           String   -- ^ Directory name template. See 'openTempFile'.+                        -> (FilePath -> m a) -- ^ Callback that can use the directory+                        -> m a+withSystemTempDirectory template action = liftIO getTemporaryDirectory >>= \tmpDir -> withTempDirectory tmpDir template action   -- | Use a temporary filename that doesn't already exist.@@ -47,14 +50,15 @@ -- -- The @tmpFlie@ will be file in the given directory, e.g. -- @src/sdist.342@.-withTempFile :: FilePath -- ^ Temp dir to create the file in+withTempFile :: (MonadIO m, MonadCatch m) =>+                FilePath -- ^ Temp dir to create the file in              -> String   -- ^ File name template. See 'openTempFile'.-             -> (FilePath -> Handle -> IO a) -- ^ Callback that can use the file-             -> IO a+             -> (FilePath -> Handle -> m a) -- ^ Callback that can use the file+             -> m a withTempFile tmpDir template action =   Exception.bracket-    (openTempFile tmpDir template)-    (\(name, handle) -> hClose handle >> ignoringIOErrors (removeFile name))+    (liftIO (openTempFile tmpDir template))+    (\(name, handle) -> liftIO (hClose handle >> ignoringIOErrors (removeFile name)))     (uncurry action)  -- | Create and use a temporary directory.@@ -66,14 +70,15 @@ -- -- The @tmpDir@ will be a new subdirectory of the given directory, e.g. -- @src/sdist.342@.-withTempDirectory :: FilePath -- ^ Temp directory to create the directory in+withTempDirectory :: (MonadCatch m, MonadIO m) =>+                     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+                  -> (FilePath -> m a) -- ^ Callback that can use the directory+                  -> m a withTempDirectory targetDir template =   Exception.bracket-    (createTempDirectory targetDir template)-    (ignoringIOErrors . removeDirectoryRecursive)+    (liftIO (createTempDirectory targetDir template))+    (liftIO . ignoringIOErrors . removeDirectoryRecursive) -ignoringIOErrors :: IO () -> IO ()+ignoringIOErrors :: MonadCatch m => m () -> m () ignoringIOErrors ioe = ioe `Exception.catch` (\e -> const (return ()) (e :: IOError))
temporary.cabal view
@@ -1,5 +1,5 @@ name:                temporary-version:             1.1.2.5+version:             1.2 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@@ -22,7 +22,8 @@     exposed-modules: System.IO.Temp     other-modules:   Distribution.Compat.Exception                      Distribution.Compat.TempFile-    build-depends:   base >= 3 && < 6, filepath >= 1.1 && < 1.4, directory >= 1.0 && < 1.3-+    build-depends:   base >= 3 && < 6, filepath >= 1.1 && < 1.4, directory >= 1.0 && < 1.3,+                     transformers >= 0.2.0.0 && < 0.4, exceptions >= 0.1.1 && < 0.2+         if !os(windows)         build-depends: unix >= 2.3 && < 2.8