Skip to content

Commit

Permalink
Handle non-existent filename extension reliably
Browse files Browse the repository at this point in the history
  • Loading branch information
mattw-nws committed Jun 23, 2023
1 parent 7551590 commit 39876f0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/realizations/catchment/AbstractCLibBmiAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ namespace models {
if (!utils::FileChecker::file_is_readable(bmi_lib_file)) {
//Try alternative extension...
size_t idx = bmi_lib_file.rfind(".");
std::string alt_bmi_lib_file;
if(idx == string::npos){
idx = bmi_lib_file.length()-1;
}
std::string alt_bmi_lib_file;
if(bmi_lib_file.substr(idx) == ".so"){
alt_bmi_lib_file = bmi_lib_file.substr(0,idx) + ".dylib";
} else if(bmi_lib_file.substr(idx) == ".dylib"){
Expand Down

0 comments on commit 39876f0

Please sign in to comment.