Use wchar version of GetDiskFreeSpaceEx on Windows Qt 5

This commit is contained in:
jonas@jkvinge.net 2021-05-11 20:32:28 +02:00
parent dee1905e16
commit 639ea35921
2 changed files with 4 additions and 8 deletions

View File

@ -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)

View File

@ -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