From b91bf70912e3f9fc04d4d790aed2be2792eb4fce Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 24 Jan 2016 19:56:33 -1000 Subject: [PATCH] CheckFreeSpace fix --- hecl/include/HECL/HECL.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hecl/include/HECL/HECL.hpp b/hecl/include/HECL/HECL.hpp index c4fa0cd63..7ad901842 100644 --- a/hecl/include/HECL/HECL.hpp +++ b/hecl/include/HECL/HECL.hpp @@ -426,9 +426,16 @@ static inline bool CheckFreeSpace(const SystemChar* path, size_t reqSz) { #if _WIN32 ULARGE_INTEGER freeBytes; - if (!GetDiskFreeSpaceExW(path, &freeBytes, nullptr, nullptr)) - LogModule.report(LogVisor::FatalError, "GetDiskFreeSpaceExW %s: %d", path, GetLastError()); - return reqSz < freeBytes; + wchar_t buf[1024]; + wchar_t* end; + DWORD ret = GetFullPathNameW(path, 1024, buf, &end); + if (!ret || ret > 1024) + LogModule.report(LogVisor::FatalError, _S("GetFullPathNameW %s"), path); + if (end) + end[0] = L'\0'; + if (!GetDiskFreeSpaceExW(buf, &freeBytes, nullptr, nullptr)) + LogModule.report(LogVisor::FatalError, _S("GetDiskFreeSpaceExW %s: %d"), path, GetLastError()); + return reqSz < freeBytes.QuadPart; #else struct statvfs svfs; if (statvfs(path, &svfs))