X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2FcopyFile002.hs;fp=tests%2FcopyFile002.hs;h=332d762b5573dac2fb09fd3f8a3e72061c356b71;hb=70a84e093a384469b229afc8cca3004ce4971586;hp=0000000000000000000000000000000000000000;hpb=8af1abacf899be128c3b195696b24c9fc81bc282;p=haskell-directory.git diff --git a/tests/copyFile002.hs b/tests/copyFile002.hs new file mode 100644 index 0000000..332d762 --- /dev/null +++ b/tests/copyFile002.hs @@ -0,0 +1,28 @@ + +module Main (main) where + +import Control.Exception +import Data.List +import System.Directory +import System.IO + +-- like copyFile001, but moves a file in the current directory +-- See bug #1652 +main :: IO () +main = do d <- getCurrentDirectory + flip finally (setCurrentDirectory d) $ do + setCurrentDirectory "copyFile" + try $ removeFile to + cs_before <- getDirectoryContents "." + putStrLn "Before:" + print $ sort cs_before + copyFile from to + cs_before <- getDirectoryContents "." + putStrLn "After:" + print $ sort cs_before + readFile to >>= print + +from, to :: FilePath +from = "source" +to = "target" +