* Parse the command line to get the configuration file path. */
| 538 | * Parse the command line to get the configuration file path. |
| 539 | */ |
| 540 | bool ParseCommandLine(LPWSTR lpCmdLine, ConfigInfo &config, std::ofstream &log) |
| 541 | { |
| 542 | if (__argc <= 1) |
| 543 | { |
| 544 | // There is one argument (or less) - just the executable path |
| 545 | // Exit since a configuration file is not specified |
| 546 | log << "Error: a configuration file must be specified!\n"; |
| 547 | return false; |
| 548 | } |
| 549 | |
| 550 | if (__argc > 2) |
| 551 | { |
| 552 | // There are more than two arguments (executable + configuration file) |
| 553 | // Exit since there must be a single argument after the executable path |
| 554 | log << "Error: incorrect command line usage! A single argument (the configuration file) must be specified.\n"; |
| 555 | return false; |
| 556 | } |
| 557 | |
| 558 | size_t len; |
| 559 | size_t max = wcslen(__wargv[1]) + 1; |
| 560 | char* dst = new char[max]; |
| 561 | |
| 562 | wcstombs_s(&len, dst, max, __wargv[1], max); |
| 563 | config.filepath = std::string(dst); |
| 564 | |
| 565 | delete[] dst; |
| 566 | |
| 567 | return true; |
| 568 | } |
| 569 | |
| 570 | } |