00001 #include <stdio.h> 00002 #include <string.h> 00003 #include <unistd.h> 00004 #include <grass/gis.h> 00005 00006 int test_path_file ( const char *path, const char *file ) 00007 { 00008 int ret; 00009 char *buf; 00010 00011 buf = (char *) G_malloc ( strlen(path) + strlen(file) + 2 ); 00012 sprintf ( buf, "%s/%s", path, file ); 00013 00014 ret = access(buf,F_OK); 00015 G_free ( buf ); 00016 00017 if ( ret == 0 ) return 1; 00018 00019 return 0; 00020 } 00021 00028 int G_is_gisbase (const char *path) 00029 { 00030 return test_path_file ( path, "etc/element_list" ); 00031 } 00032 00039 int G_is_location (const char *path) 00040 { 00041 return test_path_file ( path, "PERMANENT/DEFAULT_WIND" ); 00042 } 00043 00050 int G_is_mapset (const char *path) 00051 { 00052 return test_path_file ( path, "WIND" ); 00053 } 00054