×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    4

    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();
    ...but the method with

    Code:
    QFile file("/dev/cdrom");
    won't work! (/dev/cdrom is a symlink to /dev/sr0)

    Any hints?

    Thanks!
    Chris

  2. #2
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: Read block device /dev/cdrom

    Hi,

    Can you see this example here.

    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;
    The above might help you.

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    4

    Re: Read block device /dev/cdrom

    Ok, thanks for the hint!

  4. #4
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    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

  5. #5
    Registered User
    Join Date
    Feb 2012
    Posts
    4

    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)) {
        (...)
    }
    doesn't work ... dvd.open returns false!

  6. #6
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    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?

  7. #7
    Registered User
    Join Date
    Feb 2012
    Posts
    4

    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!

Similar Threads

  1. BT Device Class Help _ Please read!!
    By michaelmatthews in forum Bluetooth Technology
    Replies: 1
    Last Post: 2007-07-18, 17:03
  2. InputStream read() methods block forever
    By capricious28 in forum Mobile Java General
    Replies: 0
    Last Post: 2006-09-26, 04:31
  3. SDK CDROM request
    By gs_cmans in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2006-02-25, 08:37
  4. Block Ports read/write- RCommServ
    By Alicia_S60 in forum Symbian
    Replies: 0
    Last Post: 2005-07-21, 10:16
  5. I need a cdrom of Borland_v1_1_S60_Nokia_Edition.zip
    By songjw in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2003-05-08, 13:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •