-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cc
More file actions
70 lines (58 loc) · 1.46 KB
/
main.cc
File metadata and controls
70 lines (58 loc) · 1.46 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
#include <exception>
#include <filesystem>
#include <string>
#ifdef _WIN32
#include <windows.h>
#endif
import resurrect;
import utils.logger;
using namespace gpsxre;
int main(int argc, char *argv[])
{
int exit_code = 0;
std::filesystem::path file;
bool recursive = false;
bool force = false;
#ifdef _WIN32
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
#endif
try
{
for(int i = 1; i < argc; ++i)
{
std::string arg(argv[i]);
if(arg == "--recursive" || arg == "-r")
recursive = true;
else if(arg == "--force" || arg == "-f")
force = true;
else if(file.empty())
{
file = std::filesystem::path(arg);
}
}
if(file.empty())
{
LOG("usage: resurrect [options] <skeleton/hash>");
LOG("");
LOG("\t--recursive,-r \tlook for files recursively");
LOG("\t--force,-f \tforce rebuild (skip missing files)");
LOG("");
LOG("Note: .skeleton and .hash must have same filename");
exit_code = -1;
}
else
exit_code = resurrect(file, force, recursive);
}
catch(const std::exception &e)
{
LOG("error: {}", e.what());
exit_code = -1;
}
catch(...)
{
LOG("error: unhandled exception");
exit_code = -2;
}
return exit_code;
}