Files
OpenVulkano/openVulkanoCpp/IO/FsUtils.hpp
2025-05-09 20:29:11 +02:00

47 lines
1.2 KiB
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "Math/ByteSize.hpp"
#include <filesystem>
namespace OpenVulkano
{
struct FsCount
{
size_t fileCount = 0, dirCount = 0;
size_t GetTotalEntryCount() const { return fileCount + dirCount; }
FsCount& operator +=(const FsCount& other)
{
fileCount += other.fileCount;
dirCount += other.dirCount;
return *this;
}
};
struct FsUtils
{
static bool DeleteEmptyFilesAndDirs(const std::filesystem::path& dir, bool recursive = true);
static bool DeleteEmptyDirs(const std::filesystem::path& dir, bool recursive = true);
static bool DeleteEmptySubTrees(const std::filesystem::path& dir);
static bool IsTreeEmpty(const std::filesystem::path& dir);
static ByteSize GetDirSize(const std::filesystem::path& dir);
static FsCount GetDirFileAndDirCount(const std::filesystem::path& dir);
static std::string ToValidFileName(std::string filename);
static std::vector<std::filesystem::path> FilesWithExtension(const std::filesystem::path& dir, std::string ext);
};
}