diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2017-08-29 13:41:20 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2017-08-31 06:37:07 +0000 |
commit | 29ef0d2bccd1874e20de94485ee05777c3a95c5d (patch) | |
tree | bd8a68a5132981b3d33da8bbbed9afe2748c5672 /src/corelib/io | |
parent | 3088f73cf4605f7a3a0d39605d8f1191c1b4795c (diff) |
Simplify QDataStream::skipRawData()
... by using the new QIODevice::skip() function.
Change-Id: I943c4feb896d677f3150da542950595d7f485e75
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qdatastream.cpp | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 9044ad74b1..1486d3630c 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -1385,32 +1385,13 @@ int QDataStream::writeRawData(const char *s, int len) int QDataStream::skipRawData(int len) { CHECK_STREAM_PRECOND(-1) + if (q_status != Ok && dev->isTransactionStarted()) + return -1; - if (dev->isSequential()) { - char buf[4096]; - int sumRead = 0; - - while (len > 0) { - int blockSize = qMin(len, (int)sizeof(buf)); - int n = readBlock(buf, blockSize); - if (n == -1) - return -1; - if (n == 0) - return sumRead; - - sumRead += n; - len -= blockSize; - } - return sumRead; - } else { - qint64 pos = dev->pos(); - qint64 size = dev->size(); - if (pos + len > size) - len = size - pos; - if (!dev->seek(pos + len)) - return -1; - return len; - } + const int skipResult = dev->skip(len); + if (skipResult != len) + setStatus(ReadPastEnd); + return skipResult; } QT_END_NAMESPACE |