21 #include <grass/vector.h> 22 #include <grass/glocale.h> 24 #include "local_proto.h" 38 G_debug(1,
"V1_close_nat(): name = %s mapset= %s", Map->
name,
59 char *env =
getenv(
"GRASS_VECTOR_TEMPORARY");
62 if (Map->
temporary == TEMPORARY_MAP_ENV && env) {
67 G_debug(1,
"V1_close_nat(): temporary map <%s> TO BE MOVED TO" 73 if (access(path_map, 0) != 0 &&
G_mkdir(path_map) != 0)
75 path_map, strerror(errno));
79 G_debug(1,
"V1_close_nat(): %s -> %s", path_tmp, path_map);
81 G_fatal_error(
_(
"Unable to copy '%s': %s"), path_tmp, strerror(errno));
83 #ifdef TEMPORARY_MAP_DB 91 G_debug(1,
"V1_close_nat(): copying attributes");
96 for (i = 0; i < ndblinks; i++) {
112 Map->
dblnk = dblinks;
121 G_debug(1,
"V1_close_nat(): temporary map <%s> TO BE DELETED", Map->
name);
125 G_debug(1,
"V1_close_nat(): temporary map <%s> IS NOT DELETED",
130 else if (Map->
temporary == TEMPORARY_MAP) {
131 G_debug(1,
"V1_close_nat(): temporary map <%s> TO BE DELETED", Map->
name);
142 #ifndef TEMPORARY_MAP_DB 155 for (i = 0; i < ndblinks; i++) {
159 if (driver ==
NULL) {
160 G_warning(
_(
"Unable to open database <%s> by driver <%s>"),
dbDriver * db_start_driver_open_database(const char *drvname, const char *dbname)
Open driver/database connection.
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
char * name
Map name (for 4.0)
int db_copy_table(const char *from_drvname, const char *from_dbname, const char *from_tblname, const char *to_drvname, const char *to_dbname, const char *to_tblname)
Copy a table.
void G_free(void *buf)
Free allocated memory.
char * Vect__get_element_path(char *file_path, const struct Map_info *Map, const char *element)
Get map element full path (internal use only)
#define GV_DIRECTORY
Name of vector directory.
int G_mkdir(const char *path)
Creates a new directory.
off_t size
Total size (in bytes)
char * table
Name of DB table.
int Vect_get_num_dblinks(const struct Map_info *Map)
Get number of defined dblinks.
int G_recursive_copy(const char *src, const char *dst)
Copy recursively source directory to destination directory.
int V1_close_nat(struct Map_info *Map)
Close vector map.
#define GV_MODE_RW
Read-write vector map open mode.
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
Layer (old: field) information.
#define VECT_OPEN(Map)
Check if vector map is open.
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
char * name
Layer name (optional)
int Vect_add_dblink(struct dblinks *p, int number, const char *name, const char *table, const char *key, const char *db, const char *driver)
Add new DB connection to dblinks structure.
int G_debug(int level, const char *msg,...)
Print debugging message.
int Vect_coor_info(const struct Map_info *Map, struct Coor_info *Info)
Update Coor_info structure.
const struct driver * driver
void dig_file_free(struct gvfile *file)
Free struct gvfile.
int G_recursive_remove(const char *path)
Recursively remove all files in given directory.
int db_get_connection(dbConnection *connection)
Get default DB connection settings for the current mapset.
char * mapset
Mapset name.
int Vect_write_dblinks(struct Map_info *Map)
Write dblinks to file.
struct dig_head head
Header info.
off_t size
Coor file size.
struct field_info * Vect_get_dblink(const struct Map_info *Map, int link)
Get information about link to database.
struct dblinks * dblnk
Array of DB links.
char * driver
Name of DB driver ('sqlite', 'dbf', ...)
FILE * file
File descriptor.
int temporary
Temporary map flag.
int db_set_string(dbString *x, const char *s)
Inserts string to dbString (enlarge string)
struct gvfile dig_fp
GV file pointer (native format only)
int db_drop_table(dbDriver *driver, dbString *name)
Drop table.
struct dblinks * Vect_new_dblinks_struct(void)
Create and init new dblinks structure.
#define GV_MODE_WRITE
Write vector map open mode.
int dig__write_head(struct Map_info *)
void G_warning(const char *msg,...)
Print a warning message to stderr.
void db_init_string(dbString *x)
Initialize dbString.
char * key
Name of key column (usually 'cat')