<div>Hello,</div>
<div> </div>
<div> I wrote a simple program to read the contents of a cdrom:</div>
<div> </div>
<div>module Main where</div>
<div> </div>
<div>import Text.Printf</div>
<div>import System.IO</div>
<div>import System.Posix.Types</div>
<div>import <a href="http://System.Posix.IO">System.Posix.IO</a></div>
<div> </div>
<div>main = do</div>
<div> fd <- openFd "/dev/cdrom" ReadOnly Nothing defaultFileFlags</div>
<div> readCdRom fd 4096</div>
<div> closeFd fd</div>
<div> </div>
<div>readCdRom fd byteCount = do</div>
<div> (buf, actualByteCount) = fdRead fd bytecount</div>
<div> readCdRom fd byteCount</div>
<div> </div>
<div>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"?</div>
<div> </div>
<div>Thanks, ,Vasili</div>