forked from Megaflan/ClassicPersonaToolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
170 lines (162 loc) · 7.36 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
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)");
Console.WriteLine("2. Test Function 2 (Extract all P2 BIN in a dir)");
Console.WriteLine("3. Test Function 3 (Extract P2 GZBIN)");
Console.WriteLine("4. Test Function 4 (Extract all P2 GZBIN in a dir)");
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"))
{
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"))
{
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 '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();
}
}
}