From f40a21f5a6ca674d93905269bcb4b21f92c41800 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Sat, 17 Aug 2019 22:36:37 +0200 Subject: Add cc4group.addFromDisk with according cc4group.AllowEntryTypes --- src/cppc4group.hpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/cppc4group.hpp') diff --git a/src/cppc4group.hpp b/src/cppc4group.hpp index 420893c..7f51629 100644 --- a/src/cppc4group.hpp +++ b/src/cppc4group.hpp @@ -14,6 +14,7 @@ #include #include #include +#include class CppC4Group { // all C-related stuff is hidden from this header so it doesn't land in the precious C++-only code this might be used in... @@ -111,12 +112,18 @@ public: using WriteCallback = bool(*)(const void* const data, size_t const size, void* const arg); // these enums are just mapped to their C-counterparts internally - enum TmpMemoryStrategy { + enum class TmpMemoryStrategy { Memory, File, Auto }; + enum class AllowedEntryTypes { + File, + Directory, + All = File | Directory + }; + // use this to set one of the predefined strategies static void setTmpMemoryStrategy(const TmpMemoryStrategy strategy); @@ -167,6 +174,8 @@ public: bool deleteEntry(const std::string& path, const bool recursive = false); bool renameEntry(const std::string& oldPath, const std::string& newPath); + bool addFromDisk(const std::string& path, const std::string& targetPath, const AllowedEntryTypes allowedEntryTypes = AllowedEntryTypes::All); + bool createDirectory(const std::string& path); bool createFile(const std::string& path); @@ -176,3 +185,20 @@ public: // to get the child group out of the optional in case of success, construct a new CppC4Group with the move constructor: CppC4Group child{std::move(*optionalChild)}; std::optional openAsChild(const std::string& path); }; + +inline bool operator&(CppC4Group::AllowedEntryTypes lhs, CppC4Group::AllowedEntryTypes rhs) +{ + using T = std::underlying_type_t ; + return static_cast(lhs) & static_cast(rhs); +} + +inline CppC4Group::AllowedEntryTypes operator|(CppC4Group::AllowedEntryTypes lhs, CppC4Group::AllowedEntryTypes rhs) +{ + using T = std::underlying_type_t ; + return static_cast(static_cast(lhs) | static_cast(rhs)); +} + +inline CppC4Group::AllowedEntryTypes& operator|=(CppC4Group::AllowedEntryTypes& lhs, CppC4Group::AllowedEntryTypes rhs) +{ + return lhs = lhs | rhs; +} -- cgit v1.2.3-54-g00ecf