Skip to content

Commit c3847cd

Browse files
authored
gdalinfo: do not call GDALGetFileList() if -nofl is specified (#9243)
1 parent 4129468 commit c3847cd

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

apps/gdalinfo_lib.cpp

+24-26
Original file line numberDiff line numberDiff line change
@@ -290,30 +290,31 @@ char *GDALInfo(GDALDatasetH hDataset, const GDALInfoOptions *psOptions)
290290
GDALGetDriverShortName(hDriver), GDALGetDriverLongName(hDriver));
291291
}
292292

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)
301294
{
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)
303303
{
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+
}
306314
}
307315
else
308316
{
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)
317318
{
318319
json_object *poFiles = json_object_new_array();
319320

@@ -327,20 +328,17 @@ char *GDALInfo(GDALDatasetH hDataset, const GDALInfoOptions *psOptions)
327328

328329
json_object_object_add(poJsonObject, "files", poFiles);
329330
}
330-
}
331-
else
332-
{
333-
Concat(osStr, psOptions->bStdoutOutput, "Files: %s\n",
334-
papszFileList[0]);
335-
if (psOptions->bShowFileList)
331+
else
336332
{
333+
Concat(osStr, psOptions->bStdoutOutput, "Files: %s\n",
334+
papszFileList[0]);
337335
for (int i = 1; papszFileList[i] != nullptr; i++)
338336
Concat(osStr, psOptions->bStdoutOutput, " %s\n",
339337
papszFileList[i]);
340338
}
341339
}
340+
CSLDestroy(papszFileList);
342341
}
343-
CSLDestroy(papszFileList);
344342

345343
if (bJson)
346344
{

0 commit comments

Comments
 (0)