diff options
Diffstat (limited to 'zencore/filesystem.cpp')
| -rw-r--r-- | zencore/filesystem.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 7c55be3e8..2e4e876e9 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -757,25 +757,18 @@ PathToUtf8(const std::filesystem::path& Path) 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 - struct statvfs Stat; - if (statvfs(Directory.c_str(), &Stat) == 0) + using namespace std::filesystem; + + space_info SpaceInfo = space(Directory, Error); + if (Error) { - return { - .Free = uint64_t(Stat.f_bsize * Stat.f_bavail), - .Total = uint64_t(Stat.f_frsize * Stat.f_blocks), - }; + return {}; } -#endif - Error = std::error_code(zen::GetLastError(), std::system_category()); - return {}; + return { + .Free = uint64_t(SpaceInfo.available), + .Total = uint64_t(SpaceInfo.capacity), + }; } void |