@@ -16,7 +16,6 @@ import System.Directory (getTemporaryDirectory
16 , removeFile
16 , removeFile
17 , removeDirectoryRecursive
17 , removeDirectoryRecursive
18 , createDirectoryIfMissing
18 , createDirectoryIfMissing
21import System.FilePath ((</>), normalise)
20import System.FilePath ((</>), normalise)
22import System.IO
21import System.IO
@@ -66,7 +65,7 @@ isATTY = do
66withTempdir :: String -> (FilePath -> IO a) -> IO a
65withTempdir :: String -> (FilePath -> IO a) -> IO a
67withTempdir subdir callback
66withTempdir subdir callback
68 = do dir <- getTemporaryDirectory
67 = do dir <- getTemporaryDirectory
69− let tmpDir = (normalise dir) </> subdir
68+ let tmpDir = normalise dir </> subdir
70 removeLater <- catchIO (createDirectoryIfMissing True tmpDir >> return True)
69 removeLater <- catchIO (createDirectoryIfMissing True tmpDir >> return True)
71 (\ ioError -> if isAlreadyExistsError ioError then return False
70 (\ ioError -> if isAlreadyExistsError ioError then return False
72 else throw ioError
71 else throw ioError
@@ -77,12 +76,14 @@ withTempdir subdir callback
78rmFile :: FilePath -> IO ()
77rmFile :: FilePath -> IO ()
79rmFile f = do
78rmFile f = do
80− fileExists <- doesFileExist f
82− $ do putStrLn $ "Removing " ++ f
83− catchIO (removeFile f)
79+ result <- try (removeFile f)
81+ Right _ -> putStrLn $ "Removed: " ++ f
82+ Left err -> handleExists err
84+ | isDoesNotExistError e = return ()
84− (\ioerr -> putStrLn $ "WARNING: Cannot remove file "
85+ | otherwise = putStrLn $ "WARNING: Cannot remove file "
85− ++ f ++ ", Error msg:" ++ show ioerr)
86+ ++ f ++ ", Error msg:" ++ show e
87setupBundledCC :: IO()
88setupBundledCC :: IO()
88#ifdef FREESTANDING
89#ifdef FREESTANDING