-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
240 lines (232 loc) · 11.2 KB
/
Program.cs
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
namespace ClassicPersonaToolkit
{
using System;
internal class Program
{
static void Main()
{
try
{
ShowMenu();
}
catch (Exception ex)
{
Console.WriteLine($"An unhandled exception occurred: {ex.Message}");
}
}
static void ShowMenu()
{
try
{
Console.Clear();
PrintHeader();
Console.WriteLine("Select an option:");
Console.WriteLine("1. Test Function 1 (Extract P2 BIN) [PSP]");
Console.WriteLine("2. Test Function 2 (Extract all P2 BIN in a dir) [PSP]");
Console.WriteLine("3. Test Function 3 (Extract P2 GZBIN) [PSP]");
Console.WriteLine("4. Test Function 4 (Extract all P2 GZBIN in a dir) [PSP]");
Console.WriteLine("5. Test Function 5 (Extract P1 BIN) [PSP]");
Console.WriteLine("6. Test Function 6 (Extract all P1 BIN in a dir) [PSP]");
Console.WriteLine("7. [EXPERIMENTAL] Test Function 7 (Extract P2IS String Data in a PO) [PSP]");
Console.WriteLine("0. Exit");
Console.Write("> ");
char option = Console.ReadKey().KeyChar;
Console.WriteLine();
switch (option)
{
case '1':
Console.Clear();
try
{
Console.Write("Write the file path: ");
string filePath = Console.ReadLine().Trim('"');
if (filePath != "")
if (Path.Exists(filePath))
Helpers.P2IS.PSP.P2ISHelper.ExtractPersona2Bin(filePath);
else
Console.WriteLine("No file exists in this dir.");
else
Console.WriteLine("No file path detected.");
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
break;
case '2':
Console.Clear();
try
{
Console.Write("Write the dir path: ");
string dirPath = Console.ReadLine().Trim('"');
if (dirPath != "")
if (Path.Exists(dirPath))
foreach (string filePath in Directory.GetFiles(dirPath, "*.bin", SearchOption.AllDirectories))
{
try
{
if (filePath.EndsWith(".bin", StringComparison.Ordinal))
Helpers.P2IS.PSP.P2ISHelper.ExtractPersona2Bin(filePath);
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
}
else
Console.WriteLine("No file exists in this dir.");
else
Console.WriteLine("No file path detected.");
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
break;
case '3':
Console.Clear();
try
{
Console.Write("Write the file path: ");
string filePath = Console.ReadLine().Trim('"');
if (filePath != "")
if (Path.Exists(filePath))
Helpers.P2IS.PSP.P2ISHelper.ExtractPersona2GzBin(filePath);
else
Console.WriteLine("No file exists in this dir.");
else
Console.WriteLine("No file path detected.");
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
break;
case '4':
Console.Clear();
try
{
Console.Write("Write the dir path: ");
string dirPath = Console.ReadLine().Trim('"');
if (dirPath != "")
if (Path.Exists(dirPath))
foreach (string filePath in Directory.GetFiles(dirPath, "*.bin", SearchOption.AllDirectories))
{
try
{
if (filePath.EndsWith(".bin", StringComparison.Ordinal))
Helpers.P2IS.PSP.P2ISHelper.ExtractPersona2GzBin(filePath);
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
}
else
Console.WriteLine("No file exists in this dir.");
else
Console.WriteLine("No file path detected.");
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
break;
case '5':
Console.Clear();
try
{
Console.Write("Write the file path: ");
string filePath = Console.ReadLine();
if (filePath != "")
if (Path.Exists(filePath))
Helpers.P1.PSP.P1Helper.ExtractPersona1Bin(filePath);
else
Console.WriteLine("No file exists in this dir.");
else
Console.WriteLine("No file path detected.");
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
break;
case '6':
Console.Clear();
try
{
Console.Write("Write the dir path: ");
string dirPath = Console.ReadLine();
if (dirPath != "")
if (Path.Exists(dirPath))
foreach (string filePath in Directory.GetFiles(dirPath, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".bin", StringComparison.OrdinalIgnoreCase) || s.EndsWith(".BIN", StringComparison.OrdinalIgnoreCase)))
{
try
{
Helpers.P1.PSP.P1Helper.ExtractPersona1Bin(filePath);
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
}
else
Console.WriteLine("No file exists in this dir.");
else
Console.WriteLine("No file path detected.");
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
break;
case '7':
Console.Clear();
try
{
Console.Write("Write the file path: ");
string filePath = Console.ReadLine();
if (filePath != "")
if (Path.Exists(filePath))
Helpers.P2IS.PSP.P2ISHelper.ExtractPersona2Script(filePath);
else
Console.WriteLine("No file exists in this dir.");
else
Console.WriteLine("No file path detected.");
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred: {ex.Message}");
}
break;
case '0':
Console.WriteLine("Exiting the program. Goodbye!");
break;
default:
Console.WriteLine("Invalid option. Please select a valid option.");
break;
}
if (option != '0')
{
Console.Write("(Press Enter to continue)");
Console.ReadLine();
ShowMenu();
}
}
catch (Exception ex)
{
Console.WriteLine($"An exception occurred in ShowMenu: {ex.Message}");
}
}
static void PrintHeader()
{
Console.WriteLine("***********************************************");
Console.WriteLine(" ClassicPersonaToolkit ");
Console.WriteLine(" ");
Console.WriteLine($" Year: {DateTime.Now.Year} ");
Console.WriteLine(" Thanks to Pleonex for Yarhl ");
Console.WriteLine("***********************************************");
Console.WriteLine();
}
}
}