summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-07-09 12:29:26 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-07-18 15:51:18 +0000
commitc0bd7ade1aa49ed6877e5f13a74bcb72ff662062 (patch)
treee4292308717e9ce5ecafcdb191bc7744e1b88960 /src/corelib/io
parent3f18dadeeb36e8add4f82f6e6b63373e1bac5e27 (diff)
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 <Friedemann.Kleint@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp12
1 files 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.