Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
112 lines (100 loc) · 4.22 KB
/
Copy pathmain.cpp
File metadata and controls
112 lines (100 loc) · 4.22 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include"includes.h"
std::string inputDirectory;
std::string outputDirectory;
bool useEncryption = false;
upk upkSystem;
upk_API upkApiForStandalone;
int main(int argc, char* argv[]) {
console::print("", upkVersion);
console::print("", upkEncryptorVersion);
console::print("", upkEncryptorModel);
console::print("", upkBuild);
console::print("", "");
// Argüman sayýsýný kontrol et
if (argc > 1) {
std::string fileName = argv[1];
if (!fileSys::isValidFile(fileName)) {
console::exitPrint(upk_PackagerFileSysHeaderTitle + upk_error, " Invalid upk file: " + fileName);
}
if (fileSys::getFileExtension(fileName) == " .upkm") {
console::exitPrint(upk_PackagerFileSysHeaderTitle + upk_error, " Please select .upkm file: " + fileName);
}
console::print(upk_PackagerHeaderTitle + upk_info, "Creating package tree...");
upkApiForStandalone.readAndCreateTree(fileName);
while (1) {
console::print(upk_PackagerHeaderTitle, " Enter a path for list it:");
bufferData patInp = console::getInput();
std::string pathInputt((char*)patInp.pointer, patInp.size);
bufferData a = upkApiForStandalone.get(pathInputt);
if (a.pointer != nullptr) {
std::string contt((char*)a.pointer,a.size);
console::print(upk_PackagerHeaderTitle, " File content:\n" + contt);
}
else {
console::print(upk_PackagerHeaderTitle, " File not found!");
}
}
return 0;
}
else {
console::print(upk_PackagerHeaderTitle, " Enter a directory for package.");
bufferData indrBuf = console::getInput();
std::string inputDirectoryTmp((char*)indrBuf.pointer, indrBuf.size);
inputDirectory = inputDirectoryTmp;
inputDirectoryTmp.~basic_string();
indrBuf.~bufferData();
#ifdef debugFileInputOutput
console::print(upk_PackagerDebugHeaderTitle + upk_info, " Input:" + inputDirectory);
#endif // debugFileInputOutput
if (!fileSys::isValidFile(inputDirectory)) {
console::exitPrint(upk_PackagerFileSysHeaderTitle + upk_error, " Invalid directory: " + inputDirectory);
}
console::print(upk_PackagerHeaderTitle, " Enter a directory for output.");
bufferData oudrBuf = console::getInput();
std::string outputDirectoryTmp((char*)oudrBuf.pointer, oudrBuf.size);
outputDirectory = outputDirectoryTmp;
outputDirectoryTmp.~basic_string();
oudrBuf.~bufferData();
#ifdef debugFileInputOutput
console::print(upk_PackagerDebugHeaderTitle + upk_info, " Output:" + outputDirectory);
#endif // debugFileInputOutput
if (!fileSys::isValidFile(outputDirectory)) {
console::exitPrint(upk_PackagerFileSysHeaderTitle + upk_error, " Invalid directory: " + outputDirectory);
}
console::print(upk_PackagerHeaderTitle, " Do you want to use encryption? [Y]/[N]");
bufferData ecryptQuestBuf = console::getInput();
std::string encryptQuestAnswer((char*)ecryptQuestBuf.pointer, ecryptQuestBuf.size);
ecryptQuestBuf.~bufferData();
if (encryptQuestAnswer == "y" or encryptQuestAnswer == "Y") {
useEncryption = true;
upkSystem.enableEncryption();
//****************************************
console::print(upk_PackagerHeaderTitle, " Do you want to use encryption for root upk? [Y]/[N]");
bufferData ecryptQuestBuf = console::getInput();
std::string encryptQuestAnswer((char*)ecryptQuestBuf.pointer, ecryptQuestBuf.size);
ecryptQuestBuf.~bufferData();
if (encryptQuestAnswer == "y" or encryptQuestAnswer == "Y") {
upkSystem.enableEncryptionForRootFile();
}
else if (encryptQuestAnswer == "n" or encryptQuestAnswer == "N") {
}
else {
console::exitPrint(upk_PackagerFileSysHeaderTitle + upk_error, " Invalid selection!");
}
//****************************************
}
else if (encryptQuestAnswer == "n" or encryptQuestAnswer == "N") {
useEncryption = false;
upkSystem.disableEncryption();
}
else {
console::exitPrint(upk_PackagerFileSysHeaderTitle + upk_error, " Invalid selection!");
}
auto start = std::chrono::high_resolution_clock::now();
upkSystem.loadAndSearchDirectory(inputDirectory);
upkSystem.createPackage(outputDirectory);
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
console::exitPrint(upk_PackagerHeaderTitle + upk_info, "System complete in " + std::to_string(duration) + "ms");
}
}