GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
location.c File Reference

GIS library - environment routines (location) More...

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include "gis_local_proto.h"
Include dependency graph for location.c:

Go to the source code of this file.

Functions

const char * G_location (void)
 Get current location name. More...
 
char * G_location_path (void)
 Get current location UNIX-like path. More...
 
char * G__location_path (void)
 Get current location UNIX-like path (internal use only) More...
 

Detailed Description

GIS library - environment routines (location)

(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.

Author
Original author CERL

Definition in file location.c.

Function Documentation

◆ G__location_path()

char* G__location_path ( void  )

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 (?)
Returns
buffer with location path

Definition at line 77 of file location.c.

References G_gisdbase(), G_location(), G_malloc, HOST_DIRSEP, and name.

Referenced by G_location_path().

◆ G_location()

const char* G_location ( void  )

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.

Returns
location name

Definition at line 32 of file location.c.

References G_getenv().

Referenced by G__location_path(), G__mapset_path(), G_get_projepsg(), G_get_projinfo(), G_get_projunits(), G_make_mapset(), I_location_info(), and Vect_hist_command().

◆ G_location_path()

char* G_location_path ( void  )

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 spearfish in the /home/user/grassdata database directory, this routine will return a string which looks like /home/user/grassdata/spearfish.

This function also checks if location path is readable by the current user. It calls G_fatal_error() on failure.

Returns
buffer with location path

Definition at line 54 of file location.c.

References _, G__location_path(), and G_fatal_error().

Referenced by db_set_default_connection(), and G_get_available_mapsets().