GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-77aab223bc
gis/mapset.c File Reference

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

#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include "gis_local_proto.h"
Include dependency graph for gis/mapset.c:

Go to the source code of this file.

Functions

const char * G_mapset (void)
 Get current mapset name. More...
 
const char * G__mapset (void)
 Get current mapset name (internal use only) More...
 
char * G_mapset_path (void)
 Get current mapset UNIX-like path. More...
 
char * G__mapset_path (void)
 Get current mapset UNIX-like path (internal use only) More...
 

Detailed Description

GIS library - environment routines (mapset)

(C) 2001-2009, 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 gis/mapset.c.

Function Documentation

◆ G__mapset()

const char* G__mapset ( void  )

Get current mapset name (internal use only)

See G_mapset().

Returns
pointer mapset name
NULL on error

Definition at line 51 of file gis/mapset.c.

References G_getenv_nofatal().

Referenced by G__mapset_path(), and G_mapset().

◆ G__mapset_path()

char* G__mapset_path ( void  )

Get current mapset UNIX-like path (internal use only)

Allocated buffer should be freed by G_free(). See also G_mapset_path().

Todo:
Support also Windows-like path (?)
Returns
buffer with mapset path

Definition at line 96 of file gis/mapset.c.

References G__mapset(), G_gisdbase(), G_location(), and G_malloc.

Referenced by G_mapset_path().

◆ G_mapset()

◆ G_mapset_path()

char* G_mapset_path ( void  )

Get current mapset UNIX-like path.

Allocated buffer should be freed by G_free(). See G__mapset_path().

Returns the full UNIX path name of the current mapset. For example, if the user is working in mapset user1, location spearfish in the /home/user/grassdata database directory, this routine will return a string which looks like /home/user/grassdata/spearfish/user1.

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

Returns
buffer with location path

Definition at line 73 of file gis/mapset.c.

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