From 48d769f863fddb344e5b1f2e5eac60cea7c26497 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 25 Jan 2025 20:28:33 +0100 Subject: [PATCH] Add GDALDataset::ReportUpdateNotSupportedByDriver() and use it in drivers --- frmts/adrg/adrgdataset.cpp | 4 +--- frmts/adrg/srpdataset.cpp | 4 +--- frmts/aigrid/aigdataset.cpp | 4 +--- frmts/airsar/airsardataset.cpp | 4 +--- frmts/blx/blxdataset.cpp | 4 +--- frmts/bsb/bsbdataset.cpp | 4 +--- frmts/ceos/ceosdataset.cpp | 4 +--- frmts/ceos2/sar_ceosdataset.cpp | 5 +---- frmts/coasp/coasp_dataset.cpp | 4 +--- frmts/cosar/cosar_dataset.cpp | 4 +--- frmts/ctg/ctgdataset.cpp | 4 +--- frmts/dimap/dimapdataset.cpp | 4 +--- frmts/envisat/envisatdataset.cpp | 4 +--- frmts/fit/fitdataset.cpp | 4 +--- frmts/gff/gff_dataset.cpp | 4 +--- frmts/gif/biggifdataset.cpp | 4 +--- frmts/gif/gifdataset.cpp | 4 +--- frmts/grib/gribdataset.cpp | 4 +--- frmts/gxf/gxfdataset.cpp | 4 +--- frmts/hdf4/hdf4dataset.cpp | 4 +--- frmts/hdf5/bagdataset.cpp | 3 +-- frmts/hdf5/hdf5dataset.cpp | 4 +--- frmts/hdf5/hdf5imagedataset.cpp | 4 +--- frmts/hdf5/s102dataset.cpp | 3 +-- frmts/hdf5/s104dataset.cpp | 3 +-- frmts/hdf5/s111dataset.cpp | 3 +-- frmts/iris/irisdataset.cpp | 4 +--- frmts/jaxapalsar/jaxapalsardataset.cpp | 5 +---- frmts/jdem/jdemdataset.cpp | 4 +--- frmts/jpeg/jpgdataset.cpp | 4 +--- frmts/l1b/l1bdataset.cpp | 4 +--- frmts/map/mapdataset.cpp | 4 +--- frmts/msg/msgdataset.cpp | 4 +--- frmts/msgn/msgndataset.cpp | 4 +--- frmts/ngsgeoid/ngsgeoiddataset.cpp | 5 +---- frmts/nitf/ecrgtocdataset.cpp | 3 +-- frmts/nitf/rpftocdataset.cpp | 6 ++---- frmts/png/pngdataset.cpp | 4 +--- frmts/r/rdataset.cpp | 4 +--- frmts/raw/cpgdataset.cpp | 4 +--- frmts/raw/doq1dataset.cpp | 4 +--- frmts/raw/doq2dataset.cpp | 8 ++------ frmts/raw/eirdataset.cpp | 4 +--- frmts/raw/fastdataset.cpp | 4 +--- frmts/raw/gscdataset.cpp | 4 +--- frmts/raw/lcpdataset.cpp | 4 +--- frmts/raw/loslasdataset.cpp | 4 +--- frmts/raw/ndfdataset.cpp | 8 ++------ frmts/raw/nsidcbindataset.cpp | 5 +---- frmts/raw/snodasdataset.cpp | 4 +--- frmts/rcm/rcmdataset.cpp | 4 +--- frmts/rdb/rdbdataset.cpp | 4 +--- frmts/rik/rikdataset.cpp | 4 +--- frmts/rs2/rs2dataset.cpp | 4 +--- frmts/safe/safedataset.cpp | 4 +--- frmts/sdts/sdtsdataset.cpp | 4 +--- frmts/til/tildataset.cpp | 4 +--- frmts/tsx/tsxdataset.cpp | 4 +--- frmts/usgsdem/usgsdemdataset.cpp | 4 +--- frmts/wcs/wcsdataset.cpp | 4 +--- frmts/webp/webpdataset.cpp | 4 +--- frmts/wms/wmsdriver.cpp | 4 +--- frmts/xpm/xpmdataset.cpp | 4 +--- frmts/xyz/xyzdataset.cpp | 4 +--- frmts/zmap/zmapdataset.cpp | 4 +--- gcore/gdal_priv.h | 2 ++ gcore/gdaldataset.cpp | 17 +++++++++++++++++ ogr/ogrsf_frmts/cad/ogrcaddriver.cpp | 4 +--- ogr/ogrsf_frmts/miramon/ogrmiramondriver.cpp | 3 +-- 69 files changed, 89 insertions(+), 206 deletions(-) diff --git a/frmts/adrg/adrgdataset.cpp b/frmts/adrg/adrgdataset.cpp index dde59c560a9d..3300b15d0efc 100644 --- a/frmts/adrg/adrgdataset.cpp +++ b/frmts/adrg/adrgdataset.cpp @@ -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; } diff --git a/frmts/adrg/srpdataset.cpp b/frmts/adrg/srpdataset.cpp index d0d4ad1300ba..c51daeb2f004 100644 --- a/frmts/adrg/srpdataset.cpp +++ b/frmts/adrg/srpdataset.cpp @@ -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; } diff --git a/frmts/aigrid/aigdataset.cpp b/frmts/aigrid/aigdataset.cpp index b5f5faae53c5..a09a237af3a5 100644 --- a/frmts/aigrid/aigdataset.cpp +++ b/frmts/aigrid/aigdataset.cpp @@ -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; } /* -------------------------------------------------------------------- */ diff --git a/frmts/airsar/airsardataset.cpp b/frmts/airsar/airsardataset.cpp index 8043cf428638..b0e5451c849e 100644 --- a/frmts/airsar/airsardataset.cpp +++ b/frmts/airsar/airsardataset.cpp @@ -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; } diff --git a/frmts/blx/blxdataset.cpp b/frmts/blx/blxdataset.cpp index 9342391baa28..247cbaf2c59d 100644 --- a/frmts/blx/blxdataset.cpp +++ b/frmts/blx/blxdataset.cpp @@ -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; } diff --git a/frmts/bsb/bsbdataset.cpp b/frmts/bsb/bsbdataset.cpp index a0afd3291be6..bb7f8b1cb7ba 100644 --- a/frmts/bsb/bsbdataset.cpp +++ b/frmts/bsb/bsbdataset.cpp @@ -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; } diff --git a/frmts/ceos/ceosdataset.cpp b/frmts/ceos/ceosdataset.cpp index 4720dd90b2c7..4b0d1507a44c 100644 --- a/frmts/ceos/ceosdataset.cpp +++ b/frmts/ceos/ceosdataset.cpp @@ -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; } /* -------------------------------------------------------------------- */ diff --git a/frmts/ceos2/sar_ceosdataset.cpp b/frmts/ceos2/sar_ceosdataset.cpp index dda64ac26480..304350e298fb 100644 --- a/frmts/ceos2/sar_ceosdataset.cpp +++ b/frmts/ceos2/sar_ceosdataset.cpp @@ -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; } diff --git a/frmts/coasp/coasp_dataset.cpp b/frmts/coasp/coasp_dataset.cpp index 65e916510a63..220a0cd60ab3 100644 --- a/frmts/coasp/coasp_dataset.cpp +++ b/frmts/coasp/coasp_dataset.cpp @@ -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; } diff --git a/frmts/cosar/cosar_dataset.cpp b/frmts/cosar/cosar_dataset.cpp index a136dbba39fd..f2e1e1ae726d 100644 --- a/frmts/cosar/cosar_dataset.cpp +++ b/frmts/cosar/cosar_dataset.cpp @@ -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; } diff --git a/frmts/ctg/ctgdataset.cpp b/frmts/ctg/ctgdataset.cpp index 000ec386a5bb..a3f71fbc5ab2 100644 --- a/frmts/ctg/ctgdataset.cpp +++ b/frmts/ctg/ctgdataset.cpp @@ -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; } diff --git a/frmts/dimap/dimapdataset.cpp b/frmts/dimap/dimapdataset.cpp index 30ce22e5350e..fb023e62be0e 100644 --- a/frmts/dimap/dimapdataset.cpp +++ b/frmts/dimap/dimapdataset.cpp @@ -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; } /* -------------------------------------------------------------------- */ diff --git a/frmts/envisat/envisatdataset.cpp b/frmts/envisat/envisatdataset.cpp index d0b866b18f82..d5146b4247c9 100644 --- a/frmts/envisat/envisatdataset.cpp +++ b/frmts/envisat/envisatdataset.cpp @@ -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; } /* -------------------------------------------------------------------- */ diff --git a/frmts/fit/fitdataset.cpp b/frmts/fit/fitdataset.cpp index 66281d1467d1..85d7187684e2 100644 --- a/frmts/fit/fitdataset.cpp +++ b/frmts/fit/fitdataset.cpp @@ -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; } diff --git a/frmts/gff/gff_dataset.cpp b/frmts/gff/gff_dataset.cpp index 2544a3e365e4..bea214ef5802 100644 --- a/frmts/gff/gff_dataset.cpp +++ b/frmts/gff/gff_dataset.cpp @@ -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; } diff --git a/frmts/gif/biggifdataset.cpp b/frmts/gif/biggifdataset.cpp index 20f2e936cf56..98305711e267 100644 --- a/frmts/gif/biggifdataset.cpp +++ b/frmts/gif/biggifdataset.cpp @@ -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; } diff --git a/frmts/gif/gifdataset.cpp b/frmts/gif/gifdataset.cpp index 95e66500354e..bfc954cd69f6 100644 --- a/frmts/gif/gifdataset.cpp +++ b/frmts/gif/gifdataset.cpp @@ -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; } diff --git a/frmts/grib/gribdataset.cpp b/frmts/grib/gribdataset.cpp index f99407267ae7..9092e6736c58 100644 --- a/frmts/grib/gribdataset.cpp +++ b/frmts/grib/gribdataset.cpp @@ -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; } diff --git a/frmts/gxf/gxfdataset.cpp b/frmts/gxf/gxfdataset.cpp index 67a8c18af5f2..c6f8747320d5 100644 --- a/frmts/gxf/gxfdataset.cpp +++ b/frmts/gxf/gxfdataset.cpp @@ -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; } diff --git a/frmts/hdf4/hdf4dataset.cpp b/frmts/hdf4/hdf4dataset.cpp index 623fc76081cf..cdccaaa4d7c8 100644 --- a/frmts/hdf4/hdf4dataset.cpp +++ b/frmts/hdf4/hdf4dataset.cpp @@ -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; } } diff --git a/frmts/hdf5/bagdataset.cpp b/frmts/hdf5/bagdataset.cpp index 4f60f6795010..e28a8a1032ea 100644 --- a/frmts/hdf5/bagdataset.cpp +++ b/frmts/hdf5/bagdataset.cpp @@ -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; } diff --git a/frmts/hdf5/hdf5dataset.cpp b/frmts/hdf5/hdf5dataset.cpp index 7371aebb5e06..0d83218cb6ad 100644 --- a/frmts/hdf5/hdf5dataset.cpp +++ b/frmts/hdf5/hdf5dataset.cpp @@ -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; } } diff --git a/frmts/hdf5/hdf5imagedataset.cpp b/frmts/hdf5/hdf5imagedataset.cpp index 73d7a2e92bb7..d963ac21942a 100644 --- a/frmts/hdf5/hdf5imagedataset.cpp +++ b/frmts/hdf5/hdf5imagedataset.cpp @@ -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; } diff --git a/frmts/hdf5/s102dataset.cpp b/frmts/hdf5/s102dataset.cpp index 12d10b998949..1926ea55dc0b 100644 --- a/frmts/hdf5/s102dataset.cpp +++ b/frmts/hdf5/s102dataset.cpp @@ -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; } diff --git a/frmts/hdf5/s104dataset.cpp b/frmts/hdf5/s104dataset.cpp index 14b58c76a916..ce95103d3a53 100644 --- a/frmts/hdf5/s104dataset.cpp +++ b/frmts/hdf5/s104dataset.cpp @@ -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; } diff --git a/frmts/hdf5/s111dataset.cpp b/frmts/hdf5/s111dataset.cpp index b21a5ec8720a..ca386edcc768 100644 --- a/frmts/hdf5/s111dataset.cpp +++ b/frmts/hdf5/s111dataset.cpp @@ -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; } diff --git a/frmts/iris/irisdataset.cpp b/frmts/iris/irisdataset.cpp index b30c953d6e96..43f0c2fefb68 100644 --- a/frmts/iris/irisdataset.cpp +++ b/frmts/iris/irisdataset.cpp @@ -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; } diff --git a/frmts/jaxapalsar/jaxapalsardataset.cpp b/frmts/jaxapalsar/jaxapalsardataset.cpp index ed8371857e7e..746b22c703b5 100644 --- a/frmts/jaxapalsar/jaxapalsardataset.cpp +++ b/frmts/jaxapalsar/jaxapalsardataset.cpp @@ -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; } diff --git a/frmts/jdem/jdemdataset.cpp b/frmts/jdem/jdemdataset.cpp index a630e1ae103e..070cfffc9351 100644 --- a/frmts/jdem/jdemdataset.cpp +++ b/frmts/jdem/jdemdataset.cpp @@ -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; } diff --git a/frmts/jpeg/jpgdataset.cpp b/frmts/jpeg/jpgdataset.cpp index c49235ed0962..aac2f45e5cfa 100644 --- a/frmts/jpeg/jpgdataset.cpp +++ b/frmts/jpeg/jpgdataset.cpp @@ -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; } diff --git a/frmts/l1b/l1bdataset.cpp b/frmts/l1b/l1bdataset.cpp index e956f5580e28..ab91ff5ab5dc 100644 --- a/frmts/l1b/l1bdataset.cpp +++ b/frmts/l1b/l1bdataset.cpp @@ -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; diff --git a/frmts/map/mapdataset.cpp b/frmts/map/mapdataset.cpp index 472ae7c31566..fdb14f1c7400 100644 --- a/frmts/map/mapdataset.cpp +++ b/frmts/map/mapdataset.cpp @@ -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; } diff --git a/frmts/msg/msgdataset.cpp b/frmts/msg/msgdataset.cpp index 43dde5ce0f8e..7608b1131a0c 100644 --- a/frmts/msg/msgdataset.cpp +++ b/frmts/msg/msgdataset.cpp @@ -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; } diff --git a/frmts/msgn/msgndataset.cpp b/frmts/msgn/msgndataset.cpp index 16df86fbddb2..c7db88c45709 100644 --- a/frmts/msgn/msgndataset.cpp +++ b/frmts/msgn/msgndataset.cpp @@ -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; } diff --git a/frmts/ngsgeoid/ngsgeoiddataset.cpp b/frmts/ngsgeoid/ngsgeoiddataset.cpp index 6d3d424bd742..c4f6af18c69e 100644 --- a/frmts/ngsgeoid/ngsgeoiddataset.cpp +++ b/frmts/ngsgeoid/ngsgeoiddataset.cpp @@ -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; } diff --git a/frmts/nitf/ecrgtocdataset.cpp b/frmts/nitf/ecrgtocdataset.cpp index 8e6b04a1f98d..bebdaea7d317 100644 --- a/frmts/nitf/ecrgtocdataset.cpp +++ b/frmts/nitf/ecrgtocdataset.cpp @@ -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; } diff --git a/frmts/nitf/rpftocdataset.cpp b/frmts/nitf/rpftocdataset.cpp index e762bde31187..0026dd44d5e5 100644 --- a/frmts/nitf/rpftocdataset.cpp +++ b/frmts/nitf/rpftocdataset.cpp @@ -1286,8 +1286,7 @@ GDALDataset *RPFTOCDataset::Open(GDALOpenInfo *poOpenInfo) if (poDS && poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "RPFTOC driver does not support update mode"); + ReportUpdateNotSupportedByDriver("RPFTOC"); delete poDS; return nullptr; } @@ -1317,8 +1316,7 @@ GDALDataset *RPFTOCDataset::Open(GDALOpenInfo *poOpenInfo) if (poDS && poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "RPFTOC driver does not support update mode"); + ReportUpdateNotSupportedByDriver("RPFTOC"); delete poDS; return nullptr; } diff --git a/frmts/png/pngdataset.cpp b/frmts/png/pngdataset.cpp index cfe5981879c6..aa5ba4dfc1f9 100644 --- a/frmts/png/pngdataset.cpp +++ b/frmts/png/pngdataset.cpp @@ -1788,9 +1788,7 @@ GDALDataset *PNGDataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The PNG driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("PNG"); return nullptr; } diff --git a/frmts/r/rdataset.cpp b/frmts/r/rdataset.cpp index 6879b7cdcf27..e8c09aa1e3a5 100644 --- a/frmts/r/rdataset.cpp +++ b/frmts/r/rdataset.cpp @@ -342,9 +342,7 @@ GDALDataset *RDataset::Open(GDALOpenInfo *poOpenInfo) // Confirm the requested access is supported. if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The R driver does not support update access to existing" - " datasets."); + ReportUpdateNotSupportedByDriver("R"); return nullptr; } diff --git a/frmts/raw/cpgdataset.cpp b/frmts/raw/cpgdataset.cpp index 9e65d4334f3f..fec41e5c23f4 100644 --- a/frmts/raw/cpgdataset.cpp +++ b/frmts/raw/cpgdataset.cpp @@ -1141,9 +1141,7 @@ GDALDataset *CPGDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The CPG driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("CPG"); return nullptr; } diff --git a/frmts/raw/doq1dataset.cpp b/frmts/raw/doq1dataset.cpp index 44c9571d397a..ada5023f8814 100644 --- a/frmts/raw/doq1dataset.cpp +++ b/frmts/raw/doq1dataset.cpp @@ -244,9 +244,7 @@ GDALDataset *DOQ1Dataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The DOQ1 driver does not support update access to existing " - "datasets."); + ReportUpdateNotSupportedByDriver("DOQ1"); return nullptr; } diff --git a/frmts/raw/doq2dataset.cpp b/frmts/raw/doq2dataset.cpp index 007521e6a403..87fb6f927390 100644 --- a/frmts/raw/doq2dataset.cpp +++ b/frmts/raw/doq2dataset.cpp @@ -161,9 +161,7 @@ GDALDataset *DOQ2Dataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The DOQ2 driver does not support update access to existing " - "datasets."); + ReportUpdateNotSupportedByDriver("DOQ2"); return nullptr; } @@ -356,9 +354,7 @@ GDALDataset *DOQ2Dataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { CSLDestroy(papszMetadata); - CPLError(CE_Failure, CPLE_NotSupported, - "The DOQ2 driver does not support update access to existing" - " datasets."); + ReportUpdateNotSupportedByDriver("DOQ2"); return nullptr; } /* -------------------------------------------------------------------- */ diff --git a/frmts/raw/eirdataset.cpp b/frmts/raw/eirdataset.cpp index 4494e2da41cf..1aec254da4cf 100644 --- a/frmts/raw/eirdataset.cpp +++ b/frmts/raw/eirdataset.cpp @@ -418,9 +418,7 @@ GDALDataset *EIRDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The EIR driver does not support update access to existing" - " datasets."); + ReportUpdateNotSupportedByDriver("EIR"); return nullptr; } /* -------------------------------------------------------------------- */ diff --git a/frmts/raw/fastdataset.cpp b/frmts/raw/fastdataset.cpp index 2695a2e3c486..f242927371a8 100644 --- a/frmts/raw/fastdataset.cpp +++ b/frmts/raw/fastdataset.cpp @@ -1121,9 +1121,7 @@ GDALDataset *FASTDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The FAST driver does not support update access to existing" - " datasets."); + ReportUpdateNotSupportedByDriver("FAST"); return nullptr; } diff --git a/frmts/raw/gscdataset.cpp b/frmts/raw/gscdataset.cpp index 0fa1458eb566..21307f733441 100644 --- a/frmts/raw/gscdataset.cpp +++ b/frmts/raw/gscdataset.cpp @@ -143,9 +143,7 @@ GDALDataset *GSCDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The GSC driver does not support update access to existing " - "datasets."); + ReportUpdateNotSupportedByDriver("GSC"); return nullptr; } diff --git a/frmts/raw/lcpdataset.cpp b/frmts/raw/lcpdataset.cpp index bf2e282f9186..95ecc1bf7c0e 100644 --- a/frmts/raw/lcpdataset.cpp +++ b/frmts/raw/lcpdataset.cpp @@ -226,9 +226,7 @@ GDALDataset *LCPDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The LCP driver does not support update access to existing" - " datasets."); + ReportUpdateNotSupportedByDriver("LCP"); return nullptr; } /* -------------------------------------------------------------------- */ diff --git a/frmts/raw/loslasdataset.cpp b/frmts/raw/loslasdataset.cpp index eeae1d80abc8..073a59ed8895 100644 --- a/frmts/raw/loslasdataset.cpp +++ b/frmts/raw/loslasdataset.cpp @@ -180,9 +180,7 @@ GDALDataset *LOSLASDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The LOSLAS driver does not support update access to existing" - " datasets."); + ReportUpdateNotSupportedByDriver("LOSLAS"); return nullptr; } diff --git a/frmts/raw/ndfdataset.cpp b/frmts/raw/ndfdataset.cpp index b339ae89a8bb..d15818eab2c8 100644 --- a/frmts/raw/ndfdataset.cpp +++ b/frmts/raw/ndfdataset.cpp @@ -180,9 +180,7 @@ GDALDataset *NDFDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The NDF driver does not support update access to existing" - " datasets."); + ReportUpdateNotSupportedByDriver("NDF"); return nullptr; } /* -------------------------------------------------------------------- */ @@ -241,9 +239,7 @@ GDALDataset *NDFDataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { CSLDestroy(papszHeader); - CPLError(CE_Failure, CPLE_NotSupported, - "The NDF driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("NDF"); return nullptr; } diff --git a/frmts/raw/nsidcbindataset.cpp b/frmts/raw/nsidcbindataset.cpp index 164a66625cc3..ff7b1d7c57ab 100644 --- a/frmts/raw/nsidcbindataset.cpp +++ b/frmts/raw/nsidcbindataset.cpp @@ -229,10 +229,7 @@ GDALDataset *NSIDCbinDataset::Open(GDALOpenInfo *poOpenInfo) // Confirm the requested access is supported. if (poOpenInfo->eAccess == GA_Update) { - CPLError( - CE_Failure, CPLE_NotSupported, - "The NSIDCbin driver does not support update access to existing " - "datasets."); + ReportUpdateNotSupportedByDriver("NSIDCbin"); return nullptr; } diff --git a/frmts/raw/snodasdataset.cpp b/frmts/raw/snodasdataset.cpp index 27e82bd0fc41..dc2c24489df9 100644 --- a/frmts/raw/snodasdataset.cpp +++ b/frmts/raw/snodasdataset.cpp @@ -250,9 +250,7 @@ GDALDataset *SNODASDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The SNODAS driver does not support update access to existing" - " datasets."); + ReportUpdateNotSupportedByDriver("SNODAS"); return nullptr; } diff --git a/frmts/rcm/rcmdataset.cpp b/frmts/rcm/rcmdataset.cpp index 0d0abc14b411..80be053ea880 100644 --- a/frmts/rcm/rcmdataset.cpp +++ b/frmts/rcm/rcmdataset.cpp @@ -1132,9 +1132,7 @@ GDALDataset *RCMDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "ERROR: The RCM driver does not support update " - "access to existing dataset."); + ReportUpdateNotSupportedByDriver("RCM"); return nullptr; } diff --git a/frmts/rdb/rdbdataset.cpp b/frmts/rdb/rdbdataset.cpp index d4c087404538..ce31ad8f5ace 100644 --- a/frmts/rdb/rdbdataset.cpp +++ b/frmts/rdb/rdbdataset.cpp @@ -586,9 +586,7 @@ GDALDataset *RDBDataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The RDB driver does not support update access to existing " - "datasets."); + ReportUpdateNotSupportedByDriver("RDB"); return nullptr; } diff --git a/frmts/rik/rikdataset.cpp b/frmts/rik/rikdataset.cpp index fc65bd822ac7..247218972b28 100644 --- a/frmts/rik/rikdataset.cpp +++ b/frmts/rik/rikdataset.cpp @@ -1265,9 +1265,7 @@ GDALDataset *RIKDataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { delete poDS; - CPLError(CE_Failure, CPLE_NotSupported, - "The RIK driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("RIK"); return nullptr; } diff --git a/frmts/rs2/rs2dataset.cpp b/frmts/rs2/rs2dataset.cpp index 3f3aaff395fd..ac2ef08c3105 100644 --- a/frmts/rs2/rs2dataset.cpp +++ b/frmts/rs2/rs2dataset.cpp @@ -729,9 +729,7 @@ GDALDataset *RS2Dataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { CPLDestroyXMLNode(psProduct); - CPLError(CE_Failure, CPLE_NotSupported, - "The RS2 driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("RS2"); return nullptr; } diff --git a/frmts/safe/safedataset.cpp b/frmts/safe/safedataset.cpp index ab46337b324d..a0c9ad98b1b0 100644 --- a/frmts/safe/safedataset.cpp +++ b/frmts/safe/safedataset.cpp @@ -1004,9 +1004,7 @@ GDALDataset *SAFEDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The SAFE driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("SAFE"); return nullptr; } diff --git a/frmts/sdts/sdtsdataset.cpp b/frmts/sdts/sdtsdataset.cpp index 29714be1a1f8..932904eb79aa 100644 --- a/frmts/sdts/sdtsdataset.cpp +++ b/frmts/sdts/sdtsdataset.cpp @@ -134,9 +134,7 @@ GDALDataset *SDTSDataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { delete poTransfer; - CPLError(CE_Failure, CPLE_NotSupported, - "The SDTS driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("SDTS"); return nullptr; } diff --git a/frmts/til/tildataset.cpp b/frmts/til/tildataset.cpp index 8825d121d2b6..de13dfc58865 100644 --- a/frmts/til/tildataset.cpp +++ b/frmts/til/tildataset.cpp @@ -198,9 +198,7 @@ GDALDataset *TILDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The TIL driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("TIL"); return nullptr; } diff --git a/frmts/tsx/tsxdataset.cpp b/frmts/tsx/tsxdataset.cpp index d40b17b38737..4cecd79b39c7 100644 --- a/frmts/tsx/tsxdataset.cpp +++ b/frmts/tsx/tsxdataset.cpp @@ -455,9 +455,7 @@ GDALDataset *TSXDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The TSX driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("TSX"); return nullptr; } diff --git a/frmts/usgsdem/usgsdemdataset.cpp b/frmts/usgsdem/usgsdemdataset.cpp index ebc88a45f180..835854d0b56c 100644 --- a/frmts/usgsdem/usgsdemdataset.cpp +++ b/frmts/usgsdem/usgsdemdataset.cpp @@ -920,9 +920,7 @@ GDALDataset *USGSDEMDataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { delete poDS; - CPLError(CE_Failure, CPLE_NotSupported, - "The USGSDEM driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("USGSDEM"); return nullptr; } diff --git a/frmts/wcs/wcsdataset.cpp b/frmts/wcs/wcsdataset.cpp index 86be887f42b0..215f79c4043f 100644 --- a/frmts/wcs/wcsdataset.cpp +++ b/frmts/wcs/wcsdataset.cpp @@ -1365,9 +1365,7 @@ GDALDataset *WCSDataset::Open(GDALOpenInfo *poOpenInfo) { CSLDestroy(papszModifiers); CPLDestroyXMLNode(service); - CPLError(CE_Failure, CPLE_NotSupported, - "The WCS driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("WCS"); return nullptr; } diff --git a/frmts/webp/webpdataset.cpp b/frmts/webp/webpdataset.cpp index 56516a8e812a..87464eb5ed78 100644 --- a/frmts/webp/webpdataset.cpp +++ b/frmts/webp/webpdataset.cpp @@ -547,9 +547,7 @@ GDALPamDataset *WEBPDataset::OpenPAM(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The WEBP driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("WEBP"); return nullptr; } diff --git a/frmts/wms/wmsdriver.cpp b/frmts/wms/wmsdriver.cpp index 2ac5e72f9fb3..71903120706f 100644 --- a/frmts/wms/wmsdriver.cpp +++ b/frmts/wms/wmsdriver.cpp @@ -902,9 +902,7 @@ GDALDataset *GDALWMSDataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { CPLDestroyXMLNode(config); - CPLError(CE_Failure, CPLE_NotSupported, - "The WMS poDriver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("WMS"); return nullptr; } diff --git a/frmts/xpm/xpmdataset.cpp b/frmts/xpm/xpmdataset.cpp index 2623ce75eed1..c910532851f6 100644 --- a/frmts/xpm/xpmdataset.cpp +++ b/frmts/xpm/xpmdataset.cpp @@ -84,9 +84,7 @@ GDALDataset *XPMDataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The XPM driver does not support update access to existing" - " files."); + ReportUpdateNotSupportedByDriver("XPM"); return nullptr; } diff --git a/frmts/xyz/xyzdataset.cpp b/frmts/xyz/xyzdataset.cpp index aaa64b03c7e3..c1e8ce96949c 100644 --- a/frmts/xyz/xyzdataset.cpp +++ b/frmts/xyz/xyzdataset.cpp @@ -1501,9 +1501,7 @@ GDALDataset *XYZDataset::Open(GDALOpenInfo *poOpenInfo) if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The XYZ driver does not support update access to existing" - " datasets.\n"); + ReportUpdateNotSupportedByDriver("XYZ"); VSIFCloseL(fp); return nullptr; } diff --git a/frmts/zmap/zmapdataset.cpp b/frmts/zmap/zmapdataset.cpp index 08523a19e121..816c58c05d10 100644 --- a/frmts/zmap/zmapdataset.cpp +++ b/frmts/zmap/zmapdataset.cpp @@ -291,9 +291,7 @@ GDALDataset *ZMapDataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The ZMAP driver does not support update access to existing" - " datasets."); + ReportUpdateNotSupportedByDriver("ZMAP"); return nullptr; } diff --git a/gcore/gdal_priv.h b/gcore/gdal_priv.h index 4cf88355eacf..5d6c653ac131 100644 --- a/gcore/gdal_priv.h +++ b/gcore/gdal_priv.h @@ -946,6 +946,8 @@ class CPL_DLL GDALDataset : public GDALMajorObject // Only to be used by driver's GetOverviewCount() method. bool AreOverviewsEnabled() const; + + static void ReportUpdateNotSupportedByDriver(const char *pszDriverName); //! @endcond private: diff --git a/gcore/gdaldataset.cpp b/gcore/gdaldataset.cpp index 64e5ed828599..0288878dd067 100644 --- a/gcore/gdaldataset.cpp +++ b/gcore/gdaldataset.cpp @@ -10423,3 +10423,20 @@ CPLErr GDALDatasetGeolocationToPixelLine(GDALDatasetH hDS, double dfGeolocX, dfGeolocX, dfGeolocY, OGRSpatialReference::FromHandle(hSRS), pdfPixel, pdfLine, papszTransformerOptions); } + +/************************************************************************/ +/* ReportUpdateNotSupportedByDriver() */ +/************************************************************************/ + +//! @cond Doxygen_Suppress + +/* static */ +void GDALDataset::ReportUpdateNotSupportedByDriver(const char *pszDriverName) +{ + CPLError(CE_Failure, CPLE_NotSupported, + "The %s driver does not support update access to existing " + "datasets.", + pszDriverName); +} + +//! @endcond diff --git a/ogr/ogrsf_frmts/cad/ogrcaddriver.cpp b/ogr/ogrsf_frmts/cad/ogrcaddriver.cpp index dda528734b9c..3446ed3615c5 100644 --- a/ogr/ogrsf_frmts/cad/ogrcaddriver.cpp +++ b/ogr/ogrsf_frmts/cad/ogrcaddriver.cpp @@ -67,9 +67,7 @@ static GDALDataset *OGRCADDriverOpen(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_NotSupported, - "The CAD driver does not support update access to existing" - " datasets.\n"); + GDALDataset::ReportUpdateNotSupportedByDriver("CAD"); delete pFileIO; return nullptr; } diff --git a/ogr/ogrsf_frmts/miramon/ogrmiramondriver.cpp b/ogr/ogrsf_frmts/miramon/ogrmiramondriver.cpp index ec3d05585f82..9ed9c38eff48 100644 --- a/ogr/ogrsf_frmts/miramon/ogrmiramondriver.cpp +++ b/ogr/ogrsf_frmts/miramon/ogrmiramondriver.cpp @@ -84,8 +84,7 @@ static GDALDataset *OGRMiraMonDriverOpen(GDALOpenInfo *poOpenInfo) if (poDS && poOpenInfo->eAccess == GA_Update) { - CPLError(CE_Failure, CPLE_OpenFailed, - "MiraMonVector driver does not support update."); + GDALDataset::ReportUpdateNotSupportedByDriver("MiraMonVector"); return nullptr; }