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

Julien Demaria dem at acri-st.fr
Tue Oct 5 04:09:27 EDT 2004


At 22:27 04/10/2004, Frank Warmerdam wrote:
>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,

Hi,

In gdal_translate.cpp I see the following code :

     printf( "The following format drivers are configured and support 
output:\n" );
     for( iDr = 0; iDr < GDALGetDriverCount(); iDr++ )
     {
         GDALDriverH hDriver = GDALGetDriver(iDr);

         if( GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATE, NULL ) != NULL
             || GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATECOPY,
                                     NULL ) != NULL )
         {
             printf( "  %s: %s\n",
                     GDALGetDriverShortName( hDriver ),
                     GDALGetDriverLongName( hDriver ) );
         }
     }


I understand that each driver as special meta-datas GDAL_DCAP_CREATE and 
GDAL_DCAP_CREATECOPY if it support them ? and if a driver as a Create 
method, it must support the GA_Update mode, isn't it ?

Regards,

Julien




More information about the Gdal-dev mailing list