[gdal-dev] Can't use two datasets read-only from same files?

Nik Sands nixanz at nixanz.com
Sat Feb 22 19:39:44 PST 2014


Hi GDAL devs,

I have a need to open the same set of Shapefiles as two independent datasets, BOTH of which are READ ONLY.  However, when I do this, and attempt to get the number of layers in the second data set, I get a whole lot of errors of the form:

	ERROR 4: Failed to open file <shapefile>.shp.
	It may be corrupt or read-only file accessed in update mode.

...for most (but not all) of the layers, and of course the dataset is incomplete and not useful.

I've crafted the following very simple example of this problem:

		 OGRDataSourceH firstDS = OGROpen(path, FALSE, NULL);
		 OGRDataSourceH secondDS = OGROpen(path, FALSE, NULL);
		 OGR_DS_GetLayerCount(firstDS);   //  THIS LINE WORKS FINE
		 OGR_DS_GetLayerCount(secondDS);  //  THIS LINE PRODUCES MANY ERRORS

If I OGR_DS_Destroy the first data set before running the OGR_DS_GetLayerCount on the second data set it works fine.

Is this expected?

I really need to have both datasets readable and useable simultaneously as they are both in completely independent parts of the application.  The first data set should be long-lived and needs to be persistent before, during and after the entire short life-cycle of the second data set.

The error messages imply that it is either corrupt or accessed in update mode.  But clearly it is not corrupt (at the file level) because it works fine in the first data set (and in the second if the first data set is destroyed first).  It is also being explicitly opened in READ-ONLY mode in both cases and therefore should not be in update mode.

I'm using gdal-1.10.1.

Any advice would be very much appreciated.

Cheers,
Nik.



More information about the gdal-dev mailing list