22 #include <grass/config.h> 29 #include <grass/gis.h> 30 #include <grass/glocale.h> 32 #include "gis_local_proto.h" 34 static int G__open_misc(
const char *dir,
36 const char *
name,
const char *mapset,
int mode)
48 if (*mapset && strcmp(xmapset, mapset) != 0) {
49 G_warning(
_(
"G__open_misc(read): mapset <%s> doesn't match xmapset <%s>"),
64 if ((fd = open(path, 0)) < 0)
65 G_warning(
"G__open_misc(read): Unable to open '%s': %s",
66 path, strerror(errno));
70 if (mode == 1 || mode == 2) {
73 if (strcmp(xmapset, mapset) != 0) {
74 G_warning(
_(
"G__open_misc(write): xmapset <%s> != G_mapset() <%s>"),
85 if (mode == 1 || access(path, 0) != 0) {
87 close(creat(path, 0666));
90 if ((fd = open(path, mode)) < 0)
91 G_warning(
"G__open_misc(write): Unable to open '%s': %s",
92 path, strerror(errno));
115 return G__open_misc(dir, element, name,
G_mapset(), 1);
137 return G__open_misc(dir, element, name, mapset, 0);
159 fd = G__open_misc(dir, element, name,
G_mapset(), 2);
161 lseek(fd, 0L, SEEK_END);
186 fd = G__open_misc(dir, element, name,
G_mapset(), 1);
190 return fdopen(fd,
"w");
215 fd = G__open_misc(dir, element, name, mapset, 0);
219 return fdopen(fd,
"r");
227 fd = G__open_misc(dir, element, name,
G_mapset(), 2);
230 lseek(fd, 0L, SEEK_END);
232 return fdopen(fd,
"a");
240 fd = G__open_misc(dir, element, name,
G_mapset(), 2);
243 lseek(fd, 0L, SEEK_END);
245 return fdopen(fd,
"r+");
FILE * G_fopen_modify_misc(const char *dir, const char *element, const char *name)
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't touch) ...
FILE * G_fopen_old_misc(const char *dir, const char *element, const char *name, const char *mapset)
open a database file for reading
FILE * G_fopen_append_misc(const char *dir, const char *element, const char *name)
int G_open_old_misc(const char *dir, const char *element, const char *name, const char *mapset)
open a database file for reading
int G_open_new_misc(const char *dir, const char *element, const char *name)
open a new database file
int G__make_mapset_element_misc(const char *dir, const char *name)
Create misc element in the current mapset.
FILE * G_fopen_new_misc(const char *dir, const char *element, const char *name)
open a new database file
void G__check_gisinit(void)
Checks to see if GIS engine is initialized.
int G_name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)
const char * G_mapset(void)
Get current mapset name.
char * G_file_name_misc(char *path, const char *dir, const char *element, const char *name, const char *mapset)
Builds full path names to GIS misc data files.
int G_open_update_misc(const char *dir, const char *element, const char *name)
open a database file for update
int G_legal_filename(const char *s)
Check for legal database file name.
void G_warning(const char *msg,...)
Print a warning message to stderr.