Skip to content

Commit

Permalink
Add GDALDataset::ReportUpdateNotSupportedByDriver() and use it in dri…
Browse files Browse the repository at this point in the history
…vers
  • Loading branch information
rouault committed Jan 26, 2025
1 parent dbbda6e commit 48d769f
Show file tree
Hide file tree
Showing 69 changed files with 89 additions and 206 deletions.
4 changes: 1 addition & 3 deletions frmts/adrg/adrgdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1616,9 +1616,7 @@ GDALDataset *ADRGDataset::Open(GDALOpenInfo *poOpenInfo)
{
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The ADRG driver does not support update access to "
"existing datasets.");
ReportUpdateNotSupportedByDriver("ADRG");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/adrg/srpdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1615,9 +1615,7 @@ GDALDataset *SRPDataset::Open(GDALOpenInfo *poOpenInfo)

if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The SRP driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("SRP");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/aigrid/aigdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,7 @@ GDALDataset *AIGDataset::Open(GDALOpenInfo *poOpenInfo)
if (poOpenInfo->eAccess == GA_Update)
{
AIGClose(psInfo);
CPLError(CE_Failure, CPLE_NotSupported,
"The AIG driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("AIG");
return nullptr;
}
/* -------------------------------------------------------------------- */
Expand Down
4 changes: 1 addition & 3 deletions frmts/airsar/airsardataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,7 @@ GDALDataset *AirSARDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The AIRSAR driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("AIRSAR");
CSLDestroy(papszMD);
return nullptr;
}
Expand Down
4 changes: 1 addition & 3 deletions frmts/blx/blxdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ GDALDataset *BLXDataset::Open(GDALOpenInfo *poOpenInfo)
if (poOpenInfo->eAccess == GA_Update)
{
delete poDS;
CPLError(CE_Failure, CPLE_NotSupported,
"The BLX driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("BLX");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/bsb/bsbdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,7 @@ GDALDataset *BSBDataset::Open(GDALOpenInfo *poOpenInfo)

if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The BSB driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("BSB");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/ceos/ceosdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ GDALDataset *CEOSDataset::Open(GDALOpenInfo *poOpenInfo)
if (poOpenInfo->eAccess == GA_Update)
{
CEOSClose(psCEOS);
CPLError(CE_Failure, CPLE_NotSupported,
"The CEOS driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("CEOS");
return nullptr;
}
/* -------------------------------------------------------------------- */
Expand Down
5 changes: 1 addition & 4 deletions frmts/ceos2/sar_ceosdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1791,10 +1791,7 @@ GDALDataset *SAR_CEOSDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(
CE_Failure, CPLE_NotSupported,
"The SAR_CEOS driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("SAR_CEOS");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/coasp/coasp_dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,7 @@ GDALDataset *COASPDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The COASP driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("COASP");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/cosar/cosar_dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ GDALDataset *COSARDataset::Open(GDALOpenInfo *pOpenInfo)
/* -------------------------------------------------------------------- */
if (pOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The COSAR driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("COSAR");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/ctg/ctgdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,7 @@ GDALDataset *CTGDataset::Open(GDALOpenInfo *poOpenInfo)

if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The CTG driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("CTG");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/dimap/dimapdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ GDALDataset *DIMAPDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The DIMAP driver does not support update access to existing "
" datasets.");
ReportUpdateNotSupportedByDriver("DIMAP");
return nullptr;
}
/* -------------------------------------------------------------------- */
Expand Down
4 changes: 1 addition & 3 deletions frmts/envisat/envisatdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,9 +899,7 @@ GDALDataset *EnvisatDataset::Open(GDALOpenInfo *poOpenInfo)
if (poOpenInfo->eAccess == GA_Update)
{
EnvisatFile_Close(hEnvisatFile);
CPLError(CE_Failure, CPLE_NotSupported,
"The ENVISAT driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("ENVISAT");
return nullptr;
}
/* -------------------------------------------------------------------- */
Expand Down
4 changes: 1 addition & 3 deletions frmts/fit/fitdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,7 @@ GDALDataset *FITDataset::Open(GDALOpenInfo *poOpenInfo)

if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The FIT driver does not support update access to existing"
" files.\n");
ReportUpdateNotSupportedByDriver("FIT");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/gff/gff_dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ GDALDataset *GFFDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The GFF driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("GFF");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/gif/biggifdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ GDALDataset *BIGGIFDataset::Open(GDALOpenInfo *poOpenInfo)

if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The GIF driver does not support update access to existing"
" files.\n");
ReportUpdateNotSupportedByDriver("GIF");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/gif/gifdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ GDALDataset *GIFDataset::Open(GDALOpenInfo *poOpenInfo)

if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The GIF driver does not support update access to existing"
" files.");
ReportUpdateNotSupportedByDriver("GIF");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/grib/gribdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,9 +1485,7 @@ GDALDataset *GRIBDataset::Open(GDALOpenInfo *poOpenInfo)
// Confirm the requested access is supported.
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The GRIB driver does not support update access to existing "
"datasets.");
ReportUpdateNotSupportedByDriver("GRIB");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/gxf/gxfdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,7 @@ GDALDataset *GXFDataset::Open(GDALOpenInfo *poOpenInfo)
if (poOpenInfo->eAccess == GA_Update)
{
GXFClose(l_hGXF);
CPLError(CE_Failure, CPLE_NotSupported,
"The GXF driver does not support update access to existing"
" datasets.");
ReportUpdateNotSupportedByDriver("GXF");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/hdf4/hdf4dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,7 @@ GDALDataset *HDF4Dataset::Open(GDALOpenInfo *poOpenInfo)
delete poDS;
CPLAcquireMutex(hHDF4Mutex, 1000.0);

CPLError(CE_Failure, CPLE_NotSupported,
"The HDF4 driver does not support update access to "
"existing datasets.");
ReportUpdateNotSupportedByDriver(HDF4_DRIVER_NAME);
return nullptr;
}
}
Expand Down
3 changes: 1 addition & 2 deletions frmts/hdf5/bagdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2621,8 +2621,7 @@ GDALDataset *BAGDataset::Open(GDALOpenInfo *poOpenInfo)
// Confirm the requested access is supported.
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The BAG driver does not support update access.");
ReportUpdateNotSupportedByDriver("BAG");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/hdf5/hdf5dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,7 @@ GDALDataset *HDF5Dataset::Open(GDALOpenInfo *poOpenInfo)
if (poOpenInfo->eAccess == GA_Update)
{
delete poDS;
CPLError(CE_Failure, CPLE_NotSupported,
"The HDF5 driver does not support update access to "
"existing datasets.");
ReportUpdateNotSupportedByDriver("HDF5");
return nullptr;
}
}
Expand Down
4 changes: 1 addition & 3 deletions frmts/hdf5/hdf5imagedataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,7 @@ GDALDataset *HDF5ImageDataset::Open(GDALOpenInfo *poOpenInfo)
// Confirm the requested access is supported.
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The HDF5ImageDataset driver does not support update access "
"to existing datasets.");
ReportUpdateNotSupportedByDriver("HDF5");
return nullptr;
}

Expand Down
3 changes: 1 addition & 2 deletions frmts/hdf5/s102dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ GDALDataset *S102Dataset::Open(GDALOpenInfo *poOpenInfo)
// Confirm the requested access is supported.
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The S102 driver does not support update access.");
ReportUpdateNotSupportedByDriver("S102");
return nullptr;
}

Expand Down
3 changes: 1 addition & 2 deletions frmts/hdf5/s104dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ GDALDataset *S104Dataset::Open(GDALOpenInfo *poOpenInfo)
// Confirm the requested access is supported.
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The S104 driver does not support update access.");
ReportUpdateNotSupportedByDriver("S104");
return nullptr;
}

Expand Down
3 changes: 1 addition & 2 deletions frmts/hdf5/s111dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ GDALDataset *S111Dataset::Open(GDALOpenInfo *poOpenInfo)
// Confirm the requested access is supported.
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The S111 driver does not support update access.");
ReportUpdateNotSupportedByDriver("S111");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/iris/irisdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,7 @@ GDALDataset *IRISDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The IRIS driver does not support update access to existing"
" datasets.");
ReportUpdateNotSupportedByDriver("IRIS");
return nullptr;
}

Expand Down
5 changes: 1 addition & 4 deletions frmts/jaxapalsar/jaxapalsardataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,7 @@ GDALDataset *PALSARJaxaDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(
CE_Failure, CPLE_NotSupported,
"The JAXAPALSAR driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("JAXAPALSAR");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/jdem/jdemdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ GDALDataset *JDEMDataset::Open(GDALOpenInfo *poOpenInfo)
// Confirm the requested access is supported.
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The JDEM driver does not support update access to existing "
"datasets.");
ReportUpdateNotSupportedByDriver("JDEM");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/jpeg/jpgdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2762,9 +2762,7 @@ GDALDataset *JPGDatasetCommon::Open(GDALOpenInfo *poOpenInfo)

if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The JPEG driver does not support update access to existing"
" datasets.");
ReportUpdateNotSupportedByDriver("JPEG");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/l1b/l1bdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3330,9 +3330,7 @@ GDALDataset *L1BDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The L1B driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("L1B");
if (fp != nullptr)
CPL_IGNORE_RET_VAL(VSIFCloseL(fp));
return nullptr;
Expand Down
4 changes: 1 addition & 3 deletions frmts/map/mapdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ GDALDataset *MAPDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The MAP driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("MAP");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/msg/msgdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,7 @@ GDALDataset *MSGDataset::Open(GDALOpenInfo *poOpenInfo)
if (poOpenInfo->eAccess == GA_Update)
{
delete poDS;
CPLError(CE_Failure, CPLE_NotSupported,
"The MSG driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("MSG");
return nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions frmts/msgn/msgndataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,7 @@ GDALDataset *MSGNDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
if (poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"The MSGN driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("MSGN");
return nullptr;
}

Expand Down
5 changes: 1 addition & 4 deletions frmts/ngsgeoid/ngsgeoiddataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,7 @@ GDALDataset *NGSGEOIDDataset::Open(GDALOpenInfo *poOpenInfo)

if (poOpenInfo->eAccess == GA_Update)
{
CPLError(
CE_Failure, CPLE_NotSupported,
"The NGSGEOID driver does not support update access to existing"
" datasets.\n");
ReportUpdateNotSupportedByDriver("NGSGEOID");
return nullptr;
}

Expand Down
3 changes: 1 addition & 2 deletions frmts/nitf/ecrgtocdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,8 +1036,7 @@ GDALDataset *ECRGTOCDataset::Open(GDALOpenInfo *poOpenInfo)

if (poDS && poOpenInfo->eAccess == GA_Update)
{
CPLError(CE_Failure, CPLE_NotSupported,
"ECRGTOC driver does not support update mode");
ReportUpdateNotSupportedByDriver("ECRGTOC");
delete poDS;
return nullptr;
}
Expand Down
Loading

0 comments on commit 48d769f

Please sign in to comment.