diff options
Diffstat (limited to 'tests/auto/corelib/io/qfile/tst_qfile.cpp')
-rw-r--r-- | tests/auto/corelib/io/qfile/tst_qfile.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 32165ad2b8..7bf45be58c 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -2086,6 +2086,7 @@ public: uint ownerId(FileOwner) const { return 0; } QString owner(FileOwner) const { return QString(); } QDateTime fileTime(FileTime) const { return QDateTime(); } + bool setFileTime(const QDateTime &newDate, FileTime time) { return false; } private: int number; @@ -3184,22 +3185,39 @@ static qint64 streamExpectedSize(int fd) QT_STATBUF sb; if (QT_FSTAT(fd, &sb) != -1) return sb.st_size; + qErrnoWarning("Could not fstat fd %d", fd); return 0; } static qint64 streamCurrentPosition(int fd) { - QT_OFF_T pos = QT_LSEEK(fd, 0, SEEK_CUR); - if (pos != -1) - return pos; + QT_STATBUF sb; + if (QT_FSTAT(fd, &sb) != -1) { + QT_OFF_T pos = -1; + if ((sb.st_mode & QT_STAT_MASK) == QT_STAT_REG) + pos = QT_LSEEK(fd, 0, SEEK_CUR); + if (pos != -1) + return pos; + // failure to lseek() is not a problem + } else { + qErrnoWarning("Could not fstat fd %d", fd); + } return 0; } static qint64 streamCurrentPosition(FILE *f) { - QT_OFF_T pos = QT_FTELL(f); - if (pos != -1) - return pos; + QT_STATBUF sb; + if (QT_FSTAT(QT_FILENO(f), &sb) != -1) { + QT_OFF_T pos = -1; + if ((sb.st_mode & QT_STAT_MASK) == QT_STAT_REG) + pos = QT_FTELL(f); + if (pos != -1) + return pos; + // failure to ftell() is not a problem + } else { + qErrnoWarning("Could not fstat fd %d", QT_FILENO(f)); + } return 0; } |