SGPath FGFCS::FindFullPathName(const SGPath& path) const { SGPath name = FGModel::FindFullPathName(path); if (systype != stSystem || !name.isNull()) return name; name = CheckPathName(FDMExec->GetFullAircraftPath()/string("Systems"), path); if (!name.isNull()) return name; return CheckPathName(FDMExec->GetSystemsPath(), path); }
bool options(int count, char **arg) { int i; bool result = true; if (count == 1) { PrintHelp(); exit(0); } cout.setf(ios_base::fixed); for (i=1; i<count; i++) { string argument = string(arg[i]); string keyword(argument); string value(""); string::size_type n=argument.find("="); if (n != string::npos && n > 0) { keyword = argument.substr(0, n); value = argument.substr(n+1); } if (keyword == "--help") { PrintHelp(); exit(0); } else if (keyword == "--version") { cout << endl << " JSBSim Version: " << FDMExec->GetVersion() << endl << endl; exit (0); } else if (keyword == "--realtime") { realtime = true; } else if (keyword == "--nice") { play_nice = true; if (n != string::npos) { try { sleep_period = atof( value.c_str() ); } catch (...) { cerr << endl << " Invalid sleep period given!" << endl << endl; result = false; } } else { sleep_period = 0.01; } } else if (keyword == "--suspend") { suspend = true; } else if (keyword == "--nohighlight") { nohighlight = true; } else if (keyword == "--outputlogfile") { if (n != string::npos) { LogOutputName.push_back(value); } } else if (keyword == "--logdirectivefile") { if (n != string::npos) { LogDirectiveName.push_back(SGPath::fromLocal8Bit(value.c_str())); } else { gripe; exit(1); } } else if (keyword == "--root") { if (n != string::npos) { RootDir = SGPath::fromLocal8Bit(value.c_str()); } else { gripe; exit(1); } } else if (keyword == "--aircraft") { if (n != string::npos) { AircraftName = value; } else { gripe; exit(1); } } else if (keyword == "--script") { if (n != string::npos) { ScriptName = SGPath::fromLocal8Bit(value.c_str()); } else { gripe; exit(1); } } else if (keyword == "--initfile") { if (n != string::npos) { ResetName = SGPath::fromLocal8Bit(value.c_str()); } else { gripe; exit(1); } } else if (keyword == "--property") { if (n != string::npos) { string propName = value.substr(0,value.find("=")); string propValueString = value.substr(value.find("=")+1); double propValue = atof(propValueString.c_str()); CommandLineProperties.push_back(propName); CommandLinePropertyValues.push_back(propValue); } else { gripe; exit(1); } } else if (keyword.substr(0,5) == "--end") { if (n != string::npos) { try { end_time = atof( value.c_str() ); } catch (...) { cerr << endl << " Invalid end time given!" << endl << endl; result = false; } } else { gripe; exit(1); } } else if (keyword == "--simulation-rate") { if (n != string::npos) { try { simulation_rate = atof( value.c_str() ); override_sim_rate = true; } catch (...) { cerr << endl << " Invalid simulation rate given!" << endl << endl; result = false; } } else { gripe; exit(1); } } else if (keyword == "--catalog") { catalog = true; if (value.size() > 0) AircraftName=value; } else if (keyword.substr(0,2) != "--" && value.empty() ) { // See what kind of files we are specifying on the command line XMLFile xmlFile; SGPath path = SGPath::fromLocal8Bit(keyword.c_str()); if (xmlFile.IsScriptFile(path)) ScriptName = path; else if (xmlFile.IsLogDirectiveFile(path)) LogDirectiveName.push_back(path); else if (xmlFile.IsAircraftFile(SGPath("aircraft")/keyword/keyword)) AircraftName = keyword; else if (xmlFile.IsInitFile(path)) ResetName = path; else if (xmlFile.IsInitFile(SGPath("aircraft")/AircraftName/keyword)) ResetName = SGPath("aircraft")/AircraftName/keyword; else { cerr << "The argument \"" << keyword << "\" cannot be interpreted as a file name or option." << endl; exit(1); } } else //Unknown keyword so print the help file, the bad keyword and abort { PrintHelp(); cerr << "The argument \"" << keyword << "\" cannot be interpreted as a file name or option." << endl; exit(1); } } // Post-processing for script options. check for incompatible options. if (catalog && !ScriptName.isNull()) { cerr << "Cannot specify catalog with script option" << endl << endl; result = false; } if (!AircraftName.empty() && ResetName.isNull() && !catalog) { cerr << "You must specify an initialization file with the aircraft name." << endl << endl; result = false; } if (!ScriptName.isNull() && !AircraftName.empty()) { cerr << "You cannot specify an aircraft file with a script." << endl; result = false; } return result; }