forked from qt-creator/qt-creator
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:
committed by
Orgad Shaneh
parent
04c2a32fc0
commit
a5dfbe01d5
@@ -493,6 +493,20 @@ bool DesktopDeviceFileAccess::hasHardLinks(const FilePath &filePath) const
|
|||||||
if (s.st_nlink > 1)
|
if (s.st_nlink > 1)
|
||||||
return true;
|
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
|
#else
|
||||||
Q_UNUSED(filePath)
|
Q_UNUSED(filePath)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user