
1 Feb
2008
1 Feb
'08
4:01 p.m.
Hello, I wrote a simple program to read the contents of a cdrom: module Main where import Text.Printf import System.IO import System.Posix.Types import System.Posix.IO main = do fd <- openFd "/dev/cdrom" ReadOnly Nothing defaultFileFlags readCdRom fd 4096 closeFd fd readCdRom fd byteCount = do (buf, actualByteCount) = fdRead fd bytecount readCdRom fd byteCount When it executed it read thousands of 4096 blocks as I expected. It then got a "hardware error" which I suspect was the "end of the CD", i.e. the begininng of the "unlasered" part of the CD. Is there a better and more graceful way to detect and handle "end of data"? Thanks, ,Vasili