Skip to content

Commit

Permalink
OpenFileGDB: accept /vsizip/some_random_filename.zip where content is…
Browse files Browse the repository at this point in the history
… directly at top-level

Example: ogrinfo /vsizip//vsicurl/https://maps.kamloops.ca/OpenData/zipfiles/ParksGDB.zip

Fixes OSGeo#11836
  • Loading branch information
rouault committed Feb 20, 2025
1 parent b51894d commit cf73efe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions autotest/ogr/ogr_openfilegdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2958,3 +2958,12 @@ def test_ogr_openfilegdb_weird_gdbindexes():
lyr.SetAttributeFilter("id = '1'")
f = lyr.GetNextFeature()
assert f


###############################################################################


def test_ogr_openfilegdb_vsizip_random_zip_name_and_no_gdb_subdir():

with ogr.Open("/vsizip/data/filegdb/testopenfilegdb.zip") as ds:
assert ds.GetLayerCount() == 37
11 changes: 11 additions & 0 deletions ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdrivercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ GDALIdentifyEnum OGROpenFileGDBDriverIdentify(GDALOpenInfo *poOpenInfo,
}
#endif

else if (STARTS_WITH(pszFilename, "/vsizip/") && poOpenInfo->bIsDirectory)
{
VSIStatBufL stat;
return VSIStatL(
CPLFormFilenameSafe(pszFilename, "a00000001", "gdbtable")
.c_str(),
&stat) == 0
? GDAL_IDENTIFY_TRUE
: GDAL_IDENTIFY_FALSE;
}

else if (EQUAL(pszFilename, "."))
{
GDALIdentifyEnum eRet = GDAL_IDENTIFY_FALSE;
Expand Down

0 comments on commit cf73efe

Please sign in to comment.