diff --git a/openVulkanoCpp/IO/FsUtils.cpp b/openVulkanoCpp/IO/FsUtils.cpp index c2e84b2..3a3595a 100644 --- a/openVulkanoCpp/IO/FsUtils.cpp +++ b/openVulkanoCpp/IO/FsUtils.cpp @@ -69,4 +69,23 @@ namespace OpenVulkano } return true; } -} \ No newline at end of file + + ByteSize FsUtils::GetDirSize(const std::filesystem::path& dir) + { + ByteSize size = 0; + + for (auto& p: fs::directory_iterator(dir)) + { + if (fs::is_directory(p)) + { + size += GetDirSize(p); + } + else + { + size += p.file_size(); + } + } + + return size; + } +} diff --git a/openVulkanoCpp/IO/FsUtils.hpp b/openVulkanoCpp/IO/FsUtils.hpp index 7b74b66..4dc397c 100644 --- a/openVulkanoCpp/IO/FsUtils.hpp +++ b/openVulkanoCpp/IO/FsUtils.hpp @@ -6,6 +6,7 @@ #pragma once +#include "Math/ByteSize.hpp" #include namespace OpenVulkano @@ -17,5 +18,7 @@ namespace OpenVulkano static bool DeleteEmptySubTrees(const std::filesystem::path& dir); static bool IsTreeEmpty(const std::filesystem::path& dir); + + static ByteSize GetDirSize(const std::filesystem::path& dir); }; -} \ No newline at end of file +}