summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-16 15:19:24 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-16 15:58:13 -0800
commit6424b162f0f3ce74cd0d219efff52829c452d73c (patch)
tree418749d0c04cecf872ba78489ddb1818ae00038c /save-xml.c
parent90dddeb4cc90093ab42687bbda7cd7a5428355c2 (diff)
downloadsubsurface-6424b162f0f3ce74cd0d219efff52829c452d73c.tar.gz
Allow backups for .ssrf files as well
In commit 102bf768944b ("Rename old 'xml' file as 'bak' file when saving") Linus forgot about our other standard filename extension... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/save-xml.c b/save-xml.c
index a95487313..8712592bc 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -613,10 +613,20 @@ void save_dives_logic(const char *filename, const bool select_only)
{
struct membuffer buf = {0};
FILE *f;
+ char extension[][5] = {"xml", "ssrf", ""};
+ int i = 0;
+ int flen = strlen(filename);
save_dives_buffer(&buf, select_only);
/* Maybe we might want to make this configurable? */
- save_backup(filename, "xml", "bak");
+ while (extension[i][0] != '\0') {
+ int elen = strlen(extension[i]);
+ if (strcasecmp(filename + flen - elen, extension[i]) == 0) {
+ save_backup(filename, extension[i], "bak");
+ break;
+ }
+ i++;
+ }
f = subsurface_fopen(filename, "w");
if (f) {
flush_buffer(&buf, f);