GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
is.c
Go to the documentation of this file.
1 
17 #include <stdio.h>
18 #include <string.h>
19 #include <unistd.h>
20 #include <grass/gis.h>
21 
22 
23 static int test_path_file(const char *, const char *);
24 
25 
26 static int test_path_file(const char *path, const char *file)
27 {
28  int ret;
29  char *buf;
30 
31  buf = (char *)G_malloc(strlen(path) + strlen(file) + 2);
32  sprintf(buf, "%s/%s", path, file);
33 
34  ret = access(buf, F_OK);
35  G_free(buf);
36 
37  if (ret == 0)
38  return 1;
39 
40  return 0;
41 }
42 
43 
53 int G_is_gisbase(const char *path)
54 {
55  return test_path_file(path, "etc/element_list");
56 }
57 
58 
67 int G_is_location(const char *path)
68 {
69  return test_path_file(path, "PERMANENT/DEFAULT_WIND");
70 }
71 
72 
81 int G_is_mapset(const char *path)
82 {
83  return test_path_file(path, "WIND");
84 }
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
int G_is_mapset(const char *path)
Test if specified directory is mapset.
Definition: is.c:81
int G_is_location(const char *path)
Test if specified directory is location.
Definition: is.c:67
int G_is_gisbase(const char *path)
Test if specified directory is GISBASE.
Definition: is.c:53
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62
#define file