-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
46 lines (40 loc) · 1.12 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
// Copyright (C) 2020 Ash Logan <[email protected]>
// Licensed under the terms of the GNU GPL, version 3
// http://www.gnu.org/licenses/gpl-3.0.txt
#include <rpx.hpp>
#include <fstream>
#include <cstring>
int main(int argc, char** argv) {
if(argc < 3)
{
printf("wiiurpxtool-ng - version " VERSION "\n");
printf("Compress or decompress RPL/RPX files for Wii U\n\n");
printf("Usage:\n");
printf("decompress:\n");
printf("wiiurpxtool -d <rpx_name> [out_name]\n");
printf("compress:\n");
printf("wiiurpxtool -c <rpx_name> [out_name]\n");
return 0;
}
std::ifstream infile(argv[2], std::ios::binary);
auto rpx_o = rpx::readrpx(infile);
if (!rpx_o) {
printf("Couldn't parse input file!\n");
return -1;
}
rpx::rpx rpx = *rpx_o;
std::ofstream outfile((argc == 3) ? argv[2] : argv[3], std::ios::binary);
if (strcmp("-d", argv[1]) == 0) {
printf("decompressing...\n");
rpx::decompress(rpx);
rpx::writerpx(rpx, outfile);
} else if (strcmp("-c", argv[1]) == 0) {
printf("compressing...\n");
rpx::compress(rpx);
rpx::writerpx(rpx, outfile);
} else {
printf("invalid operation\n");
return -1;
}
return 0;
}