13 #include <sys/types.h>
20 #include "gis_local_proto.h"
32 static void new_mapset(
const char *);
48 if (n < 0 || n >=
st->path.count)
51 return st->path.names[n];
62 if (
st->path.count > 0)
76 while (fscanf(fp,
"%s",
name) == 1) {
77 if (strcmp(
name, cur) == 0)
85 static const char perm[] =
"PERMANENT";
92 void new_mapset(
const char *
name)
94 if (
st->path.count >=
st->path.size) {
108 st->path2.count =
st->path.count;
109 st->path2.names =
st->path.names;
123 names =
st->path2.names;
125 st->path2.count =
st->path.count;
126 st->path2.names =
st->path.names;
129 st->path.names = names;
150 char **mapsets =
NULL;
156 G_debug(3,
"G_get_available_mapsets");
158 mapsets =
G_calloc(alloc,
sizeof(
char *));
161 dir = opendir(location);
167 while ((ent = readdir(dir))) {
171 sprintf(buf,
"%s/%s/WIND", location, ent->d_name);
174 G_debug(4,
"%s is not mapset", ent->d_name);
178 G_debug(4,
"%s is mapset", ent->d_name);
180 if (n + 2 >= alloc) {
182 mapsets =
G_realloc(mapsets, alloc *
sizeof(
char *));
185 mapsets[n++] =
G_store(ent->d_name);
221 for (i = 0; i <
st->path.count; i++) {
222 if (strcmp(
st->path.names[i], mapset) == 0)
int G_mapset_permissions(const char *)
Check for user mapset permission.
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database file for reading.
void G_free(void *)
Free allocated memory.
const char * G_mapset(void)
Get current mapset name.
char * G_location_path(void)
Get current location UNIX-like path.
int G_stat(const char *, struct stat *)
Get file status.
int G_debug(int, const char *,...) __attribute__((format(printf
char * G_store(const char *)
Copy string to allocated memory.
void G_add_mapset_to_search_path(const char *mapset)
Add mapset to the list of mapsets in search path.
void G_reset_mapsets(void)
Reset number of mapsets.
const char * G_get_mapset_name(int n)
Get name of the n'th mapset from the current mapset search path.
void G__get_list_of_mapsets(void)
Fill list of mapsets from search path (internal use only)
char ** G_get_available_mapsets(void)
Get list of available mapsets for current location.
void G_create_alt_search_path(void)
Define alternative mapset search path.
void G_switch_search_path(void)
Switch mapset search path.
int G_is_mapset_in_search_path(const char *mapset)
Check if given mapset is in search path.