GRASS Programmer's Manual 6.4.1(2011)
|
00001 00016 #include <stdio.h> 00017 #include <string.h> 00018 #include <unistd.h> 00019 #include <sys/types.h> 00020 #include <grass/gis.h> 00021 #include <grass/glocale.h> 00022 00023 00037 char *G_location_path(void) 00038 { 00039 char *location; 00040 00041 location = G__location_path(); 00042 if (access(location, 0) != 0) { 00043 perror("access"); 00044 G_fatal_error(_("LOCATION << %s >> not available"), location); 00045 } 00046 00047 return location; 00048 } 00049 00050 00061 char *G_location(void) 00062 { 00063 return G_getenv("LOCATION_NAME"); 00064 } 00065 00072 char *G__location_path(void) 00073 { 00074 char *location = 0; 00075 char *base; 00076 char *name; 00077 00078 name = G_location(); 00079 base = G_gisdbase(); 00080 location = G_malloc(strlen(base) + strlen(name) + 2); 00081 00082 sprintf(location, "%s/%s", base, name); 00083 00084 return location; 00085 }