From cc465efa674a5394aa0635a0760f7a938e0260bf Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Sun, 21 Feb 2021 21:05:43 +0100 Subject: Change: [Win32] Use more modern way of getting free disk space --- src/os/windows/win32.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 27fec1ac0..cfe7d42d9 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -244,15 +244,10 @@ bool FiosIsHiddenFile(const struct dirent *ent) bool FiosGetDiskFreeSpace(const char *path, uint64 *tot) { UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box - bool retval = false; - wchar_t root[4]; - DWORD spc, bps, nfc, tnc; - - _snwprintf(root, lengthof(root), L"%c:" PATHSEP, path[0]); - if (tot != nullptr && GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) { - *tot = ((spc * bps) * (uint64)nfc); - retval = true; - } + + ULARGE_INTEGER bytes_free; + bool retval = GetDiskFreeSpaceEx(OTTD2FS(path), &bytes_free, nullptr, nullptr); + if (retval) *tot = bytes_free.QuadPart; SetErrorMode(sem); // reset previous setting return retval; -- cgit v1.2.3-54-g00ecf