CheckFreeSpace fix

This commit is contained in:
Jack Andersen 2016-01-24 19:56:33 -10:00
parent 9109abef31
commit b91bf70912
1 changed files with 10 additions and 3 deletions

View File

@ -426,9 +426,16 @@ static inline bool CheckFreeSpace(const SystemChar* path, size_t reqSz)
{ {
#if _WIN32 #if _WIN32
ULARGE_INTEGER freeBytes; ULARGE_INTEGER freeBytes;
if (!GetDiskFreeSpaceExW(path, &freeBytes, nullptr, nullptr)) wchar_t buf[1024];
LogModule.report(LogVisor::FatalError, "GetDiskFreeSpaceExW %s: %d", path, GetLastError()); wchar_t* end;
return reqSz < freeBytes; 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 #else
struct statvfs svfs; struct statvfs svfs;
if (statvfs(path, &svfs)) if (statvfs(path, &svfs))