|
@@ -1,14 +1,12 @@
|
|
/*!
|
|
/*!
|
|
- \file gis/location.c
|
|
|
|
|
|
+ \file lib/gis/location.c
|
|
|
|
|
|
\brief GIS library - environment routines (location)
|
|
\brief GIS library - environment routines (location)
|
|
|
|
|
|
- (C) 2001-2008 by the GRASS Development Team
|
|
|
|
|
|
+ (C) 2001-2008, 2012 by the GRASS Development Team
|
|
|
|
|
|
- This program is free software under the
|
|
|
|
- GNU General Public License (>=v2).
|
|
|
|
- Read the file COPYING that comes with GRASS
|
|
|
|
- for details.
|
|
|
|
|
|
+ This program is free software under the GNU General Public License
|
|
|
|
+ (>=v2). Read the file COPYING that comes with GRASS for details.
|
|
|
|
|
|
\author Original author CERL
|
|
\author Original author CERL
|
|
*/
|
|
*/
|
|
@@ -20,34 +18,39 @@
|
|
#include <grass/gis.h>
|
|
#include <grass/gis.h>
|
|
#include <grass/glocale.h>
|
|
#include <grass/glocale.h>
|
|
|
|
|
|
|
|
+#include "gis_local_proto.h"
|
|
|
|
|
|
/*!
|
|
/*!
|
|
- * \brief Get 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.
|
|
|
|
- *
|
|
|
|
- * \return char* tolocation name
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
|
|
+ \brief Get 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.
|
|
|
|
+
|
|
|
|
+ \return location name
|
|
|
|
+*/
|
|
const char *G_location(void)
|
|
const char *G_location(void)
|
|
{
|
|
{
|
|
return G_getenv("LOCATION_NAME");
|
|
return G_getenv("LOCATION_NAME");
|
|
}
|
|
}
|
|
|
|
|
|
/*!
|
|
/*!
|
|
- * \brief Get 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>/home/user/grassdata</i> database
|
|
|
|
- * directory, this routine will return a string which looks like
|
|
|
|
- * <i>/home/user/grassdata/spearfish</i>.
|
|
|
|
- *
|
|
|
|
- * \return char *
|
|
|
|
- */
|
|
|
|
|
|
+ \brief Get current location UNIX-like path
|
|
|
|
+
|
|
|
|
+ Allocated buffer should be freed by G_free(). See
|
|
|
|
+ G__location_path().
|
|
|
|
|
|
|
|
+ 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>/home/user/grassdata</i> database
|
|
|
|
+ directory, this routine will return a string which looks like
|
|
|
|
+ <i>/home/user/grassdata/spearfish</i>.
|
|
|
|
+
|
|
|
|
+ This function also checks if location path is readable by the
|
|
|
|
+ current user. It calls G_fatal_error() on failure.
|
|
|
|
+
|
|
|
|
+ \return buffer with location path
|
|
|
|
+ */
|
|
char *G_location_path(void)
|
|
char *G_location_path(void)
|
|
{
|
|
{
|
|
char *location;
|
|
char *location;
|
|
@@ -55,7 +58,7 @@ char *G_location_path(void)
|
|
location = G__location_path();
|
|
location = G__location_path();
|
|
if (access(location, F_OK) != 0) {
|
|
if (access(location, F_OK) != 0) {
|
|
perror("access");
|
|
perror("access");
|
|
- G_fatal_error(_("LOCATION << %s >> not available"), location);
|
|
|
|
|
|
+ G_fatal_error(_("LOCATION <%s> not available"), location);
|
|
}
|
|
}
|
|
|
|
|
|
return location;
|
|
return location;
|
|
@@ -63,9 +66,14 @@ char *G_location_path(void)
|
|
|
|
|
|
|
|
|
|
/*!
|
|
/*!
|
|
- * \brief Get current location path
|
|
|
|
- *
|
|
|
|
- * \return char* to location path
|
|
|
|
|
|
+ \brief Get current location UNIX-like path (internal use only)
|
|
|
|
+
|
|
|
|
+ Allocated buffer should be freed by G_free(). See also
|
|
|
|
+ G_location_path().
|
|
|
|
+
|
|
|
|
+ \todo Support also Windows-like path (?)
|
|
|
|
+
|
|
|
|
+ \return buffer with location path
|
|
*/
|
|
*/
|
|
char *G__location_path(void)
|
|
char *G__location_path(void)
|
|
{
|
|
{
|