| 446 | }; |
| 447 | |
| 448 | std::unique_ptr<Object> CreateObjectFromZipFile(std::string_view path, bool loadImages) |
| 449 | { |
| 450 | try |
| 451 | { |
| 452 | auto archive = Zip::Open(path, ZipAccess::read); |
| 453 | auto jsonBytes = archive->GetFileData("object.json"); |
| 454 | if (jsonBytes.empty()) |
| 455 | { |
| 456 | throw std::runtime_error("Unable to open object.json."); |
| 457 | } |
| 458 | |
| 459 | json_t jRoot = Json::FromVector(jsonBytes); |
| 460 | |
| 461 | if (jRoot.is_object()) |
| 462 | { |
| 463 | auto fileDataRetriever = ZipDataRetriever(path, *archive); |
| 464 | return CreateObjectFromJson(jRoot, &fileDataRetriever, loadImages, path); |
| 465 | } |
| 466 | } |
| 467 | catch (const std::exception& e) |
| 468 | { |
| 469 | Console::Error::WriteLine("Unable to open or read '%s': %s", std::string(path).c_str(), e.what()); |
| 470 | } |
| 471 | return nullptr; |
| 472 | } |
| 473 | |
| 474 | std::unique_ptr<Object> CreateObjectFromJsonFile(const std::string& path, bool loadImages) |
| 475 | { |
no test coverage detected