Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Looking for dd application as shared library
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.
koahnig last edited by
Is "QProcess":http://doc.qt.nokia.com/4.7/qprocess.html not an option for you ?
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.
lgeyer last edited by
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).
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.
goetz last edited by
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?
In Unix, a file is a file is a "file.":http://ph7spot.com/musings/in-unix-everything-is-a-file
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.
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.
dangelog last edited by
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).