From 639ea359214f0cbe2d07b3d702271346d1acb09d Mon Sep 17 00:00:00 2001 From: "jonas@jkvinge.net" Date: Tue, 11 May 2021 20:32:28 +0200 Subject: [PATCH] Use wchar version of GetDiskFreeSpaceEx on Windows Qt 5 --- CMakeLists.txt | 4 ++++ src/core/utilities.cpp | 8 -------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44b2a82e9..4b0caf917 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -419,6 +419,10 @@ add_definitions(-DQT_USE_QSTRINGBUILDER) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) add_definitions(-DQT_NO_CAST_TO_ASCII) +if(WIN32 AND QT_MAJOR_VERSION EQUAL 5) + add_definitions(-DUNICODE) +endif() + # Subdirectories add_subdirectory(src) add_subdirectory(dist) diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 3f99adeb8..4c454eaee 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -205,12 +205,8 @@ quint64 FileSystemCapacity(const QString &path) { return quint64(fs_info.f_blocks) * quint64(fs_info.f_bsize); #elif defined(Q_OS_WIN32) _ULARGE_INTEGER ret; -# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) ScopedWCharArray wchar(QDir::toNativeSeparators(path)); if (GetDiskFreeSpaceEx(wchar.get(), nullptr, &ret, nullptr) != 0) -# else - if (GetDiskFreeSpaceEx(QDir::toNativeSeparators(path).toLocal8Bit().constData(), nullptr, &ret, nullptr) != 0) -# endif return ret.QuadPart; #endif @@ -226,12 +222,8 @@ quint64 FileSystemFreeSpace(const QString &path) { return quint64(fs_info.f_bavail) * quint64(fs_info.f_bsize); #elif defined(Q_OS_WIN32) _ULARGE_INTEGER ret; -# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) ScopedWCharArray wchar(QDir::toNativeSeparators(path)); if (GetDiskFreeSpaceEx(wchar.get(), &ret, nullptr, nullptr) != 0) -# else - if (GetDiskFreeSpaceEx(QDir::toNativeSeparators(path).toLocal8Bit().constData(), &ret, nullptr, nullptr) != 0) -# endif return ret.QuadPart; #endif