1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/**********************************************************************
*
* char *
* G_location_path()
*
* returns pointer to the full path name to the current location
*
* note:
* exits with message if path not accessible to user
**********************************************************************
*
* char *
* G_location()
*
* returns: pointer to string containing the one word location
* name.
**********************************************************************/
#include <string.h>
#include <unistd.h>
#include "gis.h"
#include "glocale.h"
/*!
* \brief current location directory
*
* Returns the
* full UNIX path name of the current database location. For example, if the user
* is working in location <i>spearfish</i> in the <i>/usr/grass5/data</i>
* database directory, this routine will return a string which looks like
* <i>/home/user/grassdata/spearfish</i>.
*
* \param void
* \return char *
*/
char *
G_location_path()
{
char *location;
location = G__location_path();
if(access(location,0) != 0)
{
char msg[400];
sprintf(msg,_("LOCATION << %s >> not available"), location) ;
G_fatal_error (msg);
}
return location;
}
/*!
* \brief current location name
*
* Returns the name of
* the current database location. This routine should be used by modules that
* need to display the current location to the user. See Locations for
* an explanation of locations.
*
* \param void
* \return char *
*/
char *
G_location()
{
return G_getenv ("LOCATION_NAME");
}
char *
G__location_path()
{
char *location = 0;
char *base;
char *name;
name = G_location();
base = G_gisdbase();
location = G_malloc (strlen (base) + strlen (name) + 2);
sprintf (location, "%s/%s", base, name);
return location;
}
|