import the Haskell 98 module Control.Exception.Base instead
[haskell-directory.git] / System / Directory.hs
index 5298322..d7a6dc6 100644 (file)
@@ -77,7 +77,7 @@ import System.FilePath
 import System.IO
 import System.IO.Error hiding ( catch, try )
 import Control.Monad           ( when, unless )
-import Control.Exception
+import Control.Exception.Base
 
 #ifdef __NHC__
 import Directory
@@ -545,8 +545,8 @@ copyFile :: FilePath -> FilePath -> IO ()
 #ifdef __NHC__
 copyFile fromFPath toFPath =
     do readFile fromFPath >>= writeFile toFPath
-       try (copyPermissions fromFPath toFPath)
-       return ()
+       Prelude.catch (copyPermissions fromFPath toFPath)
+                     (\_ -> return ())
 #else
 copyFile fromFPath toFPath =
     copy `Prelude.catch` (\exc -> throw $ ioeSetLocation exc "copyFile")
@@ -554,11 +554,12 @@ copyFile fromFPath toFPath =
                  bracketOnError openTmp cleanTmp $ \(tmpFPath, hTmp) ->
                  do allocaBytes bufferSize $ copyContents hFrom hTmp
                     hClose hTmp
-                    ignoreExceptions $ copyPermissions fromFPath tmpFPath
+                    ignoreIOExceptions $ copyPermissions fromFPath tmpFPath
                     renameFile tmpFPath toFPath
           openTmp = openBinaryTempFile (takeDirectory toFPath) ".copyFile.tmp"
-          cleanTmp (tmpFPath, hTmp) = do ignoreExceptions $ hClose hTmp
-                                         ignoreExceptions $ removeFile tmpFPath
+          cleanTmp (tmpFPath, hTmp)
+              = do ignoreIOExceptions $ hClose hTmp
+                   ignoreIOExceptions $ removeFile tmpFPath
           bufferSize = 1024
 
           copyContents hFrom hTo buffer = do
@@ -566,6 +567,10 @@ copyFile fromFPath toFPath =
                   when (count > 0) $ do
                           hPutBuf hTo buffer count
                           copyContents hFrom hTo buffer
+
+          ignoreIOExceptions io = io `catch` ioExceptionIgnorer
+          ioExceptionIgnorer :: IOException -> IO ()
+          ioExceptionIgnorer _ = return ()
 #endif
 
 -- | Given path referring to a file or directory, returns a
@@ -806,20 +811,18 @@ exists and is a directory, and 'False' otherwise.
 -}
 
 doesDirectoryExist :: FilePath -> IO Bool
-doesDirectoryExist name = 
- catchAny
+doesDirectoryExist name =
    (withFileStatus "doesDirectoryExist" name $ \st -> isDirectory st)
-   (\ _ -> return False)
+   `catch` ((\ _ -> return False) :: IOException -> IO Bool)
 
 {- |The operation 'doesFileExist' returns 'True'
 if the argument file exists and is not a directory, and 'False' otherwise.
 -}
 
 doesFileExist :: FilePath -> IO Bool
-doesFileExist name = do 
- catchAny
+doesFileExist name =
    (withFileStatus "doesFileExist" name $ \st -> do b <- isDirectory st; return (not b))
-   (\ _ -> return False)
+   `catch` ((\ _ -> return False) :: IOException -> IO Bool)
 
 {- |The 'getModificationTime' operation returns the
 clock time at which the file or directory was last modified.
@@ -1035,7 +1038,7 @@ getTemporaryDirectory = do
     `Prelude.catch` \e -> if isDoesNotExistError e then return "/tmp"
                           else throw e
 #else
-    `catch` (\ex -> return "/tmp")
+    `Prelude.catch` (\ex -> return "/tmp")
 #endif
 #endif