GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71806
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
imagery/find.c
Go to the documentation of this file.
1 
2 /**************************************************************
3 * I_find_group (group)
4 *
5 * Find the a group in the current mapset
6 **************************************************************/
7 #include <grass/imagery.h>
8 #include <grass/gis.h>
9 
10 
11 /*!
12  * \brief does group exist?
13  *
14  * Returns 1 if the
15  * specified <b>group</b> exists in the current mapset; 0 otherwise.
16  *
17  * \param group
18  * \return int
19  */
20 
21 int I_find_group(const char *group)
22 {
23  if (group == NULL || *group == 0)
24  return 0;
25 
26  return G_find_file2("group", group, G_mapset()) != NULL;
27 }
28 
29 int I_find_group_file(const char *group, const char *file)
30 {
31  if (!I_find_group(group))
32  return 0;
33  if (file == NULL || *file == 0)
34  return 0;
35 
36  return G_find_file2_misc("group", file, group, G_mapset()) != NULL;
37 }
38 
39 int I_find_subgroup(const char *group, const char *subgroup)
40 {
41  char element[GNAME_MAX];
42 
43  if (!I_find_group(group))
44  return 0;
45  if (subgroup == NULL || *subgroup == 0)
46  return 0;
47 
48  sprintf(element, "subgroup%c%s", HOST_DIRSEP, subgroup);
49  G_debug(5, "I_find_subgroup() element: %s", element);
50 
51  return G_find_file2_misc("group", element, group, G_mapset()) != NULL;
52 }
53 
54 int I_find_subgroup_file(const char *group, const char *subgroup,
55  const char *file)
56 {
57  char element[GNAME_MAX * 2];
58 
59  if (!I_find_group(group))
60  return 0;
61  if (subgroup == NULL || *subgroup == 0)
62  return 0;
63  if (file == NULL || *file == 0)
64  return 0;
65 
66  sprintf(element, "subgroup%c%s%c%s", HOST_DIRSEP, subgroup, HOST_DIRSEP, file);
67  G_debug(5, "I_find_subgroup_file() element: %s", element);
68 
69  return G_find_file2_misc("group", element, group, G_mapset()) != NULL;
70 }
71 
72 /*!
73  * \brief does signature file exists?
74  *
75  * Returns 1 if the
76  * specified <b>signature</b> exists in the specified subgroup; 0 otherwise.
77  *
78  * Should be used to check if signature file exists after G_parser run
79  * when generating new signature file.
80  *
81  * \param group - group where to search
82  * \param subgroup - subgroup containing signatures
83  * \param type - type of signature ("sig" or "sigset")
84  * \param file - name of signature file
85  * \return int
86  */
87 int I_find_signature_file(const char *group, const char *subgroup,
88  const char *type, const char *file)
89 {
90  char element[GNAME_MAX * 2];
91 
92  if (!I_find_group(group))
93  return 0;
94  if (subgroup == NULL || *subgroup == 0)
95  return 0;
96  if (type == NULL || *type == 0)
97  return 0;
98  if (file == NULL || *file == 0)
99  return 0;
100 
101  sprintf(element, "subgroup%c%s%c%s%c%s", HOST_DIRSEP, subgroup, HOST_DIRSEP, type, HOST_DIRSEP, file);
102  G_debug(5, "I_find_signature_file() element: %s", element);
103 
104  return G_find_file2_misc("group", element, group, G_mapset()) != NULL;
105 }
const char * G_find_file2_misc(const char *dir, const char *element, const char *name, const char *mapset)
Searches for a file from the mapset search list or in a specified mapset. (look but don&#39;t touch) ...
Definition: find_file.c:267
#define NULL
Definition: ccmath.h:32
Definition: lidar.h:89
int I_find_subgroup(const char *group, const char *subgroup)
Definition: imagery/find.c:39
#define HOST_DIRSEP
Definition: gis.h:194
int I_find_group(const char *group)
does group exist?
Definition: imagery/find.c:21
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
int I_find_group_file(const char *group, const char *file)
Definition: imagery/find.c:29
#define GNAME_MAX
Definition: gis.h:148
#define file
int I_find_signature_file(const char *group, const char *subgroup, const char *type, const char *file)
does signature file exists?
Definition: imagery/find.c:87
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
int I_find_subgroup_file(const char *group, const char *subgroup, const char *file)
Definition: imagery/find.c:54
const char * G_find_file2(const char *element, const char *name, const char *mapset)
Searches for a file from the mapset search list or in a specified mapset. (look but don&#39;t touch) ...
Definition: find_file.c:247