浏览代码

ogr dbdriver: try to open data source read-only when read-write access fails

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54296 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 12 年之前
父节点
当前提交
556e01adfa
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      db/drivers/ogr/db.c

+ 7 - 0
db/drivers/ogr/db.c

@@ -47,7 +47,14 @@ int db__driver_open_database(dbHandle * handle)
 
     OGRRegisterAll();
 
+    /* try read-write access */
     hDs = OGROpen(name, TRUE, NULL);
+    if (hDs == NULL) {
+        /* try read-only access */
+        hDs = OGROpen(name, FALSE, NULL);
+        if (hDs)
+            G_important_message(_("Had to open data source read-only"));
+    }
 
     if (hDs == NULL) {
 	db_d_append_error(_("Unable to open OGR data source"));