Avoid sharing violation in QFileSystemEngine::id on Windows
We can't open a file for reading if the file is open by another process (or by ourselves) without sharing permitted. So ask for no access just so we can get a handle to it. Change-Id: I998653739e1cec2a58a07a6593b6ff87c1d59dd1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
fd95ef765a
commit
8d542154a8
|
|
@ -612,13 +612,13 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
|
|||
QByteArray result;
|
||||
const HANDLE handle =
|
||||
#ifndef Q_OS_WINRT
|
||||
CreateFile((wchar_t*)entry.nativeFilePath().utf16(), GENERIC_READ,
|
||||
CreateFile((wchar_t*)entry.nativeFilePath().utf16(), 0,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
#else // !Q_OS_WINRT
|
||||
CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), GENERIC_READ,
|
||||
CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), 0,
|
||||
FILE_SHARE_READ, OPEN_EXISTING, NULL);
|
||||
#endif // Q_OS_WINRT
|
||||
if (handle) {
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
result = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8 ?
|
||||
fileIdWin8(handle) : fileId(handle);
|
||||
CloseHandle(handle);
|
||||
|
|
|
|||
Loading…
Reference in New Issue