From 7dfc802b753f21afcb656b13d30d49bc548ac150 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 17 Apr 2020 22:41:53 +0200 Subject: Reaktor.API: make configurable --- src/System/Posix/Files/Extended.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/System/Posix/Files/Extended.hs (limited to 'src/System/Posix/Files') 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 + -- cgit v1.2.3