tools/eupak: Add check for if user provides a valid directory path

Oops.
This commit is contained in:
Lily Tsuru 2025-01-15 19:37:01 -05:00
parent d9dae6e6ac
commit ee89213a57

View file

@ -8,6 +8,7 @@
#include <EupakConfig.hpp> #include <EupakConfig.hpp>
#include <europa/io/PakReader.hpp> #include <europa/io/PakReader.hpp>
#include <filesystem>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <tasks/InfoTask.hpp> #include <tasks/InfoTask.hpp>
@ -50,6 +51,12 @@ namespace eupak::tasks {
try { try {
args.verbose = parser.get<bool>("--verbose"); args.verbose = parser.get<bool>("--verbose");
args.inputPath = eupak::fs::path(parser.get("input")); args.inputPath = eupak::fs::path(parser.get("input"));
if(fs::is_directory(args.inputPath)) {
std::cout << "Error: " << args.inputPath << " appears to be a directory, not a file.\n";
return 1;
}
} catch(...) { } catch(...) {
return 1; return 1;
} }
@ -63,6 +70,7 @@ namespace eupak::tasks {
int InfoTask::Run() { int InfoTask::Run() {
const auto& args = currentArgs; const auto& args = currentArgs;
std::ifstream ifs(args.inputPath.string(), std::ifstream::binary); std::ifstream ifs(args.inputPath.string(), std::ifstream::binary);
if(!ifs) { if(!ifs) {