on master help sign in
rmFile: don't even try removing not existing files
2a53c10Heather
src/Util/System.hs+9−6
@@ -16,9 +16,9 @@ import System.Directory (getTemporaryDirectory
16 , removeFile
16 , removeFile
17 , removeDirectoryRecursive
17 , removeDirectoryRecursive
18 , createDirectoryIfMissing
18 , createDirectoryIfMissing
19− , doesDirectoryExist
19+ , doesFileExist
20 )
20 )
21−import System.FilePath ((</>), normalise, isAbsolute, dropFileName)
21+import System.FilePath ((</>), normalise)
22import System.IO
22import System.IO
23import System.Info
23import System.Info
24import System.IO.Error
24import System.IO.Error
@@ -76,10 +76,13 @@ withTempdir subdir callback
76 return result
76 return result
77
77
78rmFile :: FilePath -> IO ()
78rmFile :: FilePath -> IO ()
79+rmFile f = do
80+ fileExists <- doesFileExist f
81+ when fileExists
79−rmFile f = do putStrLn $ "Removing " ++ f
82+ $ do putStrLn $ "Removing " ++ f
80− catchIO (removeFile f)
83+ catchIO (removeFile f)
81− (\ioerr -> putStrLn $ "WARNING: Cannot remove file "
84+ (\ioerr -> putStrLn $ "WARNING: Cannot remove file "
82− ++ f ++ ", Error msg:" ++ show ioerr)
85+ ++ f ++ ", Error msg:" ++ show ioerr)
83
86
84setupBundledCC :: IO()
87setupBundledCC :: IO()
85#ifdef FREESTANDING
88#ifdef FREESTANDING