Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Looking for dd application as shared library

Looking for dd application as shared library

Scheduled Pinned Locked Moved C++ Gurus
9 Posts 6 Posters 3.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qttrekker
    wrote on last edited by
    #1

    Does anyone know if the dd source code has been developed into a library? I'd like to implement a few dd functions in my qt application but I really don't have the expertise to develop dd into a library. If a libdd existed that would greatly simplify the process of integrating dd into my application.

    http://cyberknights.com.au/download/dd.c

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Is "QProcess":http://doc.qt.nokia.com/4.7/qprocess.html not an option for you ?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qttrekker
        wrote on last edited by
        #3

        I need to access the contents of the dd buffer as data is being read. I've tried a few tests with QProcess including piping the output from dd but it just wasn't a reliable solution. I also need the application to be portable and I'm not sure if dd can even be compiled on Windows.

        I need dd to return the contents of the buffer each time it's filled. If I use QProcess then my only option is to read it from stdout which is not the ideal solution. For example, if I were to run "dd bs=2048" then I need the 2048 bytes to be returned. If dd was developed as a library then I should theoretically be able to code a while loop to read 2048 bytes at a time and then access the buffer data within the loop.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          What kind of functions do you need? Is QFile respectively QIODevice not an appropriate dd substitute for you?

          In addition, the code you have linked is released under the terms of the GPL. This means that any code that you will build around it has to be released under the terms of the GPL as well (ie. open source).

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qttrekker
            wrote on last edited by
            #5

            The dd application will accept any path as the input. It doesn't matter if it's a file, folder, sequential device and it doesn't matter if you're trying to access it directly or mounted. You can use /dev/dvd or /usr/bin/file or any other path as the input. It doesn't matter if the input path is a single file or multiple files which would be the case with /dev/dvd. The output is always a single stream of data which is exactly what I need for my application. I've searched for a similar library but I haven't found anything that provides the same functions as dd.

            The GPL issue isn't a problem since it will be for an open source application.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              From a short scan of the source code you linked, dd does not do any special handling of the device nodes like /dev/dvd. So I would suspect QFile to behave the same way. Did you try it already?

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mlong
                wrote on last edited by
                #7

                In Unix, a file is a file is a "file.":http://ph7spot.com/musings/in-unix-everything-is-a-file

                Software Engineer
                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  qttrekker
                  wrote on last edited by
                  #8

                  QFile does not support sequential devices like /dev/dvd. It's only possible to read data into a buffer one time with QFile on a sequential device.
                  @
                  QFile dvd("/dev/dvd");
                  dvd.open(QIODevice::ReadOnly);
                  bytesRead = dvd.read(buffer, max);
                  @
                  The position is not saved after data is read and you can't specify a start position to read from. If you check the docs they specify that seek(), pos(), atEnd() and peek() cannot be used for a sequential device. There is one inconsistency though, according to the docs the seek method should return false for sequential devices but dvd.seek(2048) always returns true. Not sure if this is the correct behavior or a bug.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dangelog
                    wrote on last edited by
                    #9

                    The problem is that that QFile usage is a little "abuse" -- QFile is meant for random-access "ordinary" files, not sequential special files. Apart from that, you can just us it like that (possibly using QIODevice::Unbuffered), or since you can assume you're under unix, skip QFile and just use the low-level open(2) and read(2).

                    Software Engineer
                    KDAB (UK) Ltd., a KDAB Group company

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved