UI: DbErrorManager: Fix dir share mode

This commit is contained in:
Nodir Temirkhodjaev 2024-05-29 16:19:21 +03:00
parent a255e13375
commit 40c47b60d8
2 changed files with 9 additions and 4 deletions

View File

@ -21,7 +21,9 @@ bool DirInfo::open()
{
close();
m_handle = CreateFileW((LPCWSTR) path().utf16(), GENERIC_READ, FILE_SHARE_READ, nullptr,
constexpr DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
m_handle = CreateFileW((LPCWSTR) path().utf16(), GENERIC_READ, shareMode, nullptr,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
return isOpen();

View File

@ -58,7 +58,8 @@ static bool isDriveMounted(WCHAR drive)
{
const WCHAR volume[] = { L'\\', L'\\', L'.', L'\\', drive, L':', L'\0' };
const DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
constexpr DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
const HANDLE volumeHandle =
CreateFileW(volume, GENERIC_READ, shareMode, nullptr, OPEN_EXISTING, 0, nullptr);
@ -293,8 +294,10 @@ QString realPath(const QString &path)
if (path.isEmpty())
return path;
const HANDLE fileHandle = CreateFileW((LPCWSTR) path.utf16(), GENERIC_READ, FILE_SHARE_READ,
nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS /* open dir */, nullptr);
constexpr DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
const HANDLE fileHandle = CreateFileW((LPCWSTR) path.utf16(), GENERIC_READ, shareMode, nullptr,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS /* open dir */, nullptr);
QString resPath;
if (fileHandle != INVALID_HANDLE_VALUE) {