find_rast.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include <grass/gis.h>
  15. /*!
  16. * \brief Find a raster map
  17. *
  18. * Looks for the raster map <i>name</i> in the database. The
  19. * <i>mapset</i> parameter can either be the empty string "", which
  20. * means search all the mapsets in the user's current mapset search
  21. * path (see \ref Mapset_Search_Path for more details about the search
  22. * path) or it can be a specific mapset name, which means look for the
  23. * raster map only in this one mapset (for example, in the current
  24. * mapset). If found, the mapset where the raster map lives is
  25. * returned. If not found, the NULL pointer is returned.
  26. *
  27. * Note: If the user specifies a fully qualified raster map which
  28. * exists, then G_find_raster() modifies <i>name</i> by removing
  29. * the "@<i>mapset</i>".
  30. *
  31. * For example, to find a raster map anywhere in the database:
  32. \code
  33. char name[GNAME_MAX];
  34. char *mapset;
  35. if ((mapset = G_find_raster(name,"")) == NULL)
  36. // not found
  37. \endcode
  38. *
  39. * To check that the raster map exists in the current mapset:
  40. *
  41. \code
  42. char name[GNAME_MAX];
  43. if (G_find_raster(name, G_mapset()) == NULL)
  44. // not found
  45. \endcode
  46. *
  47. * \param[in,out] name map name
  48. * \param mapset mapset name or ""
  49. *
  50. * \return mapset where raster map was found
  51. * \return NULL if not found
  52. */
  53. const char *G_find_raster(char *name, const char *mapset)
  54. {
  55. G_debug(1, "G_find_raster(): name=%s mapset=%s", name, mapset);
  56. return G_find_file("cell", name, mapset);
  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. */
  73. const 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. }