From 44fdf77601270749ad4029a6431343da1e513cf2 Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 11 Jul 2008 20:55:43 +0000 Subject: [PATCH] "load"/"save" flight: enforce ".sav" extension --- src/Main/fg_commands.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index b4b07ddce..50e46ad9a 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -320,7 +320,9 @@ do_resume (const SGPropertyNode * arg) static bool do_load (const SGPropertyNode * arg) { - const string &file = arg->getStringValue("file", "fgfs.sav"); + string file = arg->getStringValue("file", "fgfs.sav"); + if (file.size() < 4 || file.substr(file.size() - 4) != ".sav") + file += ".sav"; if (!fgValidatePath(file.c_str(), false)) { SG_LOG(SG_IO, SG_ALERT, "load: reading '" << file << "' denied " @@ -349,7 +351,9 @@ do_load (const SGPropertyNode * arg) static bool do_save (const SGPropertyNode * arg) { - const string &file = arg->getStringValue("file", "fgfs.sav"); + string file = arg->getStringValue("file", "fgfs.sav"); + if (file.size() < 4 || file.substr(file.size() - 4) != ".sav") + file += ".sav"; if (!fgValidatePath(file.c_str(), false)) { SG_LOG(SG_IO, SG_ALERT, "save: reading '" << file << "' denied "