[Gdal-dev] Re: OGR Close Datasource?

Charlie Savage cfis at interserv.com
Wed Sep 21 12:23:49 EDT 2005


> 
> What is the problem you run into? When I run this test code with Perl 
> bindings, the delete data source -method deletes the datasource (the 
> directory on hard disk) in both cases, whether datasource object still 
> exists or is deleted.

What OS are you running?  On Windows XP it doesn't work because the csv 
file is still in use by the open data source, thus you can't delete it.

Charlie


>>
>> 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
>>
>> _______________________________________________
>> Gdal-dev mailing list
>> Gdal-dev at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/gdal-dev
> 
> 
> 





More information about the Gdal-dev mailing list