diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2018-08-16 00:30:15 +0200 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2018-08-16 00:34:06 +0200 |
| commit | dc22d81f89a0eeb13e8e760ff9c84c22135a7ce4 (patch) | |
| tree | 8753b175303532cca14cbd1b1f4e4f93f72d0aeb /src/cppc4group.hpp | |
| parent | 0d1ae015fef8e15442dafa61b9c8d929ce467969 (diff) | |
| download | cc4group-dc22d81f89a0eeb13e8e760ff9c84c22135a7ce4.tar.gz cc4group-dc22d81f89a0eeb13e8e760ff9c84c22135a7ce4.zip | |
Add C++ wrapper
Diffstat (limited to 'src/cppc4group.hpp')
| -rw-r--r-- | src/cppc4group.hpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/cppc4group.hpp b/src/cppc4group.hpp new file mode 100644 index 0000000..fc46592 --- /dev/null +++ b/src/cppc4group.hpp @@ -0,0 +1,74 @@ +#pragma once + +#include <memory> +#include <vector> +#include <optional> + +class CppC4Group { + struct Private; + + std::unique_ptr<Private> p; + +public: + struct Data { + const void* data; + size_t size; + + Data(); + Data(const void* data, size_t size); + }; + + struct EntryInfo { + std::string fileName; + int32_t modified; + std::string author; + size_t size; + size_t totalSize; + bool executable; + bool directory; + bool official; + }; + +public: + enum TmpMemoryStrategy { + Memory, + File, + Auto + }; + + static void setTmpMemoryStrategy(const TmpMemoryStrategy strategy); + +public: + CppC4Group(); + ~CppC4Group(); + + void create(); + bool openExisting(const std::string& path); + bool save(const std::string& path, const bool overwrite = false); + + bool extractAll(const std::string& path); + bool extractSingle(const std::string& entryPath, const std::string& targetPath); + + std::optional<Data> getEntryData(const std::string& path); + std::string getErrorMessage(); + int32_t getErrorCode(); + std::string getErrorMethod(); + std::string getErrorCauser(); + + bool setMaker(const std::string& maker, const std::string& path = "", const bool recursive = false); + bool setCreation(const int32_t creation, const std::string& path = "", const bool recursive = false); + bool setOfficial(const bool official, const std::string& path = "", const bool recursive = false); + bool setExecutable(const bool executable, const std::string& path); + + std::optional<EntryInfo> getEntryInfo(const std::string& path = ""); + std::optional<std::vector<EntryInfo>> getEntryInfos(const std::string& path = ""); + + bool deleteEntry(const std::string& path, const bool recursive); + bool renameEntry(const std::string& oldPath, const std::string& newPath); + + bool createDirectory(const std::string& path); + + bool createFile(const std::string& path, void* data = nullptr, size_t size = 0); + + bool setEntryData(const std::string& path, void* data = nullptr, size_t size = 0); +}; |
