summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-06 13:13:13 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-06 13:13:13 -0400
commit993e6459a38817a9062aafae7552a668c2db7a31 (patch)
tree900b38c923644d9f8b7eaf92ec240aa610551780 /Utility
parent723eb19bbf30d502cb6979655b8013de49ce0b5e (diff)
factor out nukeFile
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Directory.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/Utility/Directory.hs b/Utility/Directory.hs
index 5bfd49a9c..52f2396d7 100644
--- a/Utility/Directory.hs
+++ b/Utility/Directory.hs
@@ -88,6 +88,13 @@ moveFile src dest = tryIO (rename src dest) >>= onrename
(Left _) -> return False
(Right s) -> return $ isDirectory s
+{- Removes a file, which may or may not exist.
+ -
+ - Note that an exception is thrown if the file exists but
+ - cannot be removed. -}
+nukeFile :: FilePath -> IO ()
+nukeFile file = whenM (doesFileExist file) $ removeFile file
+
{- Runs an action in another directory. -}
bracketCd :: FilePath -> IO a -> IO a
bracketCd dir a = go =<< getCurrentDirectory