| 157 | } |
| 158 | |
| 159 | void Settings::updateSearchPaths(const nlohmann::json& update) |
| 160 | { |
| 161 | if (update.is_null() || !update.is_object()) |
| 162 | return; |
| 163 | for (auto& updateIt : update.items()) |
| 164 | { |
| 165 | auto processPath = [this](std::string_view searchKind, std::string_view category, const std::vector<std::string>& pathUpdates) |
| 166 | { |
| 167 | if (pathUpdates.empty()) |
| 168 | return; |
| 169 | |
| 170 | if (searchKind == "standardsearchpath") |
| 171 | { |
| 172 | std::vector<std::filesystem::path>& current = mStandardSearchDirectories[std::string(category)]; |
| 173 | ResolvedPaths result = resolveSearchPaths(current, pathUpdates, std::vector<std::filesystem::path>()); |
| 174 | FALCOR_CHECK( |
| 175 | result.invalid.empty(), |
| 176 | "While processing {}:{}, found invalid paths: {}", |
| 177 | searchKind, |
| 178 | category, |
| 179 | joinStrings(result.invalid, ", ") |
| 180 | ); |
| 181 | current = std::move(result.resolved); |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | if (searchKind == "searchpath") |
| 186 | { |
| 187 | std::vector<std::filesystem::path>& current = mSearchDirectories[std::string(category)]; |
| 188 | auto it = mStandardSearchDirectories.find(std::string(category)); |
| 189 | |
| 190 | ResolvedPaths result; |
| 191 | if (it == mStandardSearchDirectories.end()) |
| 192 | result = resolveSearchPaths(current, pathUpdates, std::vector<std::filesystem::path>()); |
| 193 | else |
| 194 | result = resolveSearchPaths(current, pathUpdates, it->second); |
| 195 | FALCOR_CHECK( |
| 196 | result.invalid.empty(), |
| 197 | "While processing {}:{}, found invalid paths: {}", |
| 198 | searchKind, |
| 199 | category, |
| 200 | joinStrings(result.invalid, ", ") |
| 201 | ); |
| 202 | current = std::move(result.resolved); |
| 203 | } |
| 204 | }; |
| 205 | |
| 206 | if ((updateIt.key() == "searchpath" || updateIt.key() == "standardsearchpath") && updateIt.value().is_object()) |
| 207 | { |
| 208 | for (auto& kindIt : updateIt.value().items()) |
| 209 | { |
| 210 | std::vector<std::string> pathUpdates = toStrings(kindIt.value()); |
| 211 | processPath(updateIt.key(), kindIt.key(), pathUpdates); |
| 212 | } |
| 213 | continue; |
| 214 | } |
| 215 | |
| 216 | // Check for `searchpath:foo` or `standardsearchpath:foo` |
nothing calls this directly
no test coverage detected