|
|
|
|
|
|
|
|
const int MaxArgcNumber = 2;
|
|
|
const int MaxArgcNumber = 2;
|
|
|
const string DefaultConfigFile = "snf_engine.xml";
|
|
|
const string DefaultConfigFile = "snf_engine.xml";
|
|
|
|
|
|
|
|
|
#if defined(WIN32) || defined(WIN64)
|
|
|
|
|
|
const string PathSep = "\\";
|
|
|
|
|
|
#else
|
|
|
|
|
|
const string PathSep = "/";
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
bool CommandLineIsValid(int argc, char*argv[]) { // Validate the command line.
|
|
|
bool CommandLineIsValid(int argc, char*argv[]) { // Validate the command line.
|
|
|
if(argc > MaxArgcNumber) {
|
|
|
if(argc > MaxArgcNumber) {
|
|
|
cout << "* CGPSNF - Bad command line. Use:" << endl
|
|
|
cout << "* CGPSNF - Bad command line. Use:" << endl
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
string ConfigPathFromArgv0(const string Argv0) { // Return the config file name in
|
|
|
string ConfigPathFromArgv0(const string Argv0) { // Return the config file name in
|
|
|
// the same directory as the executable.
|
|
|
|
|
|
string::size_type LastSlashIndex = Argv0.find_last_of(PathSep);
|
|
|
|
|
|
|
|
|
const string Slashes = "/\\"; // the same directory as the executable.
|
|
|
|
|
|
string::size_type LastSlashIndex = Argv0.find_last_of(Slashes);
|
|
|
if (string::npos == LastSlashIndex) { // If there's no slash in the path...
|
|
|
if (string::npos == LastSlashIndex) { // If there's no slash in the path...
|
|
|
return DefaultConfigFile;
|
|
|
return DefaultConfigFile;
|
|
|
}
|
|
|
}
|