diff options
author | Niels Martin Hansen <nielsm@indvikleren.dk> | 2021-02-21 21:05:43 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2021-02-23 11:25:39 +0100 |
commit | cc465efa674a5394aa0635a0760f7a938e0260bf (patch) | |
tree | 9ee65d1c9bc6ebb42378c6e083a45bdbac801068 /src/os/windows | |
parent | b427ddce887617f17aefdbe1f22ca1e00d013c3d (diff) | |
download | openttd-cc465efa674a5394aa0635a0760f7a938e0260bf.tar.xz |
Change: [Win32] Use more modern way of getting free disk space
Diffstat (limited to 'src/os/windows')
-rw-r--r-- | src/os/windows/win32.cpp | 13 |
1 files 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; |