2023-12-09 12:58:59 +00:00
|
|
|
module Server.Util where
|
|
|
|
|
|
|
|
import Control.Exception
|
|
|
|
|
|
|
|
import System.Directory
|
|
|
|
|
|
|
|
import System.IO.Error
|
|
|
|
|
2023-12-09 13:18:10 +00:00
|
|
|
-- | Remove a file if it exists
|
|
|
|
removeIfExists
|
|
|
|
:: FilePath -- File to remove
|
|
|
|
-> IO ()
|
2023-12-09 12:58:59 +00:00
|
|
|
removeIfExists fileName = removeFile fileName `catch` handleExists
|
|
|
|
where handleExists e
|
|
|
|
| isDoesNotExistError e = return ()
|
|
|
|
| otherwise = throwIO e
|