Implement recursive search for scenarios, allowing you to organize your scenarios directory

This commit is contained in:
2015-06-26 14:12:29 -04:00
parent 2bb89f127c
commit 95b3d7e30e
4 changed files with 49 additions and 6 deletions

View File

@@ -1787,11 +1787,19 @@ bool load_scenario_v2(fs::path file_to_load, cScenario& scenario, bool only_head
bool is_packed = true;
tarball pack;
std::ifstream fin;
if(!fs::exists(file_to_load)) {
giveError("The scenario could not be found.");
return false;
}
if(fs::is_directory(file_to_load)) { // Unpacked
is_packed = false;
} else { // Packed
igzstream gzin(file_to_load.string().c_str());
pack.readFrom(gzin);
if(gzin.bad()) {
giveError("There was an error loading the scenario.");
return false;
}
}
auto getFile = [&](std::string relpath) -> std::istream& {
if(is_packed) return pack.getFile(relpath);