add whenM and unlessM
Just more golfing.. I am pretty sure something in a library somewhere can do this, but I have been unable to find it.
This commit is contained in:
parent
75a3f5027f
commit
c91929f693
16 changed files with 60 additions and 63 deletions
|
@ -7,7 +7,6 @@
|
|||
|
||||
module CopyFile (copyFile) where
|
||||
|
||||
import Control.Monad (when)
|
||||
import System.Directory (doesFileExist, removeFile)
|
||||
|
||||
import Utility
|
||||
|
@ -17,8 +16,7 @@ import qualified SysConfig
|
|||
- and because this allows easy access to features like cp --reflink. -}
|
||||
copyFile :: FilePath -> FilePath -> IO Bool
|
||||
copyFile src dest = do
|
||||
e <- doesFileExist dest
|
||||
when e $
|
||||
whenM (doesFileExist dest) $
|
||||
removeFile dest
|
||||
boolSystem "cp" [params, File src, File dest]
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue