diff options
author | João Abecasis <joao@abecasis.name> | 2009-10-20 13:39:06 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-10-21 11:46:08 (GMT) |
commit | 6f52892206b155451e7b24cdbb1b4ab6569153e9 (patch) | |
tree | a48982ca819dbc06d07d3dbb40dd00a4578377bb /src/corelib/io/qfile.cpp | |
parent | badfa3435f740ec7120b2ed3367fa2be50382136 (diff) | |
download | Qt-6f52892206b155451e7b24cdbb1b4ab6569153e9.zip Qt-6f52892206b155451e7b24cdbb1b4ab6569153e9.tar.gz Qt-6f52892206b155451e7b24cdbb1b4ab6569153e9.tar.bz2 |
Get file position when attaching an open file descriptor to QFile
This was already being done when attaching to FILE* streams. Doing the
same here makes the API consistent and more usable. Namely, one can use
QFile::pos() to obtain the file position.
Test case verifies this doesn't break support for sequential files. More
thorough test case included in large file support test.
Reviewed-by: Thiago Macieira
Diffstat (limited to 'src/corelib/io/qfile.cpp')
-rw-r--r-- | src/corelib/io/qfile.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 64d8ef3..4dd6185 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1120,8 +1120,13 @@ bool QFile::open(int fd, OpenMode mode) } if(d->openExternalFile(mode, fd)) { QIODevice::open(mode); - if (mode & Append) + if (mode & Append) { seek(size()); + } else { + qint64 pos = (qint64)QT_LSEEK(fd, QT_OFF_T(0), SEEK_CUR); + if (pos != -1) + seek(pos); + } return true; } return false; |