[GRASS-SVN] r30908 - grass/trunk/general/g.mapsets

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 8 22:00:27 EDT 2008


Author: glynn
Date: 2008-04-08 22:00:27 -0400 (Tue, 08 Apr 2008)
New Revision: 30908

Modified:
   grass/trunk/general/g.mapsets/main_cmd.c
Log:
Add removemapset= option



Modified: grass/trunk/general/g.mapsets/main_cmd.c
===================================================================
--- grass/trunk/general/g.mapsets/main_cmd.c	2008-04-09 00:52:14 UTC (rev 30907)
+++ grass/trunk/general/g.mapsets/main_cmd.c	2008-04-09 02:00:27 UTC (rev 30908)
@@ -38,8 +38,8 @@
     char **tokens;
     int no_tokens;
     FILE *fp;
-	struct GModule *module;
-    struct Option *opt1, *opt2;
+    struct GModule *module;
+    struct Option *opt1, *opt2, *opt3;
     struct Flag *print;
     struct Flag *list;
 
@@ -66,6 +66,13 @@
     opt2->multiple   = YES ;
     opt2->description= _("Name(s) of existing mapset(s) to add to search list");
 
+    opt3 = G_define_option() ;
+    opt3->key        = "removemapset" ;
+    opt3->type       = TYPE_STRING ;
+    opt3->required   = NO ;
+    opt3->multiple   = YES ;
+    opt3->description= _("Name(s) of existing mapset(s) to remove from search list");
+
     list = G_define_flag();
     list->key = 'l';
     list->description = _("List all available mapsets");
@@ -128,7 +135,29 @@
 	}
     }
 
+    /* remove from existing search path */
+    if (opt3->answer)
+    {
+	char *oldname;
+	Path[0] = '\0';
+	
+	/* read existing mapsets from SEARCH_PATH */
+        for (n = 0; (oldname = G__mapset_name(n)) ; n++)
+	{
+	    int found = 0;
 
+	    for (ptr = opt3->answers; *ptr; ptr++)
+		if (strcmp(oldname, *ptr) == 0)
+		    found = 1;
+
+	    if (found)
+		continue;
+
+	    strcat (Path, oldname);
+	    strcat (Path, " "); 
+	}
+    }
+
     /* stuffem sets nchoices*/
 
     if (nchoices == 0)



More information about the grass-commit mailing list