Nik, what you try to do is perfectly valid and should work. I've just tried it myself, but I can't reproduce any error. If you are working on Linux, could you run your program with valgrind and look if it reports some errors ? The only explanation I can imagine for now is that the file system on which your shapefile is located doesn't support a file to be opened more than once at a time, but this would be extremely surprising !
Best regards, Even > 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. > > _______________________________________________ > gdal-dev mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev -- Geospatial professional services http://even.rouault.free.fr/services.html _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
