Read block device /dev/cdrom
Hi all,
how can I read a block device (/dev/cdrom)? This works for files:
[CODE]QFile file("/home/chris/backup.img");
file.open(QFile::ReadOnly);
while (!file.atEnd()) {
QByteArray data = file.read(2048);
(...)
}
file.close();
[/CODE]
...but the method with
[CODE]QFile file("/dev/cdrom");[/CODE]
won't work! (/dev/cdrom is a symlink to /dev/sr0)
Any hints?
Thanks!
Chris
Re: Read block device /dev/cdrom
Hi,
Can you see this example [URL="http://www.developer.nokia.com/Community/Wiki/How_to_perform_file_IO_using_QDataStream_in_Qt"]here[/URL].
The above link shows how to use QDataStream api for IO devices.
[CODE]
QFile read("c://test.txt");
read.open(QIODevice::ReadOnly);
QDataStream in(&read); // read the data serialized from the file
QString str;
in >> str;
[/CODE]
The above might help you.
Re: Read block device /dev/cdrom
Re: Read block device /dev/cdrom
QFile open works for block devices too.
No matters if /dev/cdrom is a symlink to sr0.
#include <QtCore/QCoreApplication>
#include <QFile>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QFile file("/dev/cdrom");
file.open(QFile::ReadOnly);
qDebug() << "XXX" << file.readAll().size();
return a.exec();
}
The code you see above prints out
XXX 732909568
Re: Read block device /dev/cdrom
Ah yes, it's a symlink! Thanks for the hint!
Another problem is, on windows
[CODE]QFile dvd("D:");
if (dvd.open(QIODevice::ReadOnly)) {
(...)
}[/CODE]
doesn't work ... [B]dvd.open[/B] returns false!
Re: Read block device /dev/cdrom
Of course it does, windows manages directories in a different way.
You have to use QDir to access to D:
BTW what's your target?
Re: Read block device /dev/cdrom
I want to read all raw data from the dvd to calculate a md5 checksum and compare it with the md5 sum of the image ... to check, if burn process 100% successful!