aboutsummaryrefslogtreecommitdiffstats
path: root/src/System/Posix
diff options
context:
space:
mode:
Diffstat (limited to 'src/System/Posix')
-rw-r--r--src/System/Posix/Files/Extended.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/System/Posix/Files/Extended.hs b/src/System/Posix/Files/Extended.hs
new file mode 100644
index 0000000..da82359
--- /dev/null
+++ b/src/System/Posix/Files/Extended.hs
@@ -0,0 +1,17 @@
+module System.Posix.Files.Extended
+ ( module Exports
+ , removeIfExists
+ ) where
+
+import qualified System.Posix.Files as Exports
+
+import Control.Exception (catch, throwIO)
+import System.IO.Error (isDoesNotExistError)
+import System.Posix.Files (removeLink)
+
+removeIfExists :: FilePath -> IO ()
+removeIfExists fileName = removeLink fileName `catch` handleExists
+ where handleExists e
+ | isDoesNotExistError e = return ()
+ | otherwise = throwIO e
+