Merge branch 'develop' into feature/ECC-539-avoid-overwrite

This commit is contained in:
Shahram Najm 2021-01-25 14:26:58 +00:00
commit d9cd84512b
2 changed files with 5 additions and 3 deletions

View File

@ -961,6 +961,7 @@ long grib_get_api_version(void);
void grib_print_api_version(FILE* out);
const char* grib_get_package_name(void);
grib_context* grib_context_get_default(void);
char* codes_resolve_path(grib_context* c, char* path);
char* grib_context_full_defs_path(grib_context* c, const char* basename);
char* grib_samples_path(const grib_context* c);
char* grib_definition_path(const grib_context* c);

View File

@ -604,7 +604,8 @@ grib_context* grib_context_new(grib_context* parent)
#endif /* function removed */
/* GRIB-235: Resolve path to expand symbolic links etc */
static char* resolve_path(grib_context* c, char* path)
/* Note: return value is allocated. Client has to free */
char* codes_resolve_path(grib_context* c, char* path)
{
char* result = NULL;
#if defined(ECCODES_HAVE_REALPATH)
@ -651,7 +652,7 @@ static int init_definition_files_dir(grib_context* c)
if (*p != ECC_PATH_DELIMITER_CHAR) {
/* No delimiter found so this is a single directory */
c->grib_definition_files_dir = (grib_string_list*)grib_context_malloc_clear_persistent(c, sizeof(grib_string_list));
c->grib_definition_files_dir->value = resolve_path(c, path);
c->grib_definition_files_dir->value = codes_resolve_path(c, path);
}
else {
/* Definitions path contains multiple directories */
@ -667,7 +668,7 @@ static int init_definition_files_dir(grib_context* c)
c->grib_definition_files_dir = (grib_string_list*)grib_context_malloc_clear_persistent(c, sizeof(grib_string_list));
next = c->grib_definition_files_dir;
}
next->value = resolve_path(c, dir);
next->value = codes_resolve_path(c, dir);
dir = strtok(NULL, ECC_PATH_DELIMITER_STR);
}
}