blob: da823590bceda1c31a74bc9fb568f679296b8cd4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
|