static bool
do_exit (const SGPropertyNode * arg)
{
- SG_LOG(SG_INPUT, SG_INFO, "Program exit requested.");
- fgExit(arg->getIntValue("status", 0));
- return true;
+ SG_LOG(SG_INPUT, SG_INFO, "Program exit requested.");
+
+ char* envp = ::getenv( "HOME" );
+ if ( envp != NULL ) {
+ SGPath config( globals->get_fg_root() );
+ config.set( envp );
+ config.append( ".fgfs" );
+ config.append( "preferences.xml" );
+ config.create_dir( 0700 );
+ SG_LOG(SG_IO, SG_INFO, "Saving user preferences");
+ try {
+ writeProperties(config.str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
+ } catch (const sg_exception &e) {
+ guiErrorMessage("Error saving preferences: ", e);
+ }
+
+ SG_LOG(SG_INPUT, SG_BULK, "Finished Saving user preferences");
+ }
+ fgExit(arg->getIntValue("status", 0));
+ return true;
}
SG_LOG( SG_INPUT, SG_ALERT, "No default aircraft specified" );
}
+
+ char* envp = ::getenv( "HOME" );
+ if ( envp != NULL ) {
+ SGPath config( globals->get_fg_root() );
+ config.set( envp );
+ config.append( ".fgfs" );
+ config.append( "preferences.xml" );
+ SG_LOG(SG_INPUT, SG_INFO, "Reading user preferences");
+ fgLoadProps(config.str().c_str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
+ SG_LOG(SG_INPUT, SG_BULK, "Finished Reading user preferences");
+ }
+
// parse options after loading aircraft to ensure any user
// overrides of defaults are honored.
do_options(argc, argv);
bool
-fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root)
+fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root, int default_mode)
{
string fullpath;
if (in_fg_root) {
}
try {
- readProperties(fullpath, props);
+ readProperties(fullpath, props, default_mode);
} catch (const sg_exception &e) {
guiErrorMessage("Error reading properties: ", e);
return false;
* otherwise.
*/
extern bool fgLoadProps (const char * path, SGPropertyNode * props,
- bool in_fg_root = true);
+ bool in_fg_root = true, int default_mode = 0);
\f