@@ -290,30 +290,31 @@ char *GDALInfo(GDALDatasetH hDataset, const GDALInfoOptions *psOptions)
290
290
GDALGetDriverShortName (hDriver), GDALGetDriverLongName (hDriver));
291
291
}
292
292
293
- // The list of files of a raster FileGDB is not super useful and potentially
294
- // super long, so omit it, unless the -json mode is enabled
295
- char **papszFileList =
296
- (!bJson && EQUAL (GDALGetDriverShortName (hDriver), " OpenFileGDB" ))
297
- ? nullptr
298
- : GDALGetFileList (hDataset);
299
-
300
- if (papszFileList == nullptr || *papszFileList == nullptr )
293
+ if (psOptions->bShowFileList )
301
294
{
302
- if (bJson)
295
+ // The list of files of a raster FileGDB is not super useful and potentially
296
+ // super long, so omit it, unless the -json mode is enabled
297
+ char **papszFileList =
298
+ (!bJson && EQUAL (GDALGetDriverShortName (hDriver), " OpenFileGDB" ))
299
+ ? nullptr
300
+ : GDALGetFileList (hDataset);
301
+
302
+ if (!papszFileList || *papszFileList == nullptr )
303
303
{
304
- json_object *poFiles = json_object_new_array ();
305
- json_object_object_add (poJsonObject, " files" , poFiles);
304
+ if (bJson)
305
+ {
306
+ json_object *poFiles = json_object_new_array ();
307
+ json_object_object_add (poJsonObject, " files" , poFiles);
308
+ }
309
+ else
310
+ {
311
+ Concat (osStr, psOptions->bStdoutOutput ,
312
+ " Files: none associated\n " );
313
+ }
306
314
}
307
315
else
308
316
{
309
- Concat (osStr, psOptions->bStdoutOutput , " Files: none associated\n " );
310
- }
311
- }
312
- else
313
- {
314
- if (bJson)
315
- {
316
- if (psOptions->bShowFileList )
317
+ if (bJson)
317
318
{
318
319
json_object *poFiles = json_object_new_array ();
319
320
@@ -327,20 +328,17 @@ char *GDALInfo(GDALDatasetH hDataset, const GDALInfoOptions *psOptions)
327
328
328
329
json_object_object_add (poJsonObject, " files" , poFiles);
329
330
}
330
- }
331
- else
332
- {
333
- Concat (osStr, psOptions->bStdoutOutput , " Files: %s\n " ,
334
- papszFileList[0 ]);
335
- if (psOptions->bShowFileList )
331
+ else
336
332
{
333
+ Concat (osStr, psOptions->bStdoutOutput , " Files: %s\n " ,
334
+ papszFileList[0 ]);
337
335
for (int i = 1 ; papszFileList[i] != nullptr ; i++)
338
336
Concat (osStr, psOptions->bStdoutOutput , " %s\n " ,
339
337
papszFileList[i]);
340
338
}
341
339
}
340
+ CSLDestroy (papszFileList);
342
341
}
343
- CSLDestroy (papszFileList);
344
342
345
343
if (bJson)
346
344
{
0 commit comments