21#include <grass/config.h>
29#include <grass/glocale.h>
31#include "gis_local_proto.h"
33static int G__open_misc(
const char *dir,
const char *
element,
const char *
name,
34 const char *mapset,
int mode)
38 char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
45 if (*mapset && strcmp(xmapset, mapset) != 0) {
46 G_warning(_(
"G__open_misc(read): mapset <%s> doesn't match "
62 if ((fd = open(
path, 0)) < 0)
63 G_warning(
"G__open_misc(read): Unable to open '%s': %s",
path,
68 if (mode == 1 || mode == 2) {
71 if (strcmp(xmapset, mapset) != 0) {
73 _(
"G__open_misc(write): xmapset <%s> != G_mapset() <%s>"),
84 if (mode == 1 || access(
path, 0) != 0) {
86 close(creat(
path, 0666));
89 if ((fd = open(
path, mode)) < 0)
90 G_warning(
"G__open_misc(write): Unable to open '%s': %s",
path,
135 return G__open_misc(dir,
element,
name, mapset, 0);
158 lseek(fd, 0L, SEEK_END);
186 return fdopen(fd,
"w");
214 return fdopen(fd,
"r");
225 lseek(fd, 0L, SEEK_END);
227 return fdopen(fd,
"a");
238 lseek(fd, 0L, SEEK_END);
240 return fdopen(fd,
"r+");
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.
const char * G_find_file2_misc(const char *dir, const char *element, const char *name, const char *mapset)
Searches for a misc file from the mapset search list or in a specified mapset. (look but don't touch)
void G_warning(const char *msg,...)
Print a warning message to stderr.
void G__check_gisinit(void)
Checks to see if GIS engine is initialized.
int G_legal_filename(const char *s)
Check for legal database file name.
const char * G_mapset(void)
Get current mapset name.
int G__make_mapset_element_misc(const char *dir, const char *name)
Create misc element in the current mapset.
int G_name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)
FILE * G_fopen_old_misc(const char *dir, const char *element, const char *name, const char *mapset)
open a database misc file for reading
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)
int G_open_update_misc(const char *dir, const char *element, const char *name)
open a database misc file for update
FILE * G_fopen_new_misc(const char *dir, const char *element, const char *name)
open a new database misc file
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