Windows: Fix QFileSystemEngine::id() for FAT32 drives

GetFileInformationByHandleEx() which is used to to obtain the ID, has been
found to fail on FAT32 (USB removable drives). Fall back to
GetFileInformationByHandle() for these.

Fixes: QTBUG-74759
Change-Id: Ib3ef60a6bf9e9edaf41af86bf71666001cb0aa58
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Friedemann Kleint 2019-04-01 17:40:29 +02:00
parent e5f0fec762
commit 163a0475eb

View File

@ -555,7 +555,7 @@ typedef struct _FILE_ID_INFO {
#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602 #endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
// File ID for Windows up to version 7. // File ID for Windows up to version 7 and FAT32 drives
static inline QByteArray fileId(HANDLE handle) static inline QByteArray fileId(HANDLE handle)
{ {
#ifndef Q_OS_WINRT #ifndef Q_OS_WINRT
@ -588,6 +588,8 @@ QByteArray fileIdWin8(HANDLE handle)
result += ':'; result += ':';
// Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one. // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
result += QByteArray(reinterpret_cast<const char *>(&infoEx.FileId), int(sizeof(infoEx.FileId))).toHex(); result += QByteArray(reinterpret_cast<const char *>(&infoEx.FileId), int(sizeof(infoEx.FileId))).toHex();
} else {
result = fileId(handle); // GetFileInformationByHandleEx() is observed to fail for FAT32, QTBUG-74759
} }
return result; return result;
#else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE #else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE