Browse Source

Simplified default configuration file path logic

git-svn-id: https://svn.microneil.com/svn/SNF4CGP/trunk@47 59e8e3e7-56fa-483b-b4b4-fa6ab0af3dfc
master
madscientist 15 years ago
parent
commit
aa7601fc0a
1 changed files with 2 additions and 8 deletions
  1. 2
    8
      SNF4CGP/main.cpp

+ 2
- 8
SNF4CGP/main.cpp View File

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;
} }

Loading…
Cancel
Save