12 #include <grass/config.h> 17 #include <sys/types.h> 19 #include <grass/gis.h> 20 #include <grass/glocale.h> 22 static int make_mapset_element(
const char *,
const char *);
43 return make_mapset_element(path, p_element);
61 return make_mapset_element(path, p_element);
64 int make_mapset_element(
const char *p_path,
const char *p_element)
66 char path[GPATH_MAX], *p;
73 strncpy(path, p_path, GPATH_MAX);
86 if (*element ==
'/' || *element == 0) {
88 if (access(path, 0) != 0) {
91 p_element, path, strerror(errno));
93 if (access(path, 0) != 0)
94 G_fatal_error(_(
"Unable to access mapset element %s (%s): %s"),
95 p_element, path, strerror(errno));
114 char buf[GNAME_MAX * 2 + 1];
116 sprintf(buf,
"%s/%s", dir, name);
120 static int check_owner(
const struct stat *info)
122 #if defined(__MINGW32__) || defined(SKIP_MAPSET_OWN_CHK) 125 const char *check = getenv(
"GRASS_SKIP_MAPSET_OWNER_CHECK");
128 if (info->st_uid != getuid())
130 if (info->st_uid != geteuid())
147 char path[GPATH_MAX];
152 if (
G_stat(path, &info) != 0)
154 if (!S_ISDIR(info.st_mode))
157 if (!check_owner(&info))
177 char path[GPATH_MAX];
180 sprintf(path,
"%s/%s/%s", gisdbase, location, mapset);
182 if (
G_stat(path, &info) != 0)
184 if (!S_ISDIR(info.st_mode))
187 if (!check_owner(&info))
int G_make_mapset_element(const char *p_element)
Create element in the current mapset.
int G_stat(const char *file_name, struct stat *buf)
Get file status.
int G_mkdir(const char *path)
Creates a new directory.
const char * G_mapset(void)
Get current mapset name.
int G_mapset_permissions(const char *mapset)
Check for user mapset permission.
char * G_file_name_tmp(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files in temporary directory (for internal use only) ...
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
int G_mapset_permissions2(const char *gisdbase, const char *location, const char *mapset)
Check for user mapset permission.
int G__make_mapset_element_misc(const char *dir, const char *name)
Create misc element in the current mapset.
int G_make_mapset_element_tmp(const char *p_element)
Create element in the temporary directory.