From acd73f6cfbd03828d4a695b546414a7ee72d74ef Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Thu, 6 Feb 2025 18:53:10 +0100 Subject: [PATCH] Add helper functions --- openVulkanoCpp/IO/FileDescription.hpp | 34 ++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/openVulkanoCpp/IO/FileDescription.hpp b/openVulkanoCpp/IO/FileDescription.hpp index a793af2..b16ccec 100644 --- a/openVulkanoCpp/IO/FileDescription.hpp +++ b/openVulkanoCpp/IO/FileDescription.hpp @@ -12,8 +12,8 @@ namespace OpenVulkano { struct FileDescription { - constexpr static inline std::filesystem::perms ALL_READ = std::filesystem::perms::owner_read | std::filesystem::perms::group_read | std::filesystem::perms::others_read; - constexpr static inline size_t UNKNOWN_SIZE = SIZE_MAX; + constexpr static std::filesystem::perms ALL_READ = std::filesystem::perms::owner_read | std::filesystem::perms::group_read | std::filesystem::perms::others_read; + constexpr static size_t UNKNOWN_SIZE = SIZE_MAX; std::filesystem::file_type type; std::string path; @@ -21,7 +21,10 @@ namespace OpenVulkano std::filesystem::perms permissions; time_t createTime = {}, modTime = {}; - static FileDescription MakeDescriptionForFile(const char* path, size_t size) + [[deprecated("Use MkFile instead")]] + static FileDescription MakeDescriptionForFile(const char* path, const size_t size) { return MkFile(path, size); } + + static FileDescription MkFile(const char* path, const size_t size) { return { std::filesystem::file_type::regular, @@ -31,5 +34,30 @@ namespace OpenVulkano std::time(nullptr), std::time(nullptr) }; } + + static FileDescription MkFile(const std::string& path, const size_t size) + { + return { + std::filesystem::file_type::regular, + path, + size, + std::filesystem::perms::owner_write | ALL_READ, + std::time(nullptr), std::time(nullptr) + }; + } + + static FileDescription MkDir(const char* path) + { + FileDescription desc = MkFile(path, 0); + desc.type = std::filesystem::file_type::directory; + return desc; + } + + static FileDescription MkDir(const std::string& path) + { + FileDescription desc = MkFile(path, 0); + desc.type = std::filesystem::file_type::directory; + return desc; + } }; }