mirror of https://github.com/ecmwf/eccodes.git
ECC-748: better error messages
This commit is contained in:
parent
47accafef5
commit
e0f82b7288
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue