mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Fix bug for when local cross_sections.xml is specified
This commit is contained in:
parent
ab4ef1d7be
commit
32d041ec90
1 changed files with 15 additions and 4 deletions
|
|
@ -76,8 +76,10 @@ Library::Library(pugi::xml_node node, const std::string& directory)
|
|||
path_ = path;
|
||||
} else if (ends_with(directory, "/")) {
|
||||
path_ = directory + path;
|
||||
} else {
|
||||
} else if (!directory.empty()) {
|
||||
path_ = directory + "/" + path;
|
||||
} else {
|
||||
path_ = path;
|
||||
}
|
||||
|
||||
if (!file_exists(path_)) {
|
||||
|
|
@ -135,6 +137,13 @@ void read_cross_sections_xml()
|
|||
}
|
||||
} else {
|
||||
settings::path_cross_sections = get_node_value(root, "cross_sections");
|
||||
|
||||
// If no '/' found, the file is probably in the input directory
|
||||
auto pos = settings::path_cross_sections.rfind("/");
|
||||
if (pos == std::string::npos && !settings::path_input.empty()) {
|
||||
settings::path_cross_sections =
|
||||
settings::path_input + "/" + settings::path_cross_sections;
|
||||
}
|
||||
}
|
||||
|
||||
// Now that the cross_sections.xml or mgxs.h5 has been located, read it in
|
||||
|
|
@ -295,10 +304,12 @@ void read_ce_cross_sections_xml()
|
|||
// TODO: Use std::filesystem functionality when C++17 is adopted
|
||||
auto pos = filename.rfind("/");
|
||||
if (pos == std::string::npos) {
|
||||
// no '/' found, probably a Windows directory
|
||||
pos = filename.rfind("\\");
|
||||
// No '\\' found, so the file must be in the same directory as
|
||||
// materials.xml
|
||||
directory = settings::path_input;
|
||||
} else {
|
||||
directory = filename.substr(0, pos);
|
||||
}
|
||||
directory = filename.substr(0, pos);
|
||||
}
|
||||
|
||||
for (const auto& node_library : root.children("library")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue