From c0bd7ade1aa49ed6877e5f13a74bcb72ff662062 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 9 Jul 2017 12:29:26 -0700 Subject: QFileSystemEngine::id/Windows: Use the volume ID too The MS documentation says that the high/low parts uniquely identify a file within a system, but they actually mean the filesystem. The details on how it's allocated make that clear. So we need the volume identifier. Change-Id: I658f552684924f8aa2cafffd14cfc03c5a09c0e9 Reviewed-by: Friedemann Kleint Reviewed-by: Kai Koehne Reviewed-by: Maurice Kalinowski --- src/corelib/io/qfilesystemengine_win.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index e4a7ea4891..5ed2671ab4 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -571,19 +571,21 @@ typedef struct _FILE_ID_INFO { // File ID for Windows up to version 7. static inline QByteArray fileId(HANDLE handle) { - QByteArray result; #ifndef Q_OS_WINRT BY_HANDLE_FILE_INFORMATION info; if (GetFileInformationByHandle(handle, &info)) { - result = QByteArray::number(uint(info.nFileIndexLow), 16); - result += ':'; - result += QByteArray::number(uint(info.nFileIndexHigh), 16); + char buffer[sizeof "01234567:0123456701234567"]; + qsnprintf(buffer, sizeof(buffer), "%lx:%08lx%08lx", + info.dwVolumeSerialNumber, + info.nFileIndexHigh, + info.nFileIndexLow); + return buffer; } #else // !Q_OS_WINRT Q_UNUSED(handle); Q_UNIMPLEMENTED(); #endif // Q_OS_WINRT - return result; + return QByteArray(); } // File ID for Windows starting from version 8. -- cgit v1.2.3