diff options
author | Alex Zolotarev <deathbaba@gmail.com> | 2012-09-06 14:46:06 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:43:06 +0300 |
commit | 66afd37cc6204975545a071b11f2a87416e77e4b (patch) | |
tree | 8f984d275912535fa0718db84d5aa96ee3118010 /platform/platform_win.cpp | |
parent | 3aabb33fb24db5204d58f9325db8c481ed961669 (diff) |
[win] Fixed some compilation errors. Only OpenGL errors left
Diffstat (limited to 'platform/platform_win.cpp')
-rw-r--r-- | platform/platform_win.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/platform/platform_win.cpp b/platform/platform_win.cpp index 78fac476da..ac57d3ad2e 100644 --- a/platform/platform_win.cpp +++ b/platform/platform_win.cpp @@ -1,10 +1,12 @@ #include "platform.hpp" +#include "../base/scope_guard.hpp" #include "../base/logging.hpp" #include "../coding/file_writer.hpp" #include "../std/windows.hpp" +#include "../std/bind.hpp" #include <shlobj.h> @@ -119,3 +121,34 @@ void Platform::RunAsync(TFunctor const & fn, Priority p) /// @todo fn(); } + +Platform::TStorageStatus Platform::GetWritableStorageStatus(uint64_t neededSize) +{ + ULARGE_INTEGER freeSpace; + if (0 == ::GetDiskFreeSpaceExA(m_writableDir.c_str(), &freeSpace, NULL, NULL)) + { + LOG(LWARNING, ("GetDiskFreeSpaceEx failed with error", GetLastError())); + return STORAGE_DISCONNECTED; + } + + if (freeSpace.u.LowPart + (freeSpace.u.HighPart << 32) < neededSize) + return NOT_ENOUGH_SPACE; + + return STORAGE_OK; +} + +bool Platform::GetFileSizeByFullPath(string const & filePath, uint64_t & size) +{ + HANDLE hFile = CreateFileA(filePath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile != INVALID_HANDLE_VALUE) + { + MY_SCOPE_GUARD(autoClose, bind(&CloseHandle, hFile)); + LARGE_INTEGER fileSize; + if (0 != GetFileSizeEx(hFile, &fileSize)) + { + size = fileSize.QuadPart; + return true; + } + } + return false; +} |