1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#pragma once
#include <memory>
#include <vector>
#include <optional>
#include <cstdio>
class CppC4Group {
struct Private;
std::unique_ptr<Private> p;
public:
struct Data {
const void* data;
size_t size;
Data();
Data(const void* const data, const 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:
using ReadCallback = bool(*)(const void** const data, size_t* const size, void* const arg);
using SetupCallback = bool(*)(void* const arg);
enum TmpMemoryStrategy {
Memory,
File,
Auto
};
enum MemoryManagement {
Take,
Copy,
Reference
};
static void setTmpMemoryStrategy(const TmpMemoryStrategy strategy);
public:
CppC4Group();
~CppC4Group();
void create();
bool openExisting(const std::string& path);
bool openFd(const int fd);
bool openFilePointer(FILE* file);
bool openMemory(const void* const data, const size_t size, const MemoryManagement management = Reference);
bool openWithReadCallback(const ReadCallback callback, void* const callbackArg, const MemoryManagement management = Take, SetupCallback initCallback = nullptr, SetupCallback deinitCallback = nullptr);
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 = false);
bool renameEntry(const std::string& oldPath, const std::string& newPath);
bool createDirectory(const std::string& path);
bool createFile(const std::string& path);
bool setEntryData(const std::string& path, const void* const data = nullptr, const size_t size = 0, const MemoryManagement management = Copy);
};
|