Hi,
2008/3/24, Glynn Clements <[EMAIL PROTECTED]>:
> I've committed the patch, but changed mapset_opt->required to NO.
thanks, small issue here -- the '-l' flag ignores gisdbase= and
location= parameters, it always prints list of mapsets for the
*current* location. The attached patch should fix it. If you have no
objections I will applied in trunk.
Martin
--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *
Index: lib/gis/mapset_nme.c
===================================================================
--- lib/gis/mapset_nme.c (revision 30718)
+++ lib/gis/mapset_nme.c (working copy)
@@ -22,6 +22,7 @@
static int nmapset2 = 0;
static int new_mapset(const char *);
static int get_list_of_mapsets(void);
+static char** get_available_mapsets(const char*);
/*!
\brief Get name of the n'th mapset from the mapset_name[] list.
@@ -150,14 +151,7 @@
return 0;
}
-/*!
- \brief Get list of available mapsets for current location
-
- List is updated by each call to this function
-
- \return pointer to zero terminated array of available mapsets.
-*/
-char **G_available_mapsets ( void )
+static char** get_available_mapsets(const char* location_path)
{
int i, n;
static int alloc = 0;
@@ -181,11 +175,11 @@
}
n = 0;
- dir = opendir( G_location_path() );
+ dir = opendir( location_path );
if (dir == NULL) return mapsets;
while ( ( ent = readdir (dir) ) ) {
- sprintf ( buf, "%s/%s/WIND", G_location_path(), ent->d_name );
+ sprintf ( buf, "%s/%s/WIND", location_path, ent->d_name );
if ( stat ( buf, &st ) == 0 ) {
G_debug (4, "%s is mapset", ent->d_name);
/* Realloc space if necessary */
@@ -208,6 +202,36 @@
}
/*!
+ \brief Get list of available mapsets for current location
+
+ List is updated by each call to this function
+
+ \return pointer to zero terminated array of available mapsets.
+*/
+char **G_available_mapsets ( void )
+{
+ return get_available_mapsets (G_location_path());
+}
+
+/*!
+ \brief Get list of available mapsets for given location
+
+ List is updated by each call to this function
+
+ \param gisdbase full path to GISDBASE
+ \param location location name
+
+ \return pointer to zero terminated array of available mapsets.
+*/
+char **G_available_mapsets2 (const char* gisdbase, const char *location )
+{
+ char path[GPATH_MAX];
+
+ sprintf (path, "%s/%s", gisdbase, location);
+ return get_available_mapsets (path);
+}
+
+/*!
\brief Add mapset to the list of mapsets in search path.
Mapset is add in memory only, not to the SEARCH_PATH file!
Index: include/gisdefs.h
===================================================================
--- include/gisdefs.h (revision 30714)
+++ include/gisdefs.h (working copy)
@@ -771,6 +771,7 @@
int G__switch_search_path(void);
int G_reset_mapsets(void);
char **G_available_mapsets ( void );
+char **G_available_mapsets2 (const char*, const char *);
void G_add_mapset_to_search_path ( const char *mapset );
/* mask_info.c */
Index: general/g.mapset/main.c
===================================================================
--- general/g.mapset/main.c (revision 30714)
+++ general/g.mapset/main.c (working copy)
@@ -106,7 +106,7 @@
if (f_list->answer) {
char **ms;
int nmapsets;
- ms = G_available_mapsets();
+ ms = G_available_mapsets2(gisdbase_new, location_new);
for (nmapsets = 0; ms[nmapsets]; nmapsets++) {
if (G__mapset_permissions2 (gisdbase_new, location_new, ms[nmapsets]) > 0) {
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev