15 #include <grass/config.h>
21 #include <grass/gis.h>
22 #include <grass/glocale.h>
49 static int G__open(
const char *element,
50 const char *
name,
const char *mapset,
int mode)
61 if (*mapset && strcmp(xmapset, mapset) != 0) {
62 G_warning(_(
"G__open(read): mapset <%s> doesn't match xmapset <%s>"),
69 else if (!mapset || !*mapset)
80 if (mode == 1 || mode == 2) {
83 if (strcmp(xmapset, mapset) != 0) {
84 G_warning(_(
"G__open(write): xmapset <%s> != G_mapset() <%s>"),
96 if (mode == 1 || access(path, 0) != 0) {
98 close(open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666));
101 return open(path, mode);
127 return G__open(element, name,
G_mapset(), 1);
147 int G_open_old(
const char *element,
const char *name,
const char *mapset)
149 return G__open(element, name, mapset, 0);
172 fd = G__open(element, name,
G_mapset(), 2);
174 lseek(fd, 0L, SEEK_END);
201 fd = G__open(element, name,
G_mapset(), 1);
205 return fdopen(fd,
"w");
226 FILE *
G_fopen_old(
const char *element,
const char *name,
const char *mapset)
230 fd = G__open(element, name, mapset, 0);
234 return fdopen(fd,
"r");
256 fd = G__open(element, name,
G_mapset(), 2);
259 lseek(fd, 0L, SEEK_END);
261 return fdopen(fd,
"a");
283 fd = G__open(element, name,
G_mapset(), 2);
286 lseek(fd, 0L, SEEK_END);
288 return fdopen(fd,
"r+");
char * G_mapset(void)
current mapset name
FILE * G_fopen_modify(const char *element, const char *name)
Open a database file for update (r+ mode)
char * G__file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
int G_open_update(const char *element, const char *name)
Open a database file for update.
int G_open_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
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) retu...
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int G_open_new(const char *element, const char *name)
Open a new database file.
int G__make_mapset_element(const char *p_element)
Create element in the current mapset.
FILE * G_fopen_append(const char *element, const char *name)
Open a database file for update (append mode)
int G__check_gisinit(void)
Checks to see if GIS engine is initialized.
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
int G_legal_filename(const char *s)
Check for legal database file name.
int G__name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)