Repository : ssh://darcs.haskell.org//srv/darcs/packages/directory

On branch  : ghc-7.6

http://hackage.haskell.org/trac/ghc/changeset/2170d15ed5bf09c5e87355e0bd0e390fc915575d

>---------------------------------------------------------------

commit 2170d15ed5bf09c5e87355e0bd0e390fc915575d
Author: Leonid Onokhov <[email protected]>
Date:   Sun Sep 23 00:22:00 2012 +0400

    Fix build for base < 4.6
    
    Build on 7.0.3 and up. Maybe lower.

>---------------------------------------------------------------

 System/Directory.hs |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/System/Directory.hs b/System/Directory.hs
index 1e44248..cfe7cd9 100644
--- a/System/Directory.hs
+++ b/System/Directory.hs
@@ -85,7 +85,7 @@ import System.FilePath
 import System.IO
 import System.IO.Error
 import Control.Monad           ( when, unless )
-import Control.Exception.Base
+import Control.Exception.Base as E
 
 #ifdef __NHC__
 import Directory -- hiding ( getDirectoryContents
@@ -127,11 +127,18 @@ import qualified System.Win32 as Win32
 import qualified System.Posix as Posix
 #endif
 
-#if __GLASGOW_HASKELL__ < 703
+#if __GLASGOW_HASKELL__ == 702
+-- fileSystemEncoding exists only in base-4.4
 getFileSystemEncoding :: IO TextEncoding
 getFileSystemEncoding = return fileSystemEncoding
 #endif
 
+#if __GLASGOW_HASKELL__ < 702
+-- just like in base >= 4.4
+catchIOError :: IO a -> (IOError -> IO a) -> IO a
+catchIOError = E.catch
+#endif
+
 #endif /* __GLASGOW_HASKELL__ */
 
 {- $intro
@@ -392,7 +399,7 @@ createDirectoryIfMissing create_parents path0
 
     createDir :: FilePath -> (IOException -> IO ()) -> IO ()
     createDir dir notExistHandler = do
-      r <- try $ createDirectory dir
+      r <- E.try $ createDirectory dir
       case (r :: Either IOException ()) of
         Right ()                   -> return ()
         Left  e
@@ -416,7 +423,7 @@ createDirectoryIfMissing create_parents path0
                  then return ()
                  else throw e
 #endif
-              ) `catch` ((\_ -> return ()) :: IOException -> IO ())
+              ) `E.catch` ((\_ -> return ()) :: IOException -> IO ())
           | otherwise              -> throw e
 #endif  /* !__NHC__ */
 
@@ -482,7 +489,7 @@ removeDirectoryRecursive startLoc = do
   removeDirectory startLoc
   where
     rm :: FilePath -> IO ()
-    rm f = do temp <- try (removeFile f)
+    rm f = do temp <- E.try (removeFile f)
               case temp of
                 Left e  -> do isDir <- doesDirectoryExist f
                               -- If f is not a directory, re-throw the error
@@ -957,7 +964,7 @@ doesDirectoryExist name =
    (do stat <- Posix.getFileStatus name
        return (Posix.isDirectory stat))
 #endif
-   `catch` ((\ _ -> return False) :: IOException -> IO Bool)
+   `E.catch` ((\ _ -> return False) :: IOException -> IO Bool)
 
 {- |The operation 'doesFileExist' returns 'True'
 if the argument file exists and is not a directory, and 'False' otherwise.
@@ -971,7 +978,7 @@ doesFileExist name =
    (do stat <- Posix.getFileStatus name
        return (not (Posix.isDirectory stat)))
 #endif
-   `catch` ((\ _ -> return False) :: IOException -> IO Bool)
+   `E.catch` ((\ _ -> return False) :: IOException -> IO Bool)
 
 {- |The 'getModificationTime' operation returns the
 clock time at which the file or directory was last modified.
@@ -1071,11 +1078,11 @@ getHomeDirectory :: IO FilePath
 getHomeDirectory =
   modifyIOError ((`ioeSetLocation` "getHomeDirectory")) $ do
 #if defined(mingw32_HOST_OS)
-    r <- try $ Win32.sHGetFolderPath nullPtr Win32.cSIDL_PROFILE nullPtr 0
+    r <- E.try $ Win32.sHGetFolderPath nullPtr Win32.cSIDL_PROFILE nullPtr 0
     case (r :: Either IOException String) of
       Right s -> return s
       Left  _ -> do
-        r1 <- try $ Win32.sHGetFolderPath nullPtr Win32.cSIDL_WINDOWS nullPtr 0
+        r1 <- E.try $ Win32.sHGetFolderPath nullPtr Win32.cSIDL_WINDOWS 
nullPtr 0
         case r1 of
           Right s -> return s
           Left  e -> ioError (e :: IOException)



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to