From 093960be317525ae72929fbb2f2bb3cdf949744d Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 16 Jul 2001 19:17:58 +0000 Subject: [PATCH] Check for the proper version of the base package and exit gracefully if not found. --- src/Main/fg_init.cxx | 24 ++++++++++++++++++++++++ src/Main/fg_init.hxx | 14 ++++++++++++++ src/Main/main.cxx | 8 ++++++++ 3 files changed, 46 insertions(+) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 5f72d1930..58fa1f1b5 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -181,6 +181,30 @@ bool fgInitFGRoot ( int argc, char **argv ) { } +// Return the current base package version +string fgBasePackageVersion() { + SGPath base_path( globals->get_fg_root() ); + base_path.append("version"); + + sg_gzifstream in( base_path.str() ); + if ( !in.is_open() ) { + SGPath old_path( globals->get_fg_root() ); + old_path.append( "Thanks" ); + sg_gzifstream old( old_path.str() ); + if ( !old.is_open() ) { + return "[none found]"; + } else { + return "[old version, please upgrade]"; + } + } + + string version; + in >> version; + + return version; +} + + // Read in configuration (file and command line) bool fgInitConfig ( int argc, char **argv ) { diff --git a/src/Main/fg_init.hxx b/src/Main/fg_init.hxx index a0ef346af..ea53fdb8b 100644 --- a/src/Main/fg_init.hxx +++ b/src/Main/fg_init.hxx @@ -31,13 +31,27 @@ #endif +#ifdef HAVE_CONFIG +# include +#endif + +#include + +#include STL_STRING + #include +SG_USING_STD(string); + // Read in configuration (file and command line) and just set fg_root bool fgInitFGRoot ( int argc, char **argv ); +// Return the current base package version +string fgBasePackageVersion(); + + // Read in configuration (file and command line) bool fgInitConfig ( int argc, char **argv ); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 0ef9568f1..1122fb2e1 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -1481,6 +1481,14 @@ int main( int argc, char **argv ) { // fg_root was specified (ignore all other options for now) fgInitFGRoot(argc, argv); + // Check for the correct base package version + string base_version = fgBasePackageVersion(); + if ( !(base_version == "0.7.9") ) { + SG_LOG( SG_GENERAL, SG_ALERT, "Base package check failed ... " + << base_version); + exit(-1); + } + // Initialize the Aircraft directory to "" (UIUC) aircraft_dir = ""; -- 2.39.5