Go to the documentation of this file.00001
00017 #include <stdio.h>
00018 #include <string.h>
00019 #include <unistd.h>
00020 #include <grass/gis.h>
00021
00022
00023 static int test_path_file(const char *, const char *);
00024
00025
00026 static int test_path_file(const char *path, const char *file)
00027 {
00028 int ret;
00029 char *buf;
00030
00031 buf = (char *)G_malloc(strlen(path) + strlen(file) + 2);
00032 sprintf(buf, "%s/%s", path, file);
00033
00034 ret = access(buf, F_OK);
00035 G_free(buf);
00036
00037 if (ret == 0)
00038 return 1;
00039
00040 return 0;
00041 }
00042
00043
00053 int G_is_gisbase(const char *path)
00054 {
00055 return test_path_file(path, "etc/element_list");
00056 }
00057
00058
00067 int G_is_location(const char *path)
00068 {
00069 return test_path_file(path, "PERMANENT/DEFAULT_WIND");
00070 }
00071
00072
00081 int G_is_mapset(const char *path)
00082 {
00083 return test_path_file(path, "WIND");
00084 }