Codechange: let FiosGetDiskFreeSpace only return disk space and split FiosGetCurrentPath off

This commit is contained in:
Rubidium
2023-05-30 22:38:55 +02:00
committed by rubidium42
parent f2e704b9a7
commit 324c43eeb2
7 changed files with 27 additions and 50 deletions

View File

@@ -213,16 +213,17 @@ bool FiosIsHiddenFile(const struct dirent *ent)
return (ent->dir->fd.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) != 0;
}
bool FiosGetDiskFreeSpace(const char *path, uint64 *tot)
std::optional<uint64_t> FiosGetDiskFreeSpace(const std::string &path)
{
UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box
ULARGE_INTEGER bytes_free;
bool retval = GetDiskFreeSpaceEx(OTTD2FS(path).c_str(), &bytes_free, nullptr, nullptr);
if (retval && tot != nullptr) *tot = bytes_free.QuadPart;
SetErrorMode(sem); // reset previous setting
return retval;
if (retval) return bytes_free.QuadPart;
return std::nullopt;
}
void CreateConsole()