diff options
author | João Abecasis <joao@abecasis.name> | 2009-10-23 09:23:55 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-10-23 13:05:49 (GMT) |
commit | 2ad49361eeb1ad14a2b9c6c95a9d20d20f9aa851 (patch) | |
tree | 7b6a0251a479602385dafeb5e45e6f90d879574b /src/corelib | |
parent | 3be1b879c9fbe37b71cce3c95ec4a3753a25a641 (diff) | |
download | Qt-2ad49361eeb1ad14a2b9c6c95a9d20d20f9aa851.zip Qt-2ad49361eeb1ad14a2b9c6c95a9d20d20f9aa851.tar.gz Qt-2ad49361eeb1ad14a2b9c6c95a9d20d20f9aa851.tar.bz2 |
On Windows, report a 0 file size for streams and other funny files
Obtain file size directly, instead of relying on fseek/ftell and messing
with the file position.
Also changed the return value on errors to 0. This is mostly relevant on
streams and pipes, where we used to return whatever error value ftell
returned (usually -1). This change also makes the return value
consistent with what is returned on Unix platforms and what we document
for Windows CE.
Nevertheless, documentation of this and related issues is misleading and
needs to be updated.
Reviewed-by: Markus Goetz
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 151eabd..b8a16fa 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -499,11 +499,8 @@ qint64 QFSFileEnginePrivate::nativeSize() const // Buffered stdlib mode. if (fh) { - QT_OFF_T oldPos = QT_FTELL(fh); - QT_FSEEK(fh, 0, SEEK_END); - QT_OFF_T fileSize = QT_FTELL(fh); - QT_FSEEK(fh, oldPos, SEEK_SET); - return qint64(fileSize); + qint64 fileSize = _filelengthi64(QT_FILENO(fh)); + return (fileSize == -1) ? 0 : fileSize; } // Not-open mode, where the file name is known: We'll check the |