22 #include <sys/types.h>
25 #include <grass/Vect.h>
26 #include <grass/gis.h>
27 #include <grass/glocale.h>
29 static char name_buf[GPATH_MAX];
30 static int check_coor(
struct Map_info *
Map);
47 G_debug(1,
"V1_open_old_nat(): name = %s mapset = %s", Map->name,
50 sprintf(buf,
"%s/%s", GRASS_VECT_DIRECTORY, Map->name);
56 G_fopen_old(buf, GRASS_VECT_COOR_ELEMENT, Map->mapset);
58 if (Map->dig_fp.file ==
NULL)
91 G_debug(1,
"V1_open_new_nat(): name = %s", name);
93 sprintf(buf,
"%s/%s", GRASS_VECT_DIRECTORY, name);
96 Map->head.Version_Major = GV_COOR_VER_MAJOR;
97 Map->head.Version_Minor = GV_COOR_VER_MINOR;
98 Map->head.Back_Major = GV_COOR_EARLIEST_MAJOR;
99 Map->head.Back_Minor = GV_COOR_EARLIEST_MINOR;
103 Map->dig_fp.file =
G_fopen_new(buf, GRASS_VECT_COOR_ELEMENT);
104 if (Map->dig_fp.file ==
NULL)
106 fclose(Map->dig_fp.file);
110 if (Map->dig_fp.file ==
NULL)
115 if (stat(name_buf, &info) == 0)
121 Map->head.head_size = GV_COOR_HEAD_SIZE;
134 int check_coor(
struct Map_info *
Map)
136 struct Coor_info CInfo;
140 dif = CInfo.size - Map->head.size;
141 G_debug(1,
"coor size in head = %ld, real coor file size= %ld",
142 Map->head.size, CInfo.size);
145 G_warning(_(
"Coor files of vector map <%s@%s> is larger than it should be "
146 "(%ld bytes excess)"), Map->name, Map->mapset, dif);
149 G_warning(_(
"Coor files of vector <%s@%s> is shorter than it should be "
150 "(%ld bytes missing)."), Map->name, Map->mapset, -dif);