| 456 | } |
| 457 | |
| 458 | static s32 write_data_index(FilesystemDisk &data_fs, const char *filename, const HashMap<StringId64, DynamicString> &index) |
| 459 | { |
| 460 | StringStream ss(default_allocator()); |
| 461 | DynamicString temp_filename(default_allocator()); |
| 462 | |
| 463 | File *file = data_fs.open_temporary(temp_filename); |
| 464 | if (file->is_open()) { |
| 465 | auto cur = hash_map::begin(index); |
| 466 | auto end = hash_map::end(index); |
| 467 | for (; cur != end; ++cur) { |
| 468 | HASH_MAP_SKIP_HOLE(index, cur); |
| 469 | |
| 470 | TempAllocator256 ta; |
| 471 | DynamicString str(ta); |
| 472 | str.from_string_id(cur->first); |
| 473 | ss << "\"" << str.c_str() << "\" = \"" << cur->second.c_str() << "\"\n"; |
| 474 | } |
| 475 | |
| 476 | u32 ss_len = strlen32(string_stream::c_str(ss)); |
| 477 | if (ss_len != file->write(string_stream::c_str(ss), ss_len)) { |
| 478 | data_fs.close(*file); |
| 479 | return -1; |
| 480 | } |
| 481 | } |
| 482 | data_fs.close(*file); |
| 483 | |
| 484 | RenameResult rr = data_fs.rename(temp_filename.c_str(), filename); |
| 485 | return rr.error == RenameResult::SUCCESS ? 0 : -1; |
| 486 | } |
| 487 | |
| 488 | static s32 write_data_versions(FilesystemDisk &data_fs |
| 489 | , const char *filename |
no test coverage detected