on master help sign in
rmFile: don't even try removing not existing files

Often when I run idris --clean (specially automated) I see warnings due trying to remove files which are not present. I wish to not see those annoying messages

commit2a53c10f75b25639eee48c760dc61d329bba6d82 authorHeather <heather@live.ru> dateTue 17 Nov 2015, 15:09 (11 years ago) parent140d06a
1 file changed+9−6
src/Util/System.hs+9−6
src/Util/System.hs+9−6
@@ -16,9 +16,9 @@ import System.Directory (getTemporaryDirectory
1616 , removeFile
1717 , removeDirectoryRecursive
1818 , createDirectoryIfMissing
19− , doesDirectoryExist
19+ , doesFileExist
2020 )
21−import System.FilePath ((</>), normalise, isAbsolute, dropFileName)
21+import System.FilePath ((</>), normalise)
2222import System.IO
2323import System.Info
2424import System.IO.Error
@@ -76,10 +76,13 @@ withTempdir subdir callback
7676 return result
7777
7878rmFile :: FilePath -> IO ()
79−rmFile f = do putStrLn $ "Removing " ++ f
80− catchIO (removeFile f)
81− (\ioerr -> putStrLn $ "WARNING: Cannot remove file "
82− ++ f ++ ", Error msg:" ++ show ioerr)
79+rmFile f = do
80+ fileExists <- doesFileExist f
81+ when fileExists
82+ $ do putStrLn $ "Removing " ++ f
83+ catchIO (removeFile f)
84+ (\ioerr -> putStrLn $ "WARNING: Cannot remove file "
85+ ++ f ++ ", Error msg:" ++ show ioerr)
8386
8487setupBundledCC :: IO()
8588#ifdef FREESTANDING