21 static const char *find_element(
int misc,
const char *dir,
const char *
element)
23 static const char *cell_elements[] = {
34 static const char *dig_elements[] = {
43 const char *search = misc ? dir : element;
46 for (i = 1; cell_elements[i]; i++)
47 if (strcmp(search, cell_elements[i]) == 0)
48 return cell_elements[0];
49 for (i = 1; dig_elements[i]; i++)
50 if (strcmp(search, dig_elements[i]) == 0)
51 return dig_elements[0];
55 static const char *find_file(
int misc,
const char *dir,
56 const char *element,
const char *
name,
61 const char *pname, *pmapset;
81 if (strcmp(element,
"vector") == 0 &&
82 pmapset && strcasecmp(pmapset,
"ogr") == 0) {
100 if (pmapset ==
NULL || *pmapset == 0) {
102 const char *pselmapset =
NULL;
103 const char *pelement = find_element(misc, dir, element);
106 if (misc && element == pelement)
110 if (access(path, 0) == 0) {
112 pselmapset = pmapset;
113 else if (element == pelement)
115 element, pname, pmapset);
124 if (access(path, 0) == 0) {
126 if (cnt > 1 && element == pelement)
146 if (access(path, 0) == 0)
155 static const char *find_file1(
158 const char *element,
char *name,
const char *mapset)
161 const char *pname, *pmapset;
173 mp = find_file(misc, dir, element, pname, pmapset);
175 if (mp && name != pname)
203 const char *
G_find_file(
const char *element,
char *name,
const char *mapset)
205 return find_file1(0,
NULL, element, name, mapset);
225 const char *element,
char *name,
const char *mapset)
227 return find_file1(1, dir, element, name, mapset);
249 const char *
G_find_file2(
const char *element,
const char *name,
const char *mapset)
251 return find_file(0,
NULL, element, name, mapset);
272 const char *name,
const char *mapset)
274 return find_file(1, dir, element, name, mapset);
char * G_file_name_misc(char *, const char *, const char *, const char *, const char *)
Builds full path names to GIS misc data files.
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
void void void G_important_message(const char *,...) __attribute__((format(printf
const char * G_find_file2_misc(const char *dir, const char *element, const char *name, const char *mapset)
Searches for a misc file from the mapset search list or in a specified mapset. (look but don't touch)...
const char * G_find_file(const char *element, char *name, const char *mapset)
Searches for a file from the mapset search list or in a specified mapset.
int G_legal_filename(const char *)
Check for legal database file name.
const char * G_find_file_misc(const char *dir, const char *element, char *name, const char *mapset)
Searches for a misc file from the mapset search list or in a specified mapset.
char * G_store(const char *)
Copy string to allocated memory.
int G_name_is_fully_qualified(const char *, char *, char *)
Check if map name is fully qualified (map @ mapset)
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't touch) ...
const char * G_get_mapset_name(int)
Get name of the n'th mapset from the current mapset search path.