hIsSeekable function takes a handle and
return IO True, if the handle is seekable, else IO False. Not all handles are
seekable, for example, a handle associated with socket is not seekable.
Prelude System.IO> :t hIsSeekable
hIsSeekable :: Handle -> IO Bool
FileUtil.hs
import System.IO main = do putStrLn "Enter file name (Including full path) to read" fileName <- getLine fileHandle <- openFile fileName ReadMode isSeekable <- hIsSeekable fileHandle putStrLn $ "Is file handle seekable " ++ show isSeekable
$ runghc FileUtil.hs Enter file name (Including full path) to read today.txt Is file handle seekable True
No comments:
Post a Comment