diff options
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qwindowspipereader.cpp | 19 | ||||
-rw-r--r-- | src/corelib/io/qwindowspipereader_p.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index c3ac51df94..5415ad7830 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -233,6 +233,25 @@ qint64 QWindowsPipeReader::readLine(char *data, qint64 maxlen) } /*! + Skips up to \c{maxlen} bytes from the internal read buffer. + */ +qint64 QWindowsPipeReader::skip(qint64 maxlen) +{ + QMutexLocker locker(&mutex); + + const qint64 skippedSoFar = readBuffer.skip(qMin(actualReadBufferSize, maxlen)); + actualReadBufferSize -= skippedSoFar; + + if (!pipeBroken) { + startAsyncReadHelper(&locker); + if (skippedSoFar == 0) + return -2; // signal EWOULDBLOCK + } + + return skippedSoFar; +} + +/*! Returns \c true if a complete line of data can be read from the buffer. */ bool QWindowsPipeReader::canReadLine() const diff --git a/src/corelib/io/qwindowspipereader_p.h b/src/corelib/io/qwindowspipereader_p.h index e2190d67d9..5eb62cb393 100644 --- a/src/corelib/io/qwindowspipereader_p.h +++ b/src/corelib/io/qwindowspipereader_p.h @@ -79,6 +79,7 @@ public: qint64 bytesAvailable() const; qint64 read(char *data, qint64 maxlen); qint64 readLine(char *data, qint64 maxlen); + qint64 skip(qint64 maxlen); bool canReadLine() const; DWORD checkPipeState(); bool checkForReadyRead() { return consumePendingAndEmit(false); } |