1 -- !!! Test file positioning
3 module Main(main) where
7 import Directory (removeFile, doesFileExist)
8 #if defined(__MINGW32__)
9 import PrelHandle(hSetBinaryMode)
13 hIn <- openFile "hGetPosn001.in" ReadMode
14 # if defined(__MINGW32__)
15 hSetBinaryMode hIn True
17 f <- doesFileExist "hGetPosn001.out"
18 when f (removeFile "hGetPosn001.out")
19 hOut <- openFile "hGetPosn001.out" ReadWriteMode
20 # if defined(__MINGW32__)
21 hSetBinaryMode hOut True
27 hSeek hOut AbsoluteSeek 0
28 stuff <- hGetContents hOut
31 copy :: Handle -> Handle -> IO ()
33 try (hGetChar hIn) >>=
34 either (\ err -> if isEOFError err then return () else error "copy")
35 ( \ x -> hPutChar hOut x >> copy hIn hOut)