Skip to content

Commit

Permalink
frmts/ ogr/: replace EQUAL(CPLGetExtension(...), ...) by EQUAL(CPLGet…
Browse files Browse the repository at this point in the history
…ExtensionSafe(...).c_str(), ...)

Using
```
find frmts ogr  -name "*.cpp"  -exec sed -i "s/EQUAL(CPLGetExtension(\([a-zA-Z]*\)),/EQUAL(CPLGetExtensionSafe(\1).c_str(),/" {} \;
```
  • Loading branch information
rouault committed Jan 11, 2025
1 parent 3252f21 commit 4b3597a
Show file tree
Hide file tree
Showing 35 changed files with 83 additions and 70 deletions.
2 changes: 1 addition & 1 deletion frmts/adrg/adrgdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ GDALDataset *ADRGDataset::Create(const char *pszFilename, int nXSize,
nYSize);
}

if (!EQUAL(CPLGetExtension(pszFilename), "gen"))
if (!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "gen"))
{
CPLError(CE_Failure, CPLE_NotSupported,
"Invalid filename. Must be ABCDEF01.GEN");
Expand Down
7 changes: 4 additions & 3 deletions frmts/ecw/ecwcreatecopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,8 @@ CPLErr GDALECWCompressor::Initialize(
SetParameter(CNCSJP2FileView::JP2_COMPRESS_PROFILE_NITF_BIIF_EPJE);

pszOption = CSLFetchNameValue(papszOptions, "CODESTREAM_ONLY");
if (pszOption == nullptr && EQUAL(CPLGetExtension(pszFilename), "j2k"))
if (pszOption == nullptr &&
EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "j2k"))
pszOption = "YES";
if (pszOption != nullptr)
SetParameter(CNCSJP2FileView::JP2_COMPRESS_CODESTREAM_ONLY,
Expand Down Expand Up @@ -1510,7 +1511,7 @@ GDALDataset *ECWCreateCopyECW(const char *pszFilename, GDALDataset *poSrcDS,
return nullptr;
}

if (!EQUAL(CPLGetExtension(pszFilename), "ecw"))
if (!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "ecw"))
{
CPLError(CE_Failure, CPLE_AppDefined,
"ECW driver does not support creating ECW files\n"
Expand Down Expand Up @@ -1605,7 +1606,7 @@ GDALDataset *ECWCreateCopyJPEG2000(const char *pszFilename,
return nullptr;
}

if (EQUAL(CPLGetExtension(pszFilename), "ecw"))
if (EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "ecw"))
{
CPLError(CE_Failure, CPLE_AppDefined,
"JP2ECW driver does not support creating JPEG2000 files\n"
Expand Down
2 changes: 1 addition & 1 deletion frmts/ecw/ecwdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2762,7 +2762,7 @@ GDALDataset *ECWDataset::Open(GDALOpenInfo *poOpenInfo, int bIsJPEG2000)
{
#if ECWSDK_VERSION < 50
/* Detect what is apparently the ECW v3 file format signature */
if (EQUAL(CPLGetExtension(osFilename), "ECW") &&
if (EQUAL(CPLGetExtensionSafe(osFilename).c_str(), "ECW") &&
poOpenInfo->nHeaderBytes > 0x30 &&
STARTS_WITH_CI((const char *)(poOpenInfo->pabyHeader + 0x20),
"ecw ECW3"))
Expand Down
2 changes: 1 addition & 1 deletion frmts/ers/ersdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ GDALDataset *ERSDataset::Create(const char *pszFilename, int nXSize, int nYSize,
/* -------------------------------------------------------------------- */
CPLString osBinFile, osErsFile;

if (EQUAL(CPLGetExtension(pszFilename), "ers"))
if (EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "ers"))
{
osErsFile = pszFilename;
osBinFile = osErsFile.substr(0, osErsFile.length() - 4);
Expand Down
20 changes: 11 additions & 9 deletions frmts/jp2kak/jp2kakdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2373,22 +2373,24 @@ static GDALDataset *JP2KAKCreateCopy(const char *pszFilename,
#ifdef KAKADU_JPX
jpx_family_tgt jpx_family;
jpx_target jpx_out;
const bool bIsJPX = !EQUAL(CPLGetExtension(pszFilename), "jpf") &&
!EQUAL(CPLGetExtension(pszFilename), "jpc") &&
!EQUAL(CPLGetExtension(pszFilename), "j2k") &&
!(pszCodec != NULL && EQUAL(pszCodec, "J2K"));
const bool bIsJPX =
!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "jpf") &&
!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "jpc") &&
!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "j2k") &&
!(pszCodec != NULL && EQUAL(pszCodec, "J2K"));
#endif

kdu_compressed_target *poOutputFile = nullptr;
jp2_target jp2_out;
const char *pszCodec = CSLFetchNameValueDef(papszOptions, "CODEC", nullptr);
const bool bIsJP2 = (!EQUAL(CPLGetExtension(pszFilename), "jpc") &&
!EQUAL(CPLGetExtension(pszFilename), "j2k") &&
const bool bIsJP2 =
(!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "jpc") &&
!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "j2k") &&
#ifdef KAKADU_JPX
!bIsJPX &&
!bIsJPX &&
#endif
!(pszCodec != nullptr && EQUAL(pszCodec, "J2K"))) ||
(pszCodec != nullptr && EQUAL(pszCodec, "JP2"));
!(pszCodec != nullptr && EQUAL(pszCodec, "J2K"))) ||
(pszCodec != nullptr && EQUAL(pszCodec, "JP2"));
kdu_codestream oCodeStream;

vsil_target oVSILTarget;
Expand Down
9 changes: 6 additions & 3 deletions frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,8 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO(
else
{
const char *pszBaseFilename = osFilename.c_str();
if (EQUAL(CPLGetExtension(pszBaseFilename), "kmz") &&
if (EQUAL(CPLGetExtensionSafe(pszBaseFilename).c_str(),
"kmz") &&
!STARTS_WITH(pszBaseFilename, "/vsizip/"))
{
osSubFilename = "/vsizip/";
Expand All @@ -1332,7 +1333,8 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO(
}

KmlSuperOverlayReadDataset *poSubImageDS = nullptr;
if (EQUAL(CPLGetExtension(osSubFilename), "kml"))
if (EQUAL(CPLGetExtensionSafe(osSubFilename).c_str(),
"kml"))
{
KmlSuperOverlayReadDataset *poRoot =
poParent ? poParent : this;
Expand Down Expand Up @@ -2650,7 +2652,8 @@ KmlSuperOverlayReadDataset::Open(const char *pszFilename,
if (psLink != nullptr)
{
const char *pszHref = CPLGetXMLValue(psLink, "href", nullptr);
if (pszHref == nullptr || !EQUAL(CPLGetExtension(pszHref), "kml"))
if (pszHref == nullptr ||
!EQUAL(CPLGetExtensionSafe(pszHref).c_str(), "kml"))
{
CPLDestroyXMLNode(psNode);
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion frmts/nitf/nitfdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3502,7 +3502,7 @@ int NITFDataset::CheckForRSets(const char *pszNITFFilename,
char **papszSiblingFiles)

{
bool isR0File = EQUAL(CPLGetExtension(pszNITFFilename), "r0");
bool isR0File = EQUAL(CPLGetExtensionSafe(pszNITFFilename).c_str(), "r0");

/* -------------------------------------------------------------------- */
/* Check to see if we have RSets. */
Expand Down
2 changes: 1 addition & 1 deletion frmts/pds/isis2dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ GDALDataset *ISIS2Dataset::Create(const char *pszFilename, int nXSize,
sExtension = pszExtension;
}

if (EQUAL(CPLGetExtension(pszFilename), sExtension))
if (EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), sExtension))
{
CPLError(CE_Failure, CPLE_AppDefined,
"IMAGE_EXTENSION (%s) cannot match LABEL file extension.",
Expand Down
4 changes: 2 additions & 2 deletions frmts/pds/isis3dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,7 @@ GDALDataset *ISIS3Dataset::Open(GDALOpenInfo *poOpenInfo)

// Sanity checks in case the external raw file appears to be a
// TIFF file
if (EQUAL(CPLGetExtension(osQubeFile), "tif"))
if (EQUAL(CPLGetExtensionSafe(osQubeFile).c_str(), "tif"))
{
GDALDataset *poTIF_DS =
GDALDataset::FromHandle(GDALOpen(osQubeFile, GA_ReadOnly));
Expand Down Expand Up @@ -3972,7 +3972,7 @@ GDALDataset *ISIS3Dataset::Create(const char *pszFilename, int nXSize,
const int nBlockYSize = std::max(
1, atoi(CSLFetchNameValueDef(papszOptions, "BLOCKYSIZE", "256")));
if (!EQUAL(pszDataLocation, "LABEL") &&
!EQUAL(CPLGetExtension(pszFilename), "LBL"))
!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "LBL"))
{
CPLError(CE_Failure, CPLE_NotSupported,
"For DATA_LOCATION=%s, "
Expand Down
2 changes: 1 addition & 1 deletion frmts/raw/gtxdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ GDALDataset *GTXDataset::Create(const char *pszFilename, int nXSize, int nYSize,
return nullptr;
}

if (!EQUAL(CPLGetExtension(pszFilename), "gtx"))
if (!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "gtx"))
{
CPLError(CE_Failure, CPLE_AppDefined,
"Attempt to create gtx file with extension other than gtx.");
Expand Down
12 changes: 6 additions & 6 deletions frmts/sentinel2/sentinel2dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ int SENTINEL2Dataset::Identify(GDALOpenInfo *poOpenInfo)
STARTS_WITH_CI(pszJustFilename, "S2B_OPER_PRD_MSI") ||
STARTS_WITH_CI(pszJustFilename, "S2A_USER_PRD_MSI") ||
STARTS_WITH_CI(pszJustFilename, "S2B_USER_PRD_MSI")) &&
EQUAL(CPLGetExtension(pszJustFilename), "zip"))
EQUAL(CPLGetExtensionSafe(pszJustFilename).c_str(), "zip"))
{
return TRUE;
}
Expand Down Expand Up @@ -501,7 +501,7 @@ GDALDataset *SENTINEL2Dataset::Open(GDALOpenInfo *poOpenInfo)
STARTS_WITH_CI(pszJustFilename, "S2B_OPER_PRD_MSI") ||
STARTS_WITH_CI(pszJustFilename, "S2A_USER_PRD_MSI") ||
STARTS_WITH_CI(pszJustFilename, "S2B_USER_PRD_MSI")) &&
EQUAL(CPLGetExtension(pszJustFilename), "zip"))
EQUAL(CPLGetExtensionSafe(pszJustFilename).c_str(), "zip"))
{
const CPLString osBasename(CPLGetBasename(pszJustFilename));
CPLString osFilename(poOpenInfo->pszFilename);
Expand All @@ -527,15 +527,15 @@ GDALDataset *SENTINEL2Dataset::Open(GDALOpenInfo *poOpenInfo)
}
else if ((STARTS_WITH_CI(pszJustFilename, "S2A_MSIL1C_") ||
STARTS_WITH_CI(pszJustFilename, "S2B_MSIL1C_")) &&
EQUAL(CPLGetExtension(pszJustFilename), "zip"))
EQUAL(CPLGetExtensionSafe(pszJustFilename).c_str(), "zip"))
{
const CPLString osBasename(CPLGetBasename(pszJustFilename));
CPLString osFilename(poOpenInfo->pszFilename);
CPLString osSAFE(osBasename);
// S2B_MSIL1C_20171004T233419_N0206_R001_T54DWM_20171005T001811.SAFE.zip
// has .SAFE.zip extension, but other products have just a .zip
// extension. So for the subdir in the zip only add .SAFE when needed
if (!EQUAL(CPLGetExtension(osSAFE), "SAFE"))
if (!EQUAL(CPLGetExtensionSafe(osSAFE).c_str(), "SAFE"))
osSAFE += ".SAFE";
osFilename = osFilename + "/" + osSAFE + "/MTD_MSIL1C.xml";
if (strncmp(osFilename, "/vsizip/", strlen("/vsizip/")) != 0)
Expand All @@ -546,15 +546,15 @@ GDALDataset *SENTINEL2Dataset::Open(GDALOpenInfo *poOpenInfo)
}
else if ((STARTS_WITH_CI(pszJustFilename, "S2A_MSIL2A_") ||
STARTS_WITH_CI(pszJustFilename, "S2B_MSIL2A_")) &&
EQUAL(CPLGetExtension(pszJustFilename), "zip"))
EQUAL(CPLGetExtensionSafe(pszJustFilename).c_str(), "zip"))
{
const CPLString osBasename(CPLGetBasename(pszJustFilename));
CPLString osFilename(poOpenInfo->pszFilename);
CPLString osSAFE(osBasename);
// S2B_MSIL1C_20171004T233419_N0206_R001_T54DWM_20171005T001811.SAFE.zip
// has .SAFE.zip extension, but other products have just a .zip
// extension. So for the subdir in the zip only add .SAFE when needed
if (!EQUAL(CPLGetExtension(osSAFE), "SAFE"))
if (!EQUAL(CPLGetExtensionSafe(osSAFE).c_str(), "SAFE"))
osSAFE += ".SAFE";
osFilename = osFilename + "/" + osSAFE + "/MTD_MSIL2A.xml";
if (strncmp(osFilename, "/vsizip/", strlen("/vsizip/")) != 0)
Expand Down
2 changes: 1 addition & 1 deletion frmts/xyz/xyzdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ int XYZDataset::IdentifyEx(GDALOpenInfo *poOpenInfo, int &bHasHeaderLine,
nCommentLineCount = 0;

CPLString osFilename(poOpenInfo->pszFilename);
if (EQUAL(CPLGetExtension(osFilename), "GRA") &&
if (EQUAL(CPLGetExtensionSafe(osFilename).c_str(), "GRA") &&
!poOpenInfo->IsSingleAllowedDriver("XYZ"))
{
// IGNFHeightASCIIGRID .GRA
Expand Down
5 changes: 3 additions & 2 deletions ogr/ogrsf_frmts/adbc/ogradbcdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ bool OGRADBCDataset::Open(const GDALOpenInfo *poOpenInfo)
const bool bIsSQLite3 =
(pszADBCDriverName && EQUAL(pszADBCDriverName, "adbc_driver_sqlite")) ||
OGRADBCDriverIsSQLite3(poOpenInfo);
bool bIsParquet = OGRADBCDriverIsParquet(poOpenInfo) ||
EQUAL(CPLGetExtension(pszFilename), "parquet");
bool bIsParquet =
OGRADBCDriverIsParquet(poOpenInfo) ||
EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "parquet");
const char *pszSQL = CSLFetchNameValue(poOpenInfo->papszOpenOptions, "SQL");
if (!bIsParquet && pszSQL)
{
Expand Down
4 changes: 2 additions & 2 deletions ogr/ogrsf_frmts/csv/ogrcsvdatasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ bool OGRCSVDataSource::Open(const char *pszFilename, bool bUpdateIn,
if (EQUAL(papszNames[i], ".") || EQUAL(papszNames[i], ".."))
continue;

if (EQUAL(CPLGetExtension(oSubFilename), "csvt"))
if (EQUAL(CPLGetExtensionSafe(oSubFilename).c_str(), "csvt"))
continue;

if (VSIStatL(oSubFilename, &sStatBuf) != 0 ||
Expand All @@ -667,7 +667,7 @@ bool OGRCSVDataSource::Open(const char *pszFilename, bool bUpdateIn,
continue;
}

if (EQUAL(CPLGetExtension(oSubFilename), "csv"))
if (EQUAL(CPLGetExtensionSafe(oSubFilename).c_str(), "csv"))
{
if (!OpenTable(oSubFilename, papszOpenOptionsIn))
{
Expand Down
4 changes: 2 additions & 2 deletions ogr/ogrsf_frmts/csv/ogrcsvdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ OGRCSVDriverCreate(const char *pszName, CPL_UNUSED int nBands,
// If the target is not a simple .csv then create it as a directory.
CPLString osDirName;

if (EQUAL(CPLGetExtension(pszName), "csv"))
if (EQUAL(CPLGetExtensionSafe(pszName).c_str(), "csv"))
{
osDirName = CPLGetPath(pszName);
if (osDirName == "")
Expand Down Expand Up @@ -233,7 +233,7 @@ OGRCSVDriverCreate(const char *pszName, CPL_UNUSED int nBands,
// Force it to open as a datasource.
auto poDS = std::make_unique<OGRCSVDataSource>();

if (EQUAL(CPLGetExtension(pszName), "csv"))
if (EQUAL(CPLGetExtensionSafe(pszName).c_str(), "csv"))
{
poDS->CreateForSingleFile(osDirName, pszName);
}
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogrsf_frmts/flatgeobuf/ogrflatgeobufdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ GDALDataset *OGRFlatGeobufDataset::Create(const char *pszName, int /* nBands */,
}

bool bIsDir = false;
if (!EQUAL(CPLGetExtension(pszName), "fgb"))
if (!EQUAL(CPLGetExtensionSafe(pszName).c_str(), "fgb"))
{
if (VSIMkdir(pszName, 0755) != 0)
{
Expand Down
8 changes: 4 additions & 4 deletions ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ static GDALDataset *OGRGeoconceptDriverCreate(const char *pszName,
/* Does it end with the extension .gxt indicating the user likely */
/* wants to create a single file set? */
/* -------------------------------------------------------------------- */
else if (EQUAL(CPLGetExtension(pszName), "gxt") ||
EQUAL(CPLGetExtension(pszName), "txt"))
else if (EQUAL(CPLGetExtensionSafe(pszName).c_str(), "gxt") ||
EQUAL(CPLGetExtensionSafe(pszName).c_str(), "txt"))
{
/* bSingleNewFile = TRUE; */
}
Expand Down Expand Up @@ -124,8 +124,8 @@ static CPLErr OGRGeoconceptDriverDelete(const char *pszDataSource)
}

if (VSI_ISREG(sStatBuf.st_mode) &&
(EQUAL(CPLGetExtension(pszDataSource), "gxt") ||
EQUAL(CPLGetExtension(pszDataSource), "txt")))
(EQUAL(CPLGetExtensionSafe(pszDataSource).c_str(), "gxt") ||
EQUAL(CPLGetExtensionSafe(pszDataSource).c_str(), "txt")))
{
for (int iExt = 0; apszExtensions[iExt] != nullptr; iExt++)
{
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogrsf_frmts/geojson/ogrgeojsonseqdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ bool OGRGeoJSONSeqDataSource::Create(const char *pszName,

eAccess = GA_Update;

m_bIsRSSeparated = EQUAL(CPLGetExtension(pszName), "GEOJSONS");
m_bIsRSSeparated = EQUAL(CPLGetExtensionSafe(pszName).c_str(), "GEOJSONS");

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ bool OGRGMLDataSource::Open(GDALOpenInfo *poOpenInfo)
// it transparently with /vsigzip/.
if (static_cast<GByte>(szHeader[0]) == 0x1f &&
static_cast<GByte>(szHeader[1]) == 0x8b &&
EQUAL(CPLGetExtension(pszFilename), "gz") &&
EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "gz") &&
!STARTS_WITH(pszFilename, "/vsigzip/"))
{
if (fpToClose)
Expand Down Expand Up @@ -1902,7 +1902,7 @@ bool OGRGMLDataSource::Create(const char *pszFilename, char **papszOptions)
}
else if (STARTS_WITH(pszFilename, "/vsizip/"))
{
if (EQUAL(CPLGetExtension(pszFilename), "zip"))
if (EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "zip"))
{
SetDescription(CPLFormFilename(pszFilename, "out.gml", nullptr));
}
Expand Down
4 changes: 2 additions & 2 deletions ogr/ogrsf_frmts/gtfs/ogrgtfsdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ GDALDataset *OGRGTFSDataset::Open(GDALOpenInfo *poOpenInfo)

const std::string osBaseDir(
(!STARTS_WITH(pszGTFSFilename, "/vsizip/") &&
EQUAL(CPLGetExtension(pszGTFSFilename), "zip"))
EQUAL(CPLGetExtensionSafe(pszGTFSFilename).c_str(), "zip"))
? std::string("/vsizip/{").append(pszGTFSFilename).append("}")
: std::string(pszGTFSFilename));

Expand All @@ -618,7 +618,7 @@ GDALDataset *OGRGTFSDataset::Open(GDALOpenInfo *poOpenInfo)
std::string osShapesFilename;
for (const char *pszFilename : cpl::Iterate(aosFilenames))
{
if (!EQUAL(CPLGetExtension(pszFilename), "txt"))
if (!EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "txt"))
continue;
for (const char *pszFilenameInDir : apszRequiredFiles)
{
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogrsf_frmts/ili/ogrili2datasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ int OGRILI2DataSource::Create(const char *pszFilename,
}
else if (STARTS_WITH(pszName, "/vsizip/"))
{
if (EQUAL(CPLGetExtension(pszName), "zip"))
if (EQUAL(CPLGetExtensionSafe(pszName).c_str(), "zip"))
{
char *pszNewName =
CPLStrdup(CPLFormFilename(pszName, "out.xtf", nullptr));
Expand Down
8 changes: 4 additions & 4 deletions ogr/ogrsf_frmts/libkml/ogrlibkmldatasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,13 +1528,13 @@ int OGRLIBKMLDataSource::Open(const char *pszFilename, int bUpdateIn)
}

/***** kml *****/
if (EQUAL(CPLGetExtension(pszFilename), "kml"))
if (EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "kml"))
{
return OpenKml(pszFilename, bUpdate);
}

/***** kmz *****/
if (EQUAL(CPLGetExtension(pszFilename), "kmz"))
if (EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "kmz"))
{
return OpenKmz(pszFilename, bUpdate);
}
Expand Down Expand Up @@ -1949,11 +1949,11 @@ int OGRLIBKMLDataSource::Create(const char *pszFilename, char **papszOptions)
/***** kml *****/
if (strcmp(pszFilename, "/vsistdout/") == 0 ||
STARTS_WITH(pszFilename, "/vsigzip/") ||
EQUAL(CPLGetExtension(pszFilename), "kml"))
EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "kml"))
return CreateKml(pszFilename, papszOptions);

/***** kmz *****/
if (EQUAL(CPLGetExtension(pszFilename), "kmz"))
if (EQUAL(CPLGetExtensionSafe(pszFilename).c_str(), "kmz"))
return CreateKmz(pszFilename, papszOptions);

/***** dir *****/
Expand Down
Loading

0 comments on commit 4b3597a

Please sign in to comment.