[GRASS-SVN] r30713 - grass/trunk/general/g.mapset
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Mar 24 13:23:43 EDT 2008
Author: glynn
Date: 2008-03-24 13:23:43 -0400 (Mon, 24 Mar 2008)
New Revision: 30713
Modified:
grass/trunk/general/g.mapset/main.c
Log:
g.mapset -l patch from Martin Landa
Modified: grass/trunk/general/g.mapset/main.c
===================================================================
--- grass/trunk/general/g.mapset/main.c 2008-03-24 11:19:11 UTC (rev 30712)
+++ grass/trunk/general/g.mapset/main.c 2008-03-24 17:23:43 UTC (rev 30713)
@@ -32,7 +32,7 @@
int ret;
struct GModule *module;
struct Option *gisdbase_opt, *location_opt, *mapset_opt;
- struct Flag *f_add;
+ struct Flag *f_add, *f_list;
char *gisdbase_old, *location_old, *mapset_old;
char *gisdbase_new, *location_new, *mapset_new;
char *gis_lock;
@@ -51,7 +51,7 @@
mapset_opt = G_define_option() ;
mapset_opt->key = "mapset" ;
mapset_opt->type = TYPE_STRING ;
- mapset_opt->required = YES ;
+ mapset_opt->required = NO ;
mapset_opt->multiple = NO ;
mapset_opt->description = _("New MAPSET name") ;
@@ -74,9 +74,16 @@
f_add->description = _("Create mapset if it doesn't exist");
f_add->answer = FALSE;
+ f_list = G_define_flag() ;
+ f_list->key = 'l' ;
+ f_list->description = _("List available mapsets");
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (!mapset_opt->answer && !f_list->answer)
+ G_fatal_error (_("Either mapset= or -l must be used"));
+
/* Store original values */
gisdbase_old = G__getenv ("GISDBASE");
location_old = G__getenv ("LOCATION_NAME");
@@ -96,6 +103,21 @@
else
location_new = location_old;
+ if (f_list->answer) {
+ char **ms;
+ int nmapsets;
+ ms = G_available_mapsets();
+
+ for (nmapsets = 0; ms[nmapsets]; nmapsets++) {
+ if (G__mapset_permissions2 (gisdbase_new, location_new, ms[nmapsets]) > 0) {
+ fprintf(stdout, "%s ", ms[nmapsets]);
+ }
+ }
+ fprintf(stdout, "\n");
+
+ exit(EXIT_SUCCESS);
+ }
+
mapset_new = mapset_opt->answer;
G_asprintf ( &mapset_new_path, "%s/%s/%s", gisdbase_new, location_new,
mapset_new );
More information about the grass-commit
mailing list