[Haskell-cafe] reading from the cdrom drive on Red Hat

Galchin Vasili vigalchin at gmail.com
Fri Feb 1 16:01:52 EST 2008


      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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080201/3a279362/attachment.htm

More information about the Haskell-Cafe mailing list