#9455 libecl: Fix summary restart absolute path issues

Test for absolute path before other logic during extraction of summary restart file path.
This commit is contained in:
Magne Sjaastad 2022-11-10 10:45:24 +01:00
parent 4fea00afbf
commit daa8d7305b

View File

@ -882,7 +882,6 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi
restart_base = util_alloc_strip_copy( tmp_base );
if (strlen(restart_base)) { /* We ignore the empty ones. */
char * smspec_header;
/*
The conditional block here is to support the following situation:
@ -904,18 +903,23 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi
}
#endif
std::string path = ecl::util::path::dirname( ecl_smspec->header_file );
smspec_header = ecl_util_alloc_exfilename( path.c_str() , restart_base , ECL_SUMMARY_HEADER_FILE , ecl_smspec->formatted , 0);
if (smspec_header) {
if (!util_same_file(smspec_header , ecl_smspec->header_file.c_str())) /* Restart from the current case is ignored. */ {
if (util_is_abs_path(restart_base))
ecl_smspec->restart_case = restart_base;
else {
char * tmp_path = util_alloc_filename( path.c_str() , restart_base , NULL );
char * abs_path = util_alloc_abs_path(tmp_path);
ecl_smspec->restart_case = abs_path;
free( abs_path );
free( tmp_path );
if (util_is_abs_path(restart_base)) {
ecl_smspec->restart_case = restart_base;
}
else {
std::string path = ecl::util::path::dirname(ecl_smspec->header_file);
char* smspec_header = ecl_util_alloc_exfilename( path.c_str() , restart_base , ECL_SUMMARY_HEADER_FILE , ecl_smspec->formatted , 0);
if (smspec_header) {
if (!util_same_file(smspec_header , ecl_smspec->header_file.c_str())) /* Restart from the current case is ignored. */ {
if (util_is_abs_path(restart_base))
ecl_smspec->restart_case = restart_base;
else {
char * tmp_path = util_alloc_filename( path.c_str() , restart_base , NULL );
char * abs_path = util_alloc_abs_path(tmp_path);
ecl_smspec->restart_case = abs_path;
free( abs_path );
free( tmp_path );
}
}
}
free( smspec_header );