From 15685f9922b36ba2f9ac077d789cfc73c8d52a28 Mon Sep 17 00:00:00 2001 From: shahramn Date: Mon, 9 Sep 2024 21:00:46 +0100 Subject: [PATCH] Tools: Set key 'file' for grib_ls --- tools/grib_ls.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/grib_ls.cc b/tools/grib_ls.cc index c5d06df01..08578502f 100644 --- a/tools/grib_ls.cc +++ b/tools/grib_ls.cc @@ -371,10 +371,6 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) } if (!json_latlon && options->json_output) { - if (options->current_infile && options->current_infile->name) { - size_t len = strlen(options->current_infile->name); - grib_set_string(h, "file", options->current_infile->name, &len); - } if (!first_handle && options->handle_count > 1) { fprintf(stdout, ",\n"); } @@ -383,6 +379,12 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) first_handle = 0; } } + + if (options->current_infile && options->current_infile->name) { + size = strlen(options->current_infile->name); + grib_set_string(h, "file", options->current_infile->name, &size); + } + new_handle = "\n,"; return 0; }