Add recursive dir size getter
This commit is contained in:
@@ -69,4 +69,23 @@ namespace OpenVulkano
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Math/ByteSize.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user