| 260 | } |
| 261 | |
| 262 | void RewriteSegmentationResourcesToAbsolute( |
| 263 | JSONValue& node, JSONDocument::AllocatorType& allocator, |
| 264 | const std::string& source_config_directory) { |
| 265 | if (node.IsObject()) { |
| 266 | auto segmentation_member = node.FindMember("segmentation"); |
| 267 | if (segmentation_member != node.MemberEnd() && |
| 268 | segmentation_member->value.IsObject()) { |
| 269 | auto resources_member = |
| 270 | segmentation_member->value.FindMember("resources"); |
| 271 | if (resources_member != segmentation_member->value.MemberEnd() && |
| 272 | resources_member->value.IsObject()) { |
| 273 | for (auto it = resources_member->value.MemberBegin(); |
| 274 | it != resources_member->value.MemberEnd(); ++it) { |
| 275 | if (!it->value.IsString()) { |
| 276 | continue; |
| 277 | } |
| 278 | const std::string resource_path = it->value.GetString(); |
| 279 | if (IsAbsolutePath(resource_path)) { |
| 280 | continue; |
| 281 | } |
| 282 | const std::string absolute_path = ResolveSegmentationResourcePath( |
| 283 | source_config_directory, resource_path); |
| 284 | it->value.SetString( |
| 285 | absolute_path.c_str(), |
| 286 | static_cast<rapidjson::SizeType>(absolute_path.size()), allocator); |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | for (auto it = node.MemberBegin(); it != node.MemberEnd(); ++it) { |
| 292 | RewriteSegmentationResourcesToAbsolute(it->value, allocator, |
| 293 | source_config_directory); |
| 294 | } |
| 295 | return; |
| 296 | } |
| 297 | |
| 298 | if (node.IsArray()) { |
| 299 | for (auto& child : node.GetArray()) { |
| 300 | RewriteSegmentationResourcesToAbsolute(child, allocator, |
| 301 | source_config_directory); |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | std::string ReadFile(const std::string& path) { |
| 307 | std::ifstream stream(path.c_str(), std::ios::binary); |
no test coverage detected