| 78 | } |
| 79 | |
| 80 | static void FillValidSearchPaths(bool only_local_path) |
| 81 | { |
| 82 | _valid_searchpaths.clear(); |
| 83 | |
| 84 | std::set<std::string> seen{}; |
| 85 | for (Searchpath sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) { |
| 86 | if (sp == SP_WORKING_DIR && !_do_scan_working_directory) continue; |
| 87 | |
| 88 | if (only_local_path) { |
| 89 | switch (sp) { |
| 90 | case SP_WORKING_DIR: // Can be influence by "-c" option. |
| 91 | case SP_BINARY_DIR: // Most likely contains all the language files. |
| 92 | case SP_AUTODOWNLOAD_DIR: // Otherwise we cannot download in-game content. |
| 93 | break; |
| 94 | |
| 95 | default: |
| 96 | continue; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | if (IsValidSearchPath(sp)) { |
| 101 | if (seen.count(_searchpaths[sp]) != 0) continue; |
| 102 | seen.insert(_searchpaths[sp]); |
| 103 | _valid_searchpaths.emplace_back(sp); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | /* The working-directory is special, as it is controlled by _do_scan_working_directory. |
| 108 | * Only add the search path if it isn't already in the set. To preserve the same order |
| 109 | * as the enum, insert it in the front. */ |
| 110 | if (IsValidSearchPath(SP_WORKING_DIR) && seen.count(_searchpaths[SP_WORKING_DIR]) == 0) { |
| 111 | _valid_searchpaths.insert(_valid_searchpaths.begin(), SP_WORKING_DIR); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Check whether the given file exists |
no test coverage detected