PDA

View Full Version : How to read CD with read?



vishal.chauhan
28th June 2007, 12:43
Hi All,

I m using Qt 4.1.5 on my MAC.
I am using the following code to read the HardDisk or any other Drive.



fileDescriptor = open ( DriveName, O_RDONLY );
lseek(fileDescriptor,(off_t) SectNo*SECTSIZE, SEEK_SET);
numBytes = read( fileDescriptor, Buffer, Size );

where for disk I have Drive Name as /dev/rdisk0.

But if I read CD by the above code it is returning non negative value in fileDescriptor and lseek also working right but in the read function is is returning -1.


If some one know why it is not working with CD then plz help me.


Thanks.

wysota
28th June 2007, 12:57
Do you want to read files or the raw ISO? Reading from /dev/cdrom or similar should work fine... Provided you have permissions to do that.

vishal.chauhan
28th June 2007, 13:47
Thanks for Reply.

Actually I want to read raw ISO.

I think I have permission because when I open the CD with
fileDescriptor = open ( DriveName, O_RDONLY );
it return 14 that it is opening the file but problem is when I read the disk it is returning -1.

wysota
28th June 2007, 21:39
Is the disk mounted at that time?

vishal.chauhan
29th June 2007, 06:18
Yes. It is showing it in the Finder and I can see the Conetnts of it.

wysota
29th June 2007, 08:36
Can you unmount it and try again?

vishal.chauhan
29th June 2007, 09:20
Thanks.

Now I m able to do it.

Actually I m reading from disk by adding r before disk as /dev/rdisk0 but to CD I have just have to read like /dev/disk2.

Thanks for Reply.