[project @ 2000-05-15 11:18:58 by rrt]
[ghc-hetmet.git] / ghc / tests / io / should_run / io018.hs
index 02b24bb..6320c97 100644 (file)
@@ -1,17 +1,20 @@
 -- !!! Testing RW handles 
 module Main(main) where
 
-
 import IO
-import Directory (removeFile)
+import IOExts
+import Directory (removeFile, doesFileExist)
+import Monad
 
 -- This test is weird, full marks to whoever dreamt it up!
 
 main :: IO ()
 main = do
    let username = "io018.inout"
+   f <- doesFileExist username
+   when f (removeFile username)
    cd <- openFile username ReadWriteMode
-   removeFile username
+   hSetBinaryMode cd True
    hSetBuffering stdin NoBuffering
    hSetBuffering stdout NoBuffering
    hSetBuffering cd NoBuffering
@@ -38,4 +41,3 @@ speak cd = do
         if ready then (do { ch <- getChar; hPutChar cd ch})
          else return ())
      speak cd
-