Skip to content

Commit 61b7b1e

Browse files
committed
Append a Trailing / to Prefix
1 parent 59bb1cd commit 61b7b1e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Src/Base/AMReX_ParmParse.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,14 @@ read_file (const char* fname, ParmParse::Table& tab)
411411
std::string filename = fname;
412412

413413
// optional prefix to search files in
414-
char const *amrex_inputs_file_prefix = std::getenv("AMREX_INPUTS_FILE_PREFIX");
415-
if (amrex_inputs_file_prefix != nullptr) {
416-
filename = std::string(amrex_inputs_file_prefix) + filename;
414+
char const *amrex_inputs_file_prefix_c = std::getenv("AMREX_INPUTS_FILE_PREFIX");
415+
if (amrex_inputs_file_prefix_c != nullptr) {
416+
// we expect a directory path as the prefix: append a trailing "/" if missing
417+
auto amrex_inputs_file_prefix = std::string(amrex_inputs_file_prefix_c);
418+
if (amrex_inputs_file_prefix.back() != "/") {
419+
amrex_inputs_file_prefix += "/";
420+
}
421+
filename = amrex_inputs_file_prefix + filename;
417422
}
418423

419424
#ifdef AMREX_USE_MPI

0 commit comments

Comments
 (0)