diff options
| author | Per Larsson <[email protected]> | 2021-12-05 19:04:39 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-12-05 19:04:39 +0100 |
| commit | 69c33063aaa85abf153bea036c58937067a80cd5 (patch) | |
| tree | 6c13f9c8095e727213cf754d274694af05afb3ce /zencore/filesystem.cpp | |
| parent | Added simple GC interval scheduling. (diff) | |
| download | zen-69c33063aaa85abf153bea036c58937067a80cd5.tar.xz zen-69c33063aaa85abf153bea036c58937067a80cd5.zip | |
Check available disk space before GC.
Diffstat (limited to 'zencore/filesystem.cpp')
| -rw-r--r-- | zencore/filesystem.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index bcbb36c73..53e6f1f38 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -634,6 +634,27 @@ ToUtf8(const std::filesystem::path& Path) #endif } +DiskSpace +DiskSpaceInfo(std::filesystem::path Directory, std::error_code& Error) +{ +#if ZEN_PLATFORM_WINDOWS + ULARGE_INTEGER Free, Total; + if (GetDiskFreeSpaceExA(Directory.string().c_str(), &Free, &Total, nullptr)) + { + return {.Free = static_cast<uint64_t>(Free.QuadPart), .Total = static_cast<uint64_t>(Total.QuadPart)}; + } + else + { + Error = std::error_code(::GetLastError(), std::system_category()); + return {}; + } +#else + ZEN_ERROR("DiskSpaceInfo() is not implemented on this platform"); + Error = std::error_code(1, std::system_category()); + return {}; +#endif +} + void FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, TreeVisitor& Visitor) { |