Skip to content

Commit

Permalink
use solution 1
Browse files Browse the repository at this point in the history
  • Loading branch information
metzm committed Feb 28, 2024
1 parent 8fcb8ed commit 936bf39
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions lib/vector/Vlib/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,30 @@ int Vect__open_old(struct Map_info *Map, const char *name, const char *mapset,
Vect_rewind(Map);
}

/* DO NOT delete support files topo, sidx, cidx, fidx if native format
* was opened for update (not head_only)
* they will be deleted by Vect_close() if the map was actually updated */
/* delete support files if native format was opened for update (not
* head_only) */
if (update && !head_only) {
char file_path[GPATH_MAX];

Vect__get_element_path(file_path, Map, GV_TOPO_ELEMENT);
if (access(file_path, F_OK) == 0) /* topo file exists? */
unlink(file_path);

Vect__get_element_path(file_path, Map, GV_SIDX_ELEMENT);
if (access(file_path, F_OK) == 0) /* sidx file exists? */
unlink(file_path);

Vect__get_element_path(file_path, Map, GV_CIDX_ELEMENT);
if (access(file_path, F_OK) == 0) /* cidx file exists? */
unlink(file_path);

if (format == GV_FORMAT_OGR || format == GV_FORMAT_POSTGIS) {
Vect__get_element_path(file_path, Map, GV_FIDX_ELEMENT);
if (access(file_path, F_OK) == 0) /* fidx file exists? */
unlink(file_path);
}
Map->support_updated = TRUE;
}

return level;
}
Expand Down

0 comments on commit 936bf39

Please sign in to comment.