Utils: Support hardlink detection also on Windows

Change-Id: I717899ef73e965438ecd28983397ffc90a7ff570
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
Orgad Shaneh
2023-06-01 12:58:46 +03:00
committed by Orgad Shaneh
parent 04c2a32fc0
commit a5dfbe01d5

View File

@@ -493,6 +493,20 @@ bool DesktopDeviceFileAccess::hasHardLinks(const FilePath &filePath) const
if (s.st_nlink > 1)
return true;
}
#elif defined(Q_OS_WIN)
const HANDLE handle = CreateFile((wchar_t *) filePath.toUserOutput().utf16(),
0,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (handle == INVALID_HANDLE_VALUE)
return false;
FILE_STANDARD_INFO info;
if (GetFileInformationByHandleEx(handle, FileStandardInfo, &info, sizeof(info)))
return info.NumberOfLinks > 1;
#else
Q_UNUSED(filePath)
#endif