GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
find_rast.c
Go to the documentation of this file.
1 /*!
2  * \file lib/gis/strings.c
3  *
4  * \brief GIS Library - Find raster map
5  *
6  * (C) 1999-2009 by the GRASS Development Team
7  *
8  * This program is free software under the GNU General Public
9  * License (>=v2). Read the file COPYING that comes with GRASS
10  * for details.
11  *
12  * \author Original author CERL
13  */
14 
15 #include <grass/gis.h>
16 
17 /*!
18  * \brief Find a raster map
19  *
20  * Looks for the raster map <i>name</i> in the database. The
21  * <i>mapset</i> parameter can either be the empty string "", which
22  * means search all the mapsets in the user's current mapset search
23  * path (see \ref Mapset_Search_Path for more details about the search
24  * path) or it can be a specific mapset name, which means look for the
25  * raster map only in this one mapset (for example, in the current
26  * mapset). If found, the mapset where the raster map lives is
27  * returned. If not found, the NULL pointer is returned.
28  *
29  * Note: If the user specifies a fully qualified raster map which
30  * exists, then G_find_raster() modifies <i>name</i> by removing
31  * the "@<i>mapset</i>".
32  *
33  * For example, to find a raster map anywhere in the database:
34  \code
35  char name[GNAME_MAX];
36  char *mapset;
37  if ((mapset = G_find_raster(name,"")) == NULL)
38  // not found
39  \endcode
40  *
41  * To check that the raster map exists in the current mapset:
42  *
43  \code
44  char name[GNAME_MAX];
45  if (G_find_raster(name, G_mapset()) == NULL)
46  // not found
47  \endcode
48  *
49  * \param[in,out] name map name
50  * \param mapset mapset name or ""
51  *
52  * \return mapset where raster map was found
53  * \return NULL if not found
54  */
55 const char *G_find_raster(char *name, const char *mapset)
56 {
57  G_debug(1, "G_find_raster(): name=%s mapset=%s", name, mapset);
58  return G_find_file("cell", name, mapset);
59 }
60 
61 /*!
62  * \brief Find a raster map (look but don't touch)
63  *
64  * The same as G_find_raster() but doesn't remove the "@<i>mapset</i>"
65  * qualification from <i>name</i>, if present.
66  *
67  * Returns NULL if the map wasn't found, or the mapset the raster was
68  * found in if it was.
69  *
70  * \param name map name
71  * \param mapset mapset name or ""
72  *
73  * \return mapset where raster map was found
74  * \return NULL if not found
75  */
76 const char *G_find_raster2(const char *name, const char *mapset)
77 {
78  G_debug(1, "G_find_raster2(): name=%s mapset=%s", name, mapset);
79  return G_find_file2("cell", name, mapset);
80 }
const char * G_find_file2(const char *, const char *, const char *)
Searches for a file from the mapset search list or in a specified mapset. (look but don't touch)
Definition: find_file.c:234
int G_debug(int, const char *,...) __attribute__((format(printf
const char * G_find_file(const char *, char *, const char *)
Searches for a file from the mapset search list or in a specified mapset.
Definition: find_file.c:186
const char * G_find_raster2(const char *name, const char *mapset)
Find a raster map (look but don't touch)
Definition: find_rast.c:76
const char * G_find_raster(char *name, const char *mapset)
Find a raster map.
Definition: find_rast.c:55
const char * name
Definition: named_colr.c:6