Expand FsUtils

This commit is contained in:
Georg Hagen
2025-05-15 20:35:11 +02:00
parent 3fd31f92ae
commit 369528c170

View File

@@ -15,7 +15,7 @@ namespace OpenVulkano
{
size_t fileCount = 0, dirCount = 0;
size_t GetTotalEntryCount() const { return fileCount + dirCount; }
[[maybe_unused]] [[nodiscard]] size_t GetTotalEntryCount() const { return fileCount + dirCount; }
FsCount& operator +=(const FsCount& other)
{
@@ -23,6 +23,23 @@ namespace OpenVulkano
dirCount += other.dirCount;
return *this;
}
FsCount operator +(FsCount other)
{
return other += *this;
}
FsCount& operator -=(const FsCount& other)
{
fileCount -= other.fileCount;
dirCount -= other.dirCount;
return *this;
}
FsCount operator -(FsCount other)
{
return other -= *this;
}
};
struct FsUtils
@@ -35,12 +52,12 @@ namespace OpenVulkano
static bool IsTreeEmpty(const std::filesystem::path& dir);
static ByteSize GetDirSize(const std::filesystem::path& dir);
[[nodiscard]] static ByteSize GetDirSize(const std::filesystem::path& dir);
static FsCount GetDirFileAndDirCount(const std::filesystem::path& dir);
[[nodiscard]] static FsCount GetDirFileAndDirCount(const std::filesystem::path& dir);
static std::string ToValidFileName(std::string filename);
[[nodiscard]] static std::string ToValidFileName(std::string filename);
static std::vector<std::filesystem::path> FilesWithExtension(const std::filesystem::path& dir, std::string ext);
[[maybe_unused]] [[nodiscard]] static std::vector<std::filesystem::path> FilesWithExtension(const std::filesystem::path& dir, std::string ext);
};
}