How do I determine that I am at the "end" of a QIODevice?

I'm trying to find an algorithm to detect when the "end" is reached QIODevice

(which means no data will ever be readable). Currently my algorithm looks something like this:

  • for serial devices, wait for a signal readChannelFinished()

  • for regular files, read data continuously until atEnd()

    it returnstrue

However, the documentation for atEnd()

contains the following caveat:

For some devices, atEnd () may return true even if there is more data to read. This special case only applies to devices that generate data in direct response to read () calls (for example, / dev or / proc files on Unix and OS X, or console input / stdin on all platforms).

This is where my algorithm breaks down. My next idea was to constantly check the value bytesAvailable()

when reading from a regular file. This gave some very strange results for /dev/zero

: bytesAvailable()

returned 0

until I called read(amount)

, after which it indicated there were 16384 - amount

bytes left .

Is there any "correct" way to determine if more data is still readable from QIODevice

?

+3
c ++ qt qiodevice


source to share


No one has answered this question yet

Check out similar questions:

2416
How do you set, clear, and switch one bit?
1783
C ++ 11 introduced a standardized memory model. What does it mean? And how will this affect C ++ programming?
1709
How can I profile C ++ code running on Linux?
7
QNetworkAccessManager: post url from serial QIODevice
five
How to read data from QNetworkReply used by QWebPage?
1
Get stream data from Qt QMediaPlayer
1
How do I determine the total size of a QIODevice to read?
0
How to get rid of memcpy in QIoDevice
0
QIODevice Write at End
0
Subclassing QIODevice: Wrapper for QUdpSocket



All Articles
Loading...
X
Show
Funny
Dev
Pics