diff --git a/tools/bufr_compare.c b/tools/bufr_compare.c index 20bf343b9..ff3a159d3 100644 --- a/tools/bufr_compare.c +++ b/tools/bufr_compare.c @@ -400,7 +400,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/bufr_copy.c b/tools/bufr_copy.c index 61539f604..6a94d71e4 100644 --- a/tools/bufr_copy.c +++ b/tools/bufr_copy.c @@ -88,7 +88,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/bufr_filter.c b/tools/bufr_filter.c index 28ed50825..765d1422b 100644 --- a/tools/bufr_filter.c +++ b/tools/bufr_filter.c @@ -73,6 +73,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/bufr_get.c b/tools/bufr_get.c index 235a8f580..d1d643763 100644 --- a/tools/bufr_get.c +++ b/tools/bufr_get.c @@ -71,7 +71,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/bufr_ls.c b/tools/bufr_ls.c index e7bfba744..e62ae3d30 100644 --- a/tools/bufr_ls.c +++ b/tools/bufr_ls.c @@ -82,7 +82,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/grib_copy.c b/tools/grib_copy.c index 680120af9..e94084fd5 100644 --- a/tools/grib_copy.c +++ b/tools/grib_copy.c @@ -92,7 +92,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/grib_dump.c b/tools/grib_dump.c index 743ae2198..d364275fd 100644 --- a/tools/grib_dump.c +++ b/tools/grib_dump.c @@ -125,7 +125,7 @@ int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* fil if (!options->current_infile->name) return 0; if (json) return 0; - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); sprintf(tmp,"FILE: %s ",options->current_infile->name); if (!grib_options_on("C")) diff --git a/tools/grib_filter.c b/tools/grib_filter.c index 54a9c3c21..ba6098895 100644 --- a/tools/grib_filter.c +++ b/tools/grib_filter.c @@ -66,7 +66,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/grib_get.c b/tools/grib_get.c index 84dea1eb2..008f94523 100644 --- a/tools/grib_get.c +++ b/tools/grib_get.c @@ -160,7 +160,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/grib_get_data.c b/tools/grib_get_data.c index 1d2bfd821..11eea374b 100644 --- a/tools/grib_get_data.c +++ b/tools/grib_get_data.c @@ -67,7 +67,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/grib_ls.c b/tools/grib_ls.c index 492ace8a7..d3fa35800 100644 --- a/tools/grib_ls.c +++ b/tools/grib_ls.c @@ -193,7 +193,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { - exit_if_input_is_directory(file->name); + exit_if_input_is_directory(grib_tool_name, file->name); return 0; } diff --git a/tools/grib_tools.c b/tools/grib_tools.c index 2c788b647..88878a1f7 100644 --- a/tools/grib_tools.c +++ b/tools/grib_tools.c @@ -1112,13 +1112,13 @@ void grib_tools_write_message(grib_runtime_options* options, grib_handle* h) #endif } -int exit_if_input_is_directory(const char* filename) +int exit_if_input_is_directory(const char* tool_name, const char* filename) { struct stat s; int stat_val = stat(filename, &s); if ( stat_val == 0 ) { if (S_ISDIR(s.st_mode)) { - fprintf(stderr, "ERROR: \"%s\": Is a directory\n", filename); + fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", tool_name, filename); exit(1); } } diff --git a/tools/grib_tools.h b/tools/grib_tools.h index b822a8f5e..278532867 100644 --- a/tools/grib_tools.h +++ b/tools/grib_tools.h @@ -199,7 +199,7 @@ int grib_process_runtime_options(grib_context* c,int argc,char** argv,grib_runti void grib_tools_write_message(grib_runtime_options* options, grib_handle* h); int grib_tool_new_filename_action(grib_runtime_options* options,const char* file); int grib_no_handle_action(grib_runtime_options* options,int err); -int exit_if_input_is_directory(const char* filename); +int exit_if_input_is_directory(const char* tool_name, const char* filename); #endif