From 69c33063aaa85abf153bea036c58937067a80cd5 Mon Sep 17 00:00:00 2001 From: Per Larsson Date: Sun, 5 Dec 2021 19:04:39 +0100 Subject: Check available disk space before GC. --- zencore/include/zencore/filesystem.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'zencore/include') diff --git a/zencore/include/zencore/filesystem.h b/zencore/include/zencore/filesystem.h index c7ac7140d..155291e67 100644 --- a/zencore/include/zencore/filesystem.h +++ b/zencore/include/zencore/filesystem.h @@ -57,6 +57,22 @@ ZENCORE_API bool SupportsBlockRefCounting(std::filesystem::path Path); ZENCORE_API std::string ToUtf8(const std::filesystem::path& Path); +struct DiskSpace +{ + uint64_t Free{}; + uint64_t Total{}; +}; + +ZENCORE_API DiskSpace DiskSpaceInfo(std::filesystem::path Directory, std::error_code& Error); + +inline bool +DiskSpaceInfo(std::filesystem::path Directory, DiskSpace& Space) +{ + std::error_code Err; + Space = DiskSpaceInfo(Directory, Err); + return !!Err; +} + /** * Efficient file system traversal * -- cgit v1.2.3