[Gdal-dev] OGR Close Datasource?

Charlie Savage cfis at interserv.com
Wed Sep 21 04:28:06 EDT 2005


Wondering if it would make sense to introduce the concept of "closing" a
datasource to the OGR API as a distinct thing from "destroying" a data
source object?

I bring this up because I run into a problem with a test script in Ruby:

1.  Create temporary csv data source
2.  Do some stuff to it
3.  At the end of the test, delete the temporary data source

Pseudo code:

driver = Ogr.get_driver_by_name('CSV')
ds_name = "tempds"
ds = driver.open(ds_name)
...
ds = nil
GC.start     <- Try to gc the ds object here
driver.delete_data_source(ds_name)  <- Delete the data source

Before deleting the temporary data source, the ds object must be
destroyed (because it has the temporary data source open).  This means
that the test is reliant on the garbage collector deleting the ds
object.  Depending on the dynamic language, this may or may not work.

Thus it would be handy to have a "close" method on a datasource.  The
one gottcha I see is that once you've closed a datasource you can't use
it anymore.  Also, you would need to make sure the destructor of the
object doesn't try to close the datasource a second time.

Charlie




More information about the Gdal-dev mailing list