unix.c
changeset 1508 3f0d2f3147c2
parent 1495 c8a61d136f26
child 1509 2c232b7d2114
--- a/unix.c	Tue Mar 15 12:21:59 2005 +0000
+++ b/unix.c	Tue Mar 15 14:06:28 2005 +0000
@@ -324,10 +324,19 @@
 
 void FiosMakeSavegameName(char *buf, const char *name)
 {
+	const char* extension;
+	const char* period;
+
 	if (_game_mode == GM_EDITOR)
-		sprintf(buf, "%s/%s.scn", _fios_path, name);
+		extension = ".scn";
 	else
-		sprintf(buf, "%s/%s.sav", _fios_path, name);
+		extension = ".sav";
+
+	// Don't append the extension, if it is already there
+	period = strrchr(name, '.');
+	if (period != NULL && strcasecmp(period, extension) == 0) extension = "";
+
+	sprintf(buf, "%s/%s%s", _fios_path, name, extension);
 }
 
 void FiosDelete(const char *name)