From 55d77cf06c86726d9ebaf7abcb8de232b01af505 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 6 Dec 2022 21:50:08 -0600 Subject: [PATCH] Small improvements to read_model_xml --- src/initialize.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/initialize.cpp b/src/initialize.cpp index b75f410a1..041712d5a 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -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));