Fix these tests
[haskell-directory.git] / tests / copyFile002.hs
1
2 module Main (main) where
3
4 import Control.Exception
5 import Data.List
6 import System.Directory
7 import System.IO
8
9 -- like copyFile001, but moves a file in the current directory
10 -- See bug #1652
11 main :: IO ()
12 main = do d <- getCurrentDirectory
13           flip finally (setCurrentDirectory d) $ do
14           setCurrentDirectory "copyFile"
15           tryIO $ removeFile to
16           cs_before <- getDirectoryContents "."
17           putStrLn "Before:"
18           print $ sort cs_before
19           copyFile from to
20           cs_before <- getDirectoryContents "."
21           putStrLn "After:"
22           print $ sort cs_before
23           readFile to >>= print
24
25 tryIO :: IO a -> IO (Either IOException a)
26 tryIO = try 
27
28 from, to :: FilePath
29 from = "source"
30 to   = "target"
31