blob: 26f5abd9a747d298a958d064244e101e69835b3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
-- !!! test hIsEOF in various buffering situations
import System.IO
main = do
h <- openFile "hIsEOF002.hs" ReadMode
hSetBuffering h NoBuffering
hSeek h SeekFromEnd 0
hIsEOF h >>= print
hSeek h SeekFromEnd (-1)
hIsEOF h >>= print
hGetChar h >>= print
hSetBuffering h LineBuffering
hSeek h SeekFromEnd 0
hIsEOF h >>= print
hSeek h SeekFromEnd (-1)
hIsEOF h >>= print
hGetChar h >>= print
hSetBuffering h (BlockBuffering (Just 1))
hSeek h SeekFromEnd 0
hIsEOF h >>= print
hSeek h SeekFromEnd (-1)
hIsEOF h >>= print
hGetChar h >>= print
hSetBuffering h (BlockBuffering Nothing)
hSeek h SeekFromEnd 0
hIsEOF h >>= print
hSeek h SeekFromEnd (-1)
hIsEOF h >>= print
hGetChar h >>= print
hClose h
h <- openFile "hIsEOF002.out" WriteMode
hPutStrLn h "hello, world"
hClose h
h <- openFile "hIsEOF002.out" ReadWriteMode
hSetBuffering h NoBuffering
hSeek h SeekFromEnd 0
hIsEOF h >>= print
hPutChar h 'x'
hIsEOF h >>= print
hSeek h SeekFromEnd (-1)
hIsEOF h >>= print
hGetChar h >>= print
|