-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (47 loc) · 1.47 KB
/
Copy pathmain.cpp
File metadata and controls
55 lines (47 loc) · 1.47 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
#include <iostream>
#include <filesystem>
#include <cstring>
#include "Compiler.h"
#include "Translator.h"
#include "JSEnv.h"
#include "Decompiler.h"
#define VERSION "1.0.0"
#define ARGUMENT_DECOMPILE "decompile"
#define ARGUMENT_COMPILE "compile"
#define ARGUMENT_TRANSLATE "translate"
void PrintStartupInfo(char* argv[]){
std::cout << "RAS Decompiler v" << VERSION << std::endl;
std::cout << "Usage: " << argv[0] << " <jsc_file>" << " [args]" << std::endl;
}
bool IsValidFilePath(const std::string& path) {
std::filesystem::path filePath(path);
if (!std::filesystem::exists(filePath)) {
return false;
}
if (!std::filesystem::is_regular_file(filePath)) {
return false;
}
return true;
}
int main(int argc, char* argv[]) {
PrintStartupInfo(argv);
if (argc < 3) {
std::cerr << "err: Arguments error!" << std::endl;
return 1;
}
JSEnv::InitJSEnv();
if (IsValidFilePath(argv[1])) {
if (strcmp(argv[2], ARGUMENT_DECOMPILE) == 0) {
Decompiler::DecompileFile(argv[1]);
} else if (strcmp(argv[2], ARGUMENT_COMPILE) == 0) {
Compiler::CompileFile(argv[1]);
} else if (strcmp(argv[2], ARGUMENT_TRANSLATE) == 0) {
Translator::TranslateFile(argv[1]);
} else {
std::cerr << "err: Operation type in arguments is not supported." << std::endl;
}
}
else{
std::cerr << "err: Input file path is invalid!" << std::endl;
}
}