GRASS 8 Programmer's Manual 8.6.0dev(2026)-8843f13794
Loading...
Searching...
No Matches
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 * SPDX-FileCopyrightText: 1999-2009 GRASS Development Team
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * \author Original author CERL
10 */
11
12#include <grass/gis.h>
13
14/*!
15 * \brief Find a raster map
16 *
17 * Looks for the raster map <i>name</i> in the database. The
18 * <i>mapset</i> parameter can either be the empty string "", which
19 * means search all the mapsets in the user's current mapset search
20 * path (see \ref Mapset_Search_Path for more details about the search
21 * path) or it can be a specific mapset name, which means look for the
22 * raster map only in this one mapset (for example, in the current
23 * mapset). If found, the mapset where the raster map lives is
24 * returned. If not found, the NULL pointer is returned.
25 *
26 * Note: If the user specifies a fully qualified raster map which
27 * exists, then G_find_raster() modifies <i>name</i> by removing
28 * the "@<i>mapset</i>".
29 *
30 * For example, to find a raster map anywhere in the database:
31 \code
32 char name[GNAME_MAX];
33 char *mapset;
34 if ((mapset = G_find_raster(name,"")) == NULL)
35 // not found
36 \endcode
37 *
38 * To check that the raster map exists in the current mapset:
39 *
40 \code
41 char name[GNAME_MAX];
42 if (G_find_raster(name, G_mapset()) == NULL)
43 // not found
44 \endcode
45 *
46 * \param[in,out] name map name
47 * \param mapset mapset name or ""
48 *
49 * \return mapset where raster map was found
50 * \return NULL if not found
51 */
52const char *G_find_raster(char *name, const char *mapset)
53{
54 G_debug(1, "G_find_raster(): name=%s mapset=%s", name, mapset);
55 return G_find_file("cell", name, mapset);
56}
57
58/*!
59 * \brief Find a raster map (look but don't touch)
60 *
61 * The same as G_find_raster() but doesn't remove the "@<i>mapset</i>"
62 * qualification from <i>name</i>, if present.
63 *
64 * Returns NULL if the map wasn't found, or the mapset the raster was
65 * found in if it was.
66 *
67 * \param name map name
68 * \param mapset mapset name or ""
69 *
70 * \return mapset where raster map was found
71 * \return NULL if not found
72 */
73const char *G_find_raster2(const char *name, const char *mapset)
74{
75 G_debug(1, "G_find_raster2(): name=%s mapset=%s", name, mapset);
76 return G_find_file2("cell", name, mapset);
77}
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:182
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:230
int G_debug(int, const char *,...) __attribute__((format(printf
const char * G_find_raster(char *name, const char *mapset)
Find a raster map.
Definition find_rast.c:52
const char * G_find_raster2(const char *name, const char *mapset)
Find a raster map (look but don't touch)
Definition find_rast.c:73
const char * name
Definition named_colr.c:6