find_cell.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. **********************************************************************
  3. * char *
  4. * G_find_cell (name, mapset)
  5. * char *name file name to look for
  6. * char *mapset mapset to search. if mapset is ""
  7. * will search in mapset search list
  8. *
  9. * searches for a cell file from the mapset search list
  10. * or in a specified mapset.
  11. * returns the mapset name where the cell file was found.
  12. *
  13. * returns:
  14. * char * pointer to a string with name of mapset
  15. * where cell file was found, or NULL if not found
  16. * note:
  17. * rejects all names that begin with .
  18. *
  19. * if name is of the form nnn in ppp then
  20. * name = nnn and mapset = ppp
  21. **********************************************************************/
  22. #include <grass/gis.h>
  23. /*!
  24. * \brief find a raster map
  25. *
  26. * Looks for the raster map <b>name</b> in the database. The
  27. * <b>mapset</b> parameter can either be the empty string "", which means
  28. * search all the mapsets in the user's current mapset search path,
  29. * \remarks{See Mapset_Search_Path for more details about the search path.}
  30. * or it can be a specific mapset name, which means look for the raster map
  31. * only in this one mapset (for example, in the current mapset). If found,
  32. * the mapset where the raster map lives is returned. If not found, the NULL
  33. * pointer is returned.
  34. *
  35. * NOTE: If the user specifies a fully qualified raster map which exists,
  36. * then <i>G_find_cell(~)</i> modifies <b>name</b> by removing the
  37. * "@<i>mapset</i>".
  38. *
  39. * For example, to find a raster map anywhere in the database:
  40. \code
  41. char name[GNAME_MAX];
  42. char *mapset;
  43. if ((mapset = G_find_cell(name,"")) == NULL)
  44. // not found
  45. \endcode
  46. *
  47. * To check that the raster map exists in the current mapset:
  48. *
  49. \code
  50. char name[GNAME_MAX];
  51. if (G_find_cell(name,G_mapset( )) == NULL)
  52. // not found
  53. \endcode
  54. *
  55. * \param name
  56. * \param mapset
  57. * \return char *
  58. */
  59. char *G_find_cell(char *name, const char *mapset)
  60. {
  61. return G_find_file("cell", name, mapset);
  62. }
  63. /*!
  64. * \brief find a raster map (look but don't touch)
  65. *
  66. * The same as G_find_cell() but doesn't remove the "@<i>mapset</i>"
  67. * qualification from <b>name</b>, if present.
  68. *
  69. * Returns NULL if the map wasn't found, or the mapset the raster was
  70. * found in if it was.
  71. *
  72. * \param name
  73. * \param mapset
  74. * \return char *
  75. */
  76. char *G_find_cell2(const char *name, const char *mapset)
  77. {
  78. return G_find_file2("cell", name, mapset);
  79. }