summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-12 23:35:52 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-12 23:35:52 -0800
commitd4f2b7214863b2a40ebcf69e7add113412f795b8 (patch)
treea0f1210a109371e69f83a283f8583c3ba6304c6a /save-xml.c
parentae49a8a4f7c277644a62b096585ee467f3cad5c7 (diff)
downloadsubsurface-d4f2b7214863b2a40ebcf69e7add113412f795b8.tar.gz
Make special backup when switching XML versions
Since the last few dozen commits change the format in irreversible ways and could therefore be destructive and lose data for testers of the development version, let's try to be extra careful and create "special" backup files that aren't overwritten by subsequent backups. At least this way people can go back to the previous state. Of course people using the git backend don't have to worry about this as they always can go back to any earlier save. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/save-xml.c b/save-xml.c
index dad57dc9b..5a0c6976c 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -591,7 +591,15 @@ static void try_to_backup(const char *filename)
while (extension[i][0] != '\0') {
int elen = strlen(extension[i]);
if (strcasecmp(filename + flen - elen, extension[i]) == 0) {
- save_backup(filename, extension[i], "bak");
+ if (last_xml_version < VERSION) {
+ int se_len = strlen(extension[i]) + 5;
+ char *special_ext = malloc(se_len);
+ snprintf(special_ext, se_len, "%s.v%d", extension[i], last_xml_version);
+ save_backup(filename, extension[i], special_ext);
+ free(special_ext);
+ } else {
+ save_backup(filename, extension[i], "bak");
+ }
break;
}
i++;