Просмотр исходного кода

v.to.db: check if the map is in the current mapset (when modifying data)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@63698 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 лет назад
Родитель
Сommit
234bdd7691
1 измененных файлов с 13 добавлено и 3 удалено
  1. 13 3
      vector/v.to.db/main.c

+ 13 - 3
vector/v.to.db/main.c

@@ -40,14 +40,24 @@ int main(int argc, char *argv[])
 
     parse_command_line(argc, argv);
 
+    if (!options.print && !options.total) {
+        const char *mapset;
+
+        mapset = G_find_vector2(options.name, "");
+        if (!mapset || (strcmp(mapset, G_mapset()) != 0))
+            G_fatal_error(_("Vector map <%s> not found in the current mapset. "
+                            "Unable to modify vector maps from different mapsets."),
+                          options.name);
+    }
+
     G_begin_distance_calculations();
     G_begin_polygon_area_calculations();
 
     /* open map */
     Vect_set_open_level(2);
-    if (Vect_open_old(&Map, options.name, "") < 0)
-	G_fatal_error(_("Unable to open vector map <%s>"), options.name);
-
+    Vect_open_old(&Map, options.name, "");
+    Vect_set_error_handler_io(&Map, NULL);
+   
     Fi = Vect_get_field(&Map, options.field);
 
     if (!options.print && Fi == NULL) {