| 269 | } |
| 270 | |
| 271 | static bool load_file(const std::filesystem::path & path, int entity_id) { |
| 272 | Json::Value json; |
| 273 | try { |
| 274 | std::ifstream file(path); |
| 275 | file >> json; |
| 276 | } catch (std::exception &) { |
| 277 | // empty file? |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | if (json.isArray()) { |
| 282 | auto & entity_store_entry = store[entity_id]; |
| 283 | for (auto & value : json) { |
| 284 | std::shared_ptr<Persistence::DataEntry> entry(new Persistence::DataEntry(entity_id, value)); |
| 285 | if (entry->key.empty()) |
| 286 | continue; |
| 287 | // ensure fake DF IDs remain globally unique |
| 288 | next_fake_df_id = std::min(next_fake_df_id, entry->fake_df_id - 1); |
| 289 | add_entry(entity_store_entry, entry); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | return true; |
| 294 | } |
| 295 | |
| 296 | void Persistence::Internal::load(color_ostream& out) { |
| 297 | CoreSuspender suspend; |