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));
137 return G__open_misc(dir,
element,
name, mapset, 0);
161 lseek(fd, 0L, SEEK_END);
190 return fdopen(fd,
"w");
219 return fdopen(fd,
"r");
230 lseek(fd, 0L, SEEK_END);
232 return fdopen(fd,
"a");
243 lseek(fd, 0L, SEEK_END);
245 return fdopen(fd,
"r+");
char * G_file_name_misc(char *, const char *, const char *, const char *, const char *)
Builds full path names to GIS misc data files.
int G_name_is_fully_qualified(const char *, char *, char *)
Check if map name is fully qualified (map @ mapset)
int G__make_mapset_element_misc(const char *, const char *)
Create misc element in the current mapset.
void G_warning(const char *,...) __attribute__((format(printf
int G_legal_filename(const char *)
Check for legal database file name.
const char * G_mapset(void)
Get current mapset name.
const char * G_find_file2_misc(const char *, const char *, const char *, const char *)
Searches for a misc file from the mapset search list or in a specified mapset. (look but don't touch)
void G__check_gisinit(void)
Checks to see if GIS engine is initialized.
int G_open_new_misc(const char *dir, const char *element, const char *name)
open a new database misc file
FILE * G_fopen_modify_misc(const char *dir, const char *element, const char *name)
FILE * G_fopen_old_misc(const char *dir, const char *element, const char *name, const char *mapset)
open a database misc file for reading
FILE * G_fopen_new_misc(const char *dir, const char *element, const char *name)
open a new database misc file
int G_open_update_misc(const char *dir, const char *element, const char *name)
open a database misc file for update
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 misc file for reading