ZVON > References > Haskell reference |
Intro / Search / ZVON |
| Indexes | Syntax | Prelude | Ratio | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | >> IO << | Directory | System | Time | Locale | CPUTime | Random |
Module: | IO |
---|---|
Function: | hSeek |
Type: | Handle -> SeekMode -> Integer -> IO () |
Description: |
Computation hSeek hdl mode i sets the position of handle hdl depending on mode. If mode is: * AbsoluteSeek: the position of hdl is set to i. * RelativeSeek: the position of hdl is set to offset i from the current position. * SeekFromEnd: the position of hdl is set to offset i from the end of the file. The offset is given in terms of 8-bit bytes. Error reporting: the hSeek computation may fail with: isPermissionError if a system resource limit would be exceeded. |
Related: |
File: /tmp/foo.txt : Hello, world! Good bye!
Program source: import IO main = do hdl <- openFile "/tmp/foo.txt" ReadMode a <- hGetChar hdl hSeek hdl AbsoluteSeek 4 b <- hGetChar hdl print (a,b) c <- hGetChar hdl hSeek hdl RelativeSeek 3 d <- hGetChar hdl print (c,d) e <- hGetChar hdl hSeek hdl SeekFromEnd (-3) f <- hGetChar hdl print (e,f)
Output: ('H','o')
Output: (',','r')
Output: ('l','y')