c536f7d03a10d45f4eb466cf206faf8424c653b3
[ghc-hetmet.git] / ghc / tests / lib / IO / misc001.hs
1 import IO
2
3 import System (getArgs)
4 import Char   (toUpper)
5 import Directory (removeFile, doesFileExist)
6
7 main   =  do
8   [f1,f2] <- getArgs
9   h1 <- openFile f1 ReadMode
10   f <- doesFileExist f2
11   if f then removeFile f2 else return ()
12   h2 <- openFile f2 WriteMode
13   copyFile h1 h2
14   hClose h1
15   hClose h2
16
17 copyFile h1 h2 = do
18   eof <- hIsEOF h1
19   if eof 
20         then return ()
21         else do
22   c <- hGetChar h1
23   c <- hPutChar h2 (toUpper c)
24   copyFile h1 h2