Skip to content

Commit 856e9bc

Browse files
feat: add metadata accessor
1 parent 4446849 commit 856e9bc

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/fgptool.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ void crack(const std::string& inputPath) {
251251
std::cout << (found / static_cast<double>(total) * 100) << "% hashes identified (" << ((found - existed) / static_cast<double>(total) * 100) << "% new) for " << std::filesystem::path{inputPath}.filename().string() << std::endl;
252252
}
253253

254+
void meta(const std::string& inputPath) {
255+
const auto fgp = FGP::open(inputPath);
256+
if (!fgp) {
257+
std::cerr << "Can't open file \"" << inputPath << "\" as FGP!" << std::endl;
258+
return;
259+
}
260+
std::cout << fgp->getFilename() << std::endl;
261+
std::cout << "\tFile count: " << fgp->getEntryCount() << std::endl;
262+
std::cout << "\tLoading screen path: " << dynamic_cast<FGP&>(*fgp).getLoadingScreenFilePath() << std::endl;
263+
}
264+
254265
void dump(const std::string& inputPath) {
255266
const auto fgp = FGP::open(inputPath);
256267
if (!fgp) {
@@ -281,7 +292,7 @@ int main(int argc, const char* const argv[]) {
281292
cli.add_argument("input").metavar("PATH").help("The input path(s).").remaining().store_into(inputPaths);
282293

283294
std::string mode = "CRACK";
284-
cli.add_argument("-m", "--mode").metavar("MODE").help("The active mode. Can be EXTRACT, CRACK, DUMP, or TEST.").choices("EXTRACT", "CRACK", "DUMP", "TEST").default_value(mode).store_into(mode);
295+
cli.add_argument("-m", "--mode").metavar("MODE").help("The active mode. Can be EXTRACT, CRACK, META, DUMP, or TEST.").choices("EXTRACT", "CRACK", "META", "DUMP", "TEST").default_value(mode).store_into(mode);
285296

286297
cli.add_epilog(
287298
PROJECT_NAME " — version v" PROJECT_VERSION " — created by " PROJECT_ORGANIZATION_NAME " — licensed under MIT\n"
@@ -313,13 +324,17 @@ int main(int argc, const char* const argv[]) {
313324
if (entry.is_regular_file() && entry.path().extension().string() == ".GRP") {
314325
if (mode == "CRACK") {
315326
::crack(entry.path().string());
327+
} else if (mode == "META") {
328+
::meta(entry.path().string());
316329
} else {
317330
::dump(entry.path().string());
318331
}
319332
}
320333
}
321334
} else if (mode == "CRACK") {
322335
::crack(inputPath);
336+
} else if (mode == "META") {
337+
::meta(inputPath);
323338
} else {
324339
::dump(inputPath);
325340
}

0 commit comments

Comments
 (0)