diff options
author | Shane Kearns <ext-shane.2.kearns@nokia.com> | 2012-05-30 10:59:59 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-09 06:46:12 (GMT) |
commit | 92c458b3521909c9db200beb80293a5c64b9b5f8 (patch) | |
tree | 81f7911a219220c45297887ee3aabdb46f404d10 /src | |
parent | 422f1b68d2caf49e9df45b24f486340835c8dbc7 (diff) | |
download | Qt-92c458b3521909c9db200beb80293a5c64b9b5f8.zip Qt-92c458b3521909c9db200beb80293a5c64b9b5f8.tar.gz Qt-92c458b3521909c9db200beb80293a5c64b9b5f8.tar.bz2 |
Fix QFile append on windows
1. make windows file engine seek to end on open to match unix/symbian
2. make qfile forcibly seek the file engine in case a custom file
engine has the same bug.
Task-number: QTBUG-25906
Change-Id: I62a26519a9401e547ff77bd8a71027cb361dc671
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qfile.cpp | 7 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index c4bc612..8eea244 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1036,8 +1036,11 @@ bool QFile::open(OpenMode mode) #endif { QIODevice::open(mode); - if (mode & Append) - seek(size()); + if (mode & Append) { + //The file engine should have done this in open(), + //this is a workaround for backward compatibility + fileEngine()->seek(size()); + } return true; } QFile::FileError err = d->fileEngine->error(); diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 8014720..a148fd9 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -144,6 +144,11 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) if (openMode & QIODevice::Truncate) q->setSize(0); + // Seek to the end when in Append mode. + if (openMode & QFile::Append) { + ::SetFilePointer(fileHandle, 0, 0, FILE_END); + } + return true; } |