-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
70 lines (59 loc) · 1.57 KB
/
main.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
#include "Patcher.h"
#include "defines.h"
void printUsage(char* binName) {
printf("usage: %s", binName);
printf(" [-u] path/to/ps2_iso\n");
}
int main (int argc, char** argv) {
if (argc < 2 || argc > 3
|| (argc == 3 && strcmp(argv[1], "-u") == 0 && strcmp(argv[2], "-u") == 0)
) {
printUsage(argv[0]);
return -1;
}
bool unpatch = false;
char* isoPath;
if (argc == 3) {
unpatch = true;
if (strcmp(argv[1],"-u") == 0)
isoPath = argv[2];
else if (strcmp(argv[2],"-u") == 0)
isoPath = argv[1];
else
printUsage(argv[0]);
}
else if (argc == 2) {
isoPath = argv[1];
}
CPatcher* patcher = new CPatcher();
eFileErr result;
if (unpatch) {
result = (eFileErr)patcher->doUnPatch(isoPath);
}
else {
result = (eFileErr)patcher->doPatch(isoPath);
}
switch (result) {
case ESR_FILE_ALREADY_PATCHED:
printf("iso already patched\n");
break;
case ESR_FILE_CANNOT_OPEN:
printf("cannot open iso for reading\n");
break;
case ESR_FILE_NO_UDF_DESCRIPTOR:
printf("no udf descriptor on iso\n");
break;
case ESR_FILE_NOT_PATCHED:
printf("iso already not patched\n");
break;
case ESR_FILE_OK:
printf("ok!\n");
break;
case ESR_FILE_WRONG_FORMAT:
printf("iso is wrong format\n");
break;
default:
break;
}
return 0;
}