32#include "local_proto.h"
79static int copy_file(
const char *src,
const char *dst)
98 while ((len =
read(fd, buf, 4096)) > 0) {
107 if (len == -1 ||
len2 == -1)
131 const char *
files[] = {
156 G_warning(
_(
"Vector map <%s> already exists and will be overwritten"),
242 G_debug(2,
"Rename vector '%s' to '%s'", in,
out);
249 G_warning(
_(
"Vector map <%s> already exists and will be overwritten"),
263 G_warning(
_(
"Vector map <%s> not found"), in);
266 else if (
ret == -1) {
267 G_warning(
_(
"Unable to copy vector map <%s> to <%s>"), in,
out);
288 fields = (
int *)
G_malloc(n *
sizeof(
int));
290 for (i = 0; i < n; i++) {
292 fields[i] =
Fin->number;
295 for (i = 0; i < n; i++) {
296 G_debug(3,
"field[%d] = %d", i, fields[i]);
300 G_warning(
_(
"Database connection not defined for layer %d"),
307 G_debug(3,
"Copy drv:db:table '%s:%s:%s' to '%s:%s:%s'",
Fin->driver,
339 G_warning(
_(
"Unable to open database <%s> by driver <%s>"),
344 G_warning(
_(
"Unable to create index for table <%s>, key <%s>"),
386 const char *tmp, *mapset, *env;
405 G_warning(
_(
"Invalid vector map name <%s>"), map ? map :
"null");
415 G_warning(
_(
"Unable to open header file for vector map <%s>"), map);
430 for (i = 0; i < n; i++) {
433 G_warning(
_(
"Database connection not defined for layer %d"),
434 Map.dblnk->field[i].number);
441 G_debug(3,
"Delete drv:db:table '%s:%s:%s'",
Fi->driver,
442 Fi->database,
Fi->table);
446 G_warning(
_(
"Unable to find table <%s> linked to vector "
468 G_warning(
_(
"Table <%s> linked to vector map <%s> does not "
508 env =
getenv(
"GRASS_VECTOR_TMPDIR_MAPSET");
509 if (env &&
strcmp(env,
"0") == 0) {
521 G_warning(
_(
"Unable to rename directory '%s' to '%s'"),
path, tmp);
526 G_debug(3,
"remove directory '%s'", tmp);
530 G_warning(
_(
"Unable to remove directory '%s': %s"), tmp,
547 Map->plus.release_support =
TRUE;
AMI_err name(char **stream_name)
Main header of GRASS DataBase Management Interface.
int db_delete_table(const char *, const char *, const char *)
Delete table.
int db_close_database_shutdown_driver(dbDriver *)
Close driver/database connection.
int db_create_index2(dbDriver *, const char *, const char *)
Create unique index.
int db_table_exists(const char *, const char *, const char *)
Check if table exists.
dbDriver * db_start_driver_open_database(const char *, const char *)
Open driver/database connection.
int db_copy_table(const char *, const char *, const char *, const char *, const char *, const char *)
Copy a table.
int G_name_is_fully_qualified(const char *, char *, char *)
Check if map name is fully qualified (map @ mapset)
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
int G_make_mapset_dir_object(const char *, const char *)
Create directory for an object of a given type.
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
char * G_tempfile(void)
Returns a temporary file name.
int G_debug(int, const char *,...) __attribute__((format(printf
const char * G_find_vector2(const char *, const char *)
Find a vector map (look but don't touch)
const char * G_mapset(void)
Get current mapset name.
int G_rename(const char *, const char *, const char *)
Rename a database file.
struct field_info * Vect_default_field_info(struct Map_info *, int, const char *, int)
Get default information about link to database for new dblink.
char * Vect_subst_var(const char *, struct Map_info *)
Substitute variable in string.
int Vect_map_del_dblink(struct Map_info *, int)
Delete db connection from Map_info structure.
int Vect_close(struct Map_info *)
Close vector map.
struct field_info * Vect_get_field(struct Map_info *, int)
Get information about link to database (by layer number)
int Vect_open_update_head(struct Map_info *, const char *, const char *)
Open header file of existing vector map for updating (mostly for database link updates)
int Vect_legal_filename(const char *)
Check if output is legal vector name.
struct field_info * Vect_get_dblink(struct Map_info *, int)
Get information about link to database.
int Vect_get_num_dblinks(struct Map_info *)
Get number of defined dblinks.
int Vect_map_add_dblink(struct Map_info *, int, const char *, const char *, const char *, const char *, const char *)
Add new db connection to Map_info structure.
int Vect_set_open_level(int)
Predetermine level at which a vector map will be opened for reading.
int Vect_open_old_head(struct Map_info *, const char *, const char *)
Reads only info about vector map (headers)
int Vect_copy_tables(struct Map_info *, struct Map_info *, int)
Copy attribute tables linked to vector map.
#define GV_FRMT_ELEMENT
Format description, data location (OGR)
#define GV_DIRECTORY
Name of vector directory.
#define GV_SIDX_ELEMENT
Native format, spatial index.
#define GV_1TABLE
One table linked to vector map.
#define GV_COOR_ELEMENT
Native format, coordinates.
#define GV_DBLN_ELEMENT
Native format, link to database.
#define GV_CIDX_ELEMENT
Native format, category index.
#define GV_TOPO_ELEMENT
Native format, topology file.
#define GV_MTABLE
More tables linked to vector map.
#define GV_HEAD_ELEMENT
Native format, header information.
#define GV_FORMAT_NATIVE
Geometry data formats supported by lib Don't change GV_FORMAT_* values, this order is hardcoded in li...
#define GV_HIST_ELEMENT
Native format, history file.
Header file for msvc/fcntl.c.
void Vect_set_category_index_update(struct Map_info *Map)
Set category index to be updated when vector is changed.
void Vect_destroy_map_struct(struct Map_info *p)
Frees all memory associated with a Map_info structure, including the structure itself.
int Vect__delete(const char *map, int is_tmp)
Delete vector map (internal use only)
int Vect_rename(const char *in, const char *out)
Rename existing vector map (in the current mapset).
int Vect_copy(const char *in, const char *mapset, const char *out)
Copy vector map including attribute tables.
struct Map_info * Vect_new_map_struct(void)
Creates and initializes Map_info structure.
void Vect_set_release_support(struct Map_info *Map)
Set spatial index to be released when vector is closed.
int Vect_delete(const char *map)
Delete vector map including attribute tables.
DIR * opendir(const char *name)
struct dirent * readdir(DIR *dir)
char * mapset
Mapset name.
int type
Feature type constraint.
int format
Map format (native, ogr, postgis)
Layer (old: field) information.
char * driver
Name of DB driver ('sqlite', 'dbf', ...)
int Vect__open_old(struct Map_info *Map, const char *name, const char *mapset, const char *layer, int update, int head_only, int is_tmp)
Open existing vector map for reading (internal use only)
char * Vect__get_element_path(char *file_path, struct Map_info *Map, const char *element)
Get map element full path (internal use only)