17 #include <sys/types.h> 22 static int make_mapset_element(
const char *,
const char *);
23 static int make_mapset_element_no_fail_on_race(
const char *,
const char *);
24 static int make_mapset_element_impl(
const char *,
const char *,
bool);
49 return make_mapset_element(path, p_element);
79 return make_mapset_element_no_fail_on_race(path, type);
114 return make_mapset_element(path, name);
136 return make_mapset_element(path, p_element);
158 return make_mapset_element_no_fail_on_race(path, type);
161 int make_mapset_element_impl(
const char *p_path,
const char *p_element,
bool race_ok)
183 if (*element ==
'/' || *element == 0) {
186 if (access(path, 0) != 0) {
189 msg =
G_store(strerror(errno));
192 if (access(path, 0) != 0 || (msg && !race_ok)) {
197 p_element, path, strerror(errno));
202 p_element, path, strerror(errno));
212 int make_mapset_element(
const char *p_path,
const char *p_element)
214 return make_mapset_element_impl(p_path, p_element,
false);
217 int make_mapset_element_no_fail_on_race(
const char *p_path,
const char *p_element)
219 return make_mapset_element_impl(p_path, p_element,
true);
237 static int check_owner(
const struct stat *info)
239 #if defined(__MINGW32__) || defined(SKIP_MAPSET_OWN_CHK) 242 const char *check =
getenv(
"GRASS_SKIP_MAPSET_OWNER_CHECK");
245 if (info->st_uid != getuid())
247 if (info->st_uid != geteuid())
269 if (
G_stat(path, &info) != 0)
271 if (!S_ISDIR(info.st_mode))
274 if (!check_owner(&info))
297 sprintf(path,
"%s/%s/%s", gisdbase, location, mapset);
299 if (
G_stat(path, &info) != 0)
301 if (!S_ISDIR(info.st_mode))
304 if (!check_owner(&info))
int G_make_mapset_element(const char *p_element)
Create element in the current mapset.
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_mapset_permissions(const char *mapset)
Check for user mapset permission.
int G_make_mapset_object_group(const char *type)
Create directory for group of elements of a given type.
int G_make_mapset_dir_object(const char *type, const char *name)
Create directory for an object of a given type.
int G_mapset_permissions2(const char *gisdbase, const char *location, const char *mapset)
Check for user mapset permission.
int G_stat(const char *, struct stat *)
Get file status.
int G__make_mapset_element_misc(const char *dir, const char *name)
Create misc element in the current mapset.
char * G_file_name_tmp(char *, const char *, const char *, const char *)
Builds full path names to GIS data files in temporary directory (for internal use only) ...
const char * G_mapset(void)
Get current mapset name.
int G_mkdir(const char *)
Creates a new directory.
char * G_store(const char *)
Copy string to allocated memory.
int G_make_mapset_element_tmp(const char *p_element)
Create element in the temporary directory.
int G_make_mapset_object_group_tmp(const char *type)
Create directory for type of objects in the temporary directory.