Skip to content

Commit

Permalink
TileDB: make Identify() method return false if passed object is not a…
Browse files Browse the repository at this point in the history
… directory
  • Loading branch information
rouault committed Sep 16, 2024
1 parent e00399b commit 0a926b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 44 deletions.
40 changes: 8 additions & 32 deletions frmts/tiledb/tiledbcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,33 +118,11 @@ CPLErr TileDBDataset::AddFilter(tiledb::Context &ctx,
int TileDBDataset::Identify(GDALOpenInfo *poOpenInfo)

{
if (STARTS_WITH_CI(poOpenInfo->pszFilename, "TILEDB:"))
int nRet = TileDBDriverIdentifySimplified(poOpenInfo);
if (nRet == GDAL_IDENTIFY_UNKNOWN)
{
return TRUE;
}

try
{
const char *pszConfig =
CSLFetchNameValue(poOpenInfo->papszOpenOptions, "TILEDB_CONFIG");

if (pszConfig != nullptr)
{
return TRUE;
}

const bool bIsS3OrGS =
STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIS3/") ||
STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIGS/");
// If this is a /vsi virtual file systems, bail out, except if it is S3 or GS.
if (!bIsS3OrGS && STARTS_WITH(poOpenInfo->pszFilename, "/vsi"))
{
return false;
}

if (poOpenInfo->bIsDirectory ||
(bIsS3OrGS &&
!EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "tif")))
nRet = FALSE;
try
{
tiledb::Context ctx;
CPLString osArrayPath =
Expand All @@ -170,13 +148,11 @@ int TileDBDataset::Identify(GDALOpenInfo *poOpenInfo)
return eType == tiledb::Object::Type::Array;
}
}

return FALSE;
}
catch (...)
{
return FALSE;
catch (...)
{
}
}
return nRet;
}

/************************************************************************/
Expand Down
19 changes: 7 additions & 12 deletions frmts/tiledb/tiledbdrivercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* TileDBDriverIdentifySimplified() */
/************************************************************************/

static int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo)
int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo)

{
if (STARTS_WITH_CI(poOpenInfo->pszFilename, "TILEDB:"))
Expand All @@ -51,6 +51,11 @@ static int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo)
return TRUE;
}

if (!poOpenInfo->bIsDirectory)
{
return false;
}

const bool bIsS3OrGS = STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIS3/") ||
STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIGS/");
// If this is a /vsi virtual file systems, bail out, except if it is S3 or GS.
Expand All @@ -59,17 +64,7 @@ static int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo)
return false;
}

if (poOpenInfo->bIsDirectory)
{
return GDAL_IDENTIFY_UNKNOWN;
}

if (bIsS3OrGS && !EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "tif"))
{
return GDAL_IDENTIFY_UNKNOWN;
}

return FALSE;
return GDAL_IDENTIFY_UNKNOWN;
}

/************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions frmts/tiledb/tiledbdrivercore.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ constexpr const char *DRIVER_NAME = "TileDB";
#define TileDBDriverSetCommonMetadata \
PLUGIN_SYMBOL_NAME(TileDBDriverSetCommonMetadata)

int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo);

void TileDBDriverSetCommonMetadata(GDALDriver *poDriver);

#endif

0 comments on commit 0a926b7

Please sign in to comment.