main = do d <- getCurrentDirectory
flip finally (setCurrentDirectory d) $ do
setCurrentDirectory "copyFile"
- ignoreExceptions $ removeFile to
+ tryIO $ removeFile to
cs_before <- getDirectoryContents "."
putStrLn "Before:"
print $ sort cs_before
print $ sort cs_before
readFile to >>= print
+tryIO :: IO a -> IO (Either IOException a)
+tryIO = try
+
from, to :: FilePath
from = "source"
to = "target"