From 40c47b60d88494839391af54650f55a481ee2b5a Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 29 May 2024 16:19:21 +0300 Subject: [PATCH] UI: DbErrorManager: Fix dir share mode --- src/ui/util/dirinfo.cpp | 4 +++- src/ui/util/fileutil.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ui/util/dirinfo.cpp b/src/ui/util/dirinfo.cpp index b0327411..ce950526 100644 --- a/src/ui/util/dirinfo.cpp +++ b/src/ui/util/dirinfo.cpp @@ -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(); diff --git a/src/ui/util/fileutil.cpp b/src/ui/util/fileutil.cpp index c1a63782..30540691 100644 --- a/src/ui/util/fileutil.cpp +++ b/src/ui/util/fileutil.cpp @@ -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) {