From b427fd6bd0e5e182fa507a1930356f9cbdeacd86 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 14 Jul 2009 14:15:26 +0200 Subject: large file support for Windows CE Seeking in files above 0x80000000 failed on Windows CE. SetFilePointer was used in the 32 bit version. That means, seeking only worked for positions <= LONG_MAX (which is 0x80000000 - 1). Task-number: 255242 Reviewed-by: mauricek --- src/corelib/io/qfsfileengine_win.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 618566a..5365ff5 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -588,21 +588,23 @@ qint64 QFSFileEnginePrivate::nativePos() const if (fileHandle == INVALID_HANDLE_VALUE) return 0; -#if !defined(QT_NO_LIBRARY) +#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_WINCE) QFSFileEnginePrivate::resolveLibs(); if (!ptrSetFilePointerEx) { #endif - DWORD newFilePointer = SetFilePointer(fileHandle, 0, NULL, FILE_CURRENT); - if (newFilePointer == 0xFFFFFFFF) { + LARGE_INTEGER filepos; + filepos.HighPart = 0; + DWORD newFilePointer = SetFilePointer(fileHandle, 0, &filepos.HighPart, FILE_CURRENT); + if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) { thatQ->setError(QFile::UnspecifiedError, qt_error_string()); return 0; } - // Note: returns <4GB; does not work with large files. This is the - // case for MOC, UIC, qmake and other bootstrapped tools, and for - // Win9x/ME. - return qint64(newFilePointer); -#if !defined(QT_NO_LIBRARY) + // Note: This is the case for MOC, UIC, qmake and other + // bootstrapped tools, and for Windows CE. + filepos.LowPart = newFilePointer; + return filepos.QuadPart; +#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_WINCE) } // This approach supports large files. @@ -631,21 +633,22 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos) return seekFdFh(pos); } -#if !defined(QT_NO_LIBRARY) +#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_WINCE) QFSFileEnginePrivate::resolveLibs(); if (!ptrSetFilePointerEx) { #endif - LONG seekToPos = LONG(pos); // <- lossy - DWORD newFilePointer = SetFilePointer(fileHandle, seekToPos, NULL, FILE_BEGIN); - if (newFilePointer == 0xFFFFFFFF) { - thatQ->setError(QFile::UnspecifiedError, qt_error_string()); + DWORD newFilePointer; + LARGE_INTEGER *li = reinterpret_cast(&pos); + newFilePointer = SetFilePointer(fileHandle, li->LowPart, &li->HighPart, FILE_BEGIN); + if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) { + thatQ->setError(QFile::PositionError, qt_error_string()); return false; } - // Note: does not work with large files. This is the case for MOC, - // UIC, qmake and other bootstrapped tools, and for Win9x/ME. + // Note: This is the case for MOC, UIC, qmake and other + // bootstrapped tools, and for Windows CE. return true; -#if !defined(QT_NO_LIBRARY) +#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_WINCE) } // This approach supports large files. -- cgit v0.12