25 #include "gis_local_proto.h"
52 static int G__open(
const char *
element,
const char *
name,
const char *mapset,
67 if (*mapset && strcmp(xmapset, mapset) != 0) {
69 _(
"G__open(read): mapset <%s> doesn't match xmapset <%s>"),
89 if ((fd = open(
path, 0)) < 0)
95 if (mode == 1 || mode == 2) {
98 if (strcmp(xmapset, mapset) != 0) {
99 G_warning(
_(
"G__open(write): xmapset <%s> != G_mapset() <%s>"),
114 if (mode == 1 || access(
path, 0) != 0) {
119 close(open(
path, O_WRONLY | O_CREAT | O_TRUNC, 0666));
122 if ((fd = open(
path, mode)) < 0)
197 lseek(fd, 0L, SEEK_END);
225 G_debug(1,
"G_fopen_new(): element = %s, name = %s : NULL",
element,
230 G_debug(2,
"\tfile open: new (mode = w)");
231 return fdopen(fd,
"w");
259 G_debug(2,
"\tfile open: read (mode = r)");
260 return fdopen(fd,
"r");
285 lseek(fd, 0L, SEEK_END);
287 G_debug(2,
"\tfile open: append (mode = a)");
288 return fdopen(fd,
"a");
313 lseek(fd, 0L, SEEK_END);
315 G_debug(2,
"\tfile open: modify (mode = r+)");
316 return fdopen(fd,
"r+");
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 *, const char *, const char *)
Searches for a file from the mapset search list or in a specified mapset. (look but don't touch)
void G_warning(const char *,...) __attribute__((format(printf
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
int G_legal_filename(const char *)
Check for legal database file name.
int G_make_mapset_object_group(const char *)
Create directory for group of elements of a given type.
const char * G_mapset(void)
Get current mapset name.
char * G_file_name_tmp(char *, const char *, const char *, const char *)
Builds full path names to GIS data files in temporary directory (for internal use only)
int G_make_mapset_object_group_tmp(const char *)
Create directory for type of objects in the temporary directory.
int G_debug(int, const char *,...) __attribute__((format(printf
FILE * G_fopen_append(const char *element, const char *name)
Open a database file for update (append mode)
FILE * G_fopen_modify(const char *element, const char *name)
Open a database file for update (r+ mode)
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
int G_open_new(const char *element, const char *name)
Open a new database file.
int G_open_update(const char *element, const char *name)
Open a database file for update.
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
int G_open_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
void G__check_gisinit(void)
Checks to see if GIS engine is initialized.