[Gdal-dev] how to know if GDALOpen(filename,GA_Update) is valid ?

Frank Warmerdam warmerdam at pobox.com
Mon Oct 4 16:27:31 EDT 2004


Stephane Routelous wrote:
> Hi,
> 
> according to the documentation of GDALOpen, "Many drivers support only read
> only access".
> How do I know if a driver only has read access ?
> 
> Because, if I really need to open a raster in read/write mode, if the driver
> does not support write, I need to use a in-memory raster if the driver
> supports createcopy.
> 
> ex : (pseudo-code)
> 
> GDALDataset* ds = GDALOpen(filename,GA_Update); //let's say the driver for
> "filename" has only read access
> GDALRasterBand* band = ds->GetRasterBand(1);
> band->RasterIO( GF_Write,whatever the other parameters are);//here, problem.

Stephane,

Currently there is no way to know if a driver supports read-only or read-write
for existing files other than to open the file in update mode, and if that
succeeds to try and write some data.  I am afraid that many drivers that
don't really support update mode will still allow an update mode open to
succeed, though that is clearly a bug.

Sorry,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list