| 462 | } |
| 463 | |
| 464 | TSTRING cTWUtil::GetCfgFilePath(const cCmdLineParser& cmdLine, int cfgFileID) |
| 465 | { |
| 466 | |
| 467 | TSTRING cfgFilePath; |
| 468 | bool fConfigOnCmdLine = false; |
| 469 | |
| 470 | // let's see if this was specified on the command line... |
| 471 | cCmdLineIter iter(cmdLine); |
| 472 | for (iter.SeekBegin(); !iter.Done(); iter.Next()) |
| 473 | { |
| 474 | if (iter.ArgId() == cfgFileID) |
| 475 | { |
| 476 | ASSERT(iter.NumParams() > 0); |
| 477 | cfgFilePath = iter.ParamAt(0); |
| 478 | fConfigOnCmdLine = true; |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | // OK, now we need to figure out where to find the config file. |
| 483 | // If the location was specified on the command line, get the full path to it. |
| 484 | // otherwise, the location is the dir that this exe is in. |
| 485 | if (fConfigOnCmdLine) |
| 486 | { |
| 487 | TSTRING pathOut; |
| 488 | iFSServices::GetInstance()->FullPath(pathOut, cfgFilePath); |
| 489 | cfgFilePath = pathOut; |
| 490 | } |
| 491 | else |
| 492 | { |
| 493 | iFSServices::GetInstance()->FullPath( |
| 494 | cfgFilePath, TSS_GetString(cTW, tw::STR_DEF_CFG_FILENAME), cSystemInfo::GetExeDir()); |
| 495 | } |
| 496 | |
| 497 | |
| 498 | cFileUtil::TestFileExists(cfgFilePath); |
| 499 | |
| 500 | |
| 501 | return (cfgFilePath); |
| 502 | } |
| 503 | |
| 504 | /////////////////////////////////////////////////////////////////////////////// |
| 505 | // OpenConfigFile -- opens the config file, either from a known location or |