GRASS GIS 7 Programmer's Manual
7.8.2(2019)-exported
|
Go to the documentation of this file.
15 #include <grass/config.h>
22 #include <grass/gis.h>
23 #include <grass/glocale.h>
25 #include "gis_local_proto.h"
52 static int G__open(
const char *
element,
53 const char *
name,
const char *mapset,
int mode)
58 char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
67 if (*mapset && strcmp(xmapset, mapset) != 0) {
68 G_warning(_(
"G__open(read): mapset <%s> doesn't match xmapset <%s>"),
88 if ((fd = open(
path, 0)) < 0)
89 G_warning(_(
"G__open(read): Unable to open '%s': %s"),
90 path, strerror(errno));
94 if (mode == 1 || mode == 2) {
97 if (strcmp(xmapset, mapset) != 0) {
98 G_warning(_(
"G__open(write): xmapset <%s> != G_mapset() <%s>"),
113 if (mode == 1 || access(
path, 0) != 0) {
118 close(open(
path, O_WRONLY | O_CREAT | O_TRUNC, 0666));
121 if ((fd = open(
path, mode)) < 0)
122 G_warning(_(
"G__open(write): Unable to open '%s': %s"),
123 path, strerror(errno));
197 lseek(fd, 0L, SEEK_END);
226 G_debug(1,
"G_fopen_new(): element = %s, name = %s : NULL",
231 G_debug(2,
"\tfile open: new (mode = w)");
232 return fdopen(fd,
"w");
259 return (FILE *)
NULL;
261 G_debug(2,
"\tfile open: read (mode = r)");
262 return fdopen(fd,
"r");
287 lseek(fd, 0L, SEEK_END);
289 G_debug(2,
"\tfile open: append (mode = a)");
290 return fdopen(fd,
"a");
315 lseek(fd, 0L, SEEK_END);
317 G_debug(2,
"\tfile open: modify (mode = r+)");
318 return fdopen(fd,
"r+");
char * G_file_name_tmp(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files in temporary directory (for internal use only)
int G_open_new(const char *element, const char *name)
Open a new database file.
int G_name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)
int G_make_mapset_element_tmp(const char *p_element)
Create element in the temporary directory.
FILE * G_fopen_modify(const char *element, const char *name)
Open a database file for update (r+ mode)
const char * G_mapset(void)
Get current mapset name.
FILE * G_fopen_append(const char *element, const char *name)
Open a database file for update (append mode)
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
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_debug(int level, const char *msg,...)
Print debugging message.
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.
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)
int G_open_update(const char *element, const char *name)
Open a database file for update.
void G_warning(const char *msg,...)
Print a warning message to stderr.
int G_make_mapset_element(const char *p_element)
Create element in the current mapset.