-
Notifications
You must be signed in to change notification settings - Fork 11
/
pfs_upk.cpp
75 lines (65 loc) · 2.06 KB
/
pfs_upk.cpp
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
/*
This file is part of pfs_upk.
pfs_upk is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
pfs_upk is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
pfs_upk. If not, see <https://www.gnu.org/licenses/>.
*/
#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "pfs_upk.hpp"
using namespace std;
int main(int argc, char *argv[]) {
try {
#ifdef _WIN32
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
#endif // _WIN32
#ifndef _TESTMODE
// check params
if (argc < 2) {
cout << "Artemis C++ Packer ---- A Simple C++ Artemis Engine Archive "
"Packer / Unpacker."
<< endl;
cout << "Copyright 2022-present @ryank231231." << endl;
cout << "Usage:" << endl;
cout << argv[0] << " "
<< "<ARTEMIS ARCHIVE> / <FOLDER>" << endl;
exit(EXIT_SUCCESS);
}
#else
argv[1] = "C:\\vn_temp\\保\\pfs";
#endif
// check is path or file
filesystem::path path;
try {
path = filesystem::canonical(argv[1]);
} catch (
filesystem::filesystem_error) { // when the path is already canonical.
path = argv[1];
}
if (filesystem::is_directory(path)) {
if (pack(path.string()) == false) {
cout << "Pack failed!" << endl;
exit(EXIT_FAILURE);
}
} else {
if (unpack(path.string()) == false) {
cout << "Unpack failed!" << endl;
exit(EXIT_FAILURE);
}
}
exit(EXIT_SUCCESS);
} catch (std::exception &e) {
cout << "Caught a C++ exception. ";
cout << e.what() << endl;
}
}