Small improvements to read_model_xml

This commit is contained in:
Patrick Shriwise 2022-12-06 21:50:08 -06:00
parent 7fdfed22f3
commit 55d77cf06c

View file

@ -284,7 +284,9 @@ int parse_command_line(int argc, char* argv[])
// check that the path is either a valid directory or file
if (!is_dir(settings::path_input) && !file_exists(settings::path_input)) {
fatal_error(fmt::format("The specified path '{}' does not exist.", settings::path_input));
fatal_error(fmt::format(
"The path specified to the OpenMC executable '{}' does not exist.",
settings::path_input));
}
// Add slash at end of directory if it isn't the
@ -297,13 +299,14 @@ int parse_command_line(int argc, char* argv[])
}
bool read_model_xml() {
std::string model_filename = settings::path_input;
std::string model_filename =
settings::path_input.empty() ? "." : settings::path_input;
// some string cleanup
// a trailing "/" is applied to path_input if it's present,
// a trailing "/" is applied to path_input if it's specified,
// remove it for the first attempt at reading the input file
if (ends_with(model_filename, "/")) model_filename.pop_back();
if (model_filename.length() == 0) model_filename = ".";
if (ends_with(model_filename, "/"))
model_filename.pop_back();
// if the current filename is a directory, append the default model filename
if (is_dir(model_filename)) model_filename += "/model.xml";
@ -313,7 +316,6 @@ bool read_model_xml() {
// try to process the path input as an XML file
pugi::xml_document doc;
// if the input is a file, try to read it
if (!doc.load_file(model_filename.c_str())) {
fatal_error(fmt::format(
"Error reading from single XML input file '{}'", model_filename));