| 521 | } |
| 522 | |
| 523 | static s32 write_data_mtimes(FilesystemDisk &data_fs, const char *filename, const HashMap<StringId64, u64> &mtimes) |
| 524 | { |
| 525 | StringStream ss(default_allocator()); |
| 526 | DynamicString temp_filename(default_allocator()); |
| 527 | |
| 528 | File *file = data_fs.open_temporary(temp_filename); |
| 529 | if (file->is_open()) { |
| 530 | auto cur = hash_map::begin(mtimes); |
| 531 | auto end = hash_map::end(mtimes); |
| 532 | for (; cur != end; ++cur) { |
| 533 | HASH_MAP_SKIP_HOLE(mtimes, cur); |
| 534 | |
| 535 | TempAllocator64 ta; |
| 536 | DynamicString key(ta); |
| 537 | key.from_string_id(cur->first); |
| 538 | ss << "\"" << key.c_str() << "\" = \"" << cur->second << "\"\n"; |
| 539 | } |
| 540 | |
| 541 | u32 ss_len = strlen32(string_stream::c_str(ss)); |
| 542 | if (ss_len != file->write(string_stream::c_str(ss), ss_len)) { |
| 543 | data_fs.close(*file); |
| 544 | return -1; |
| 545 | } |
| 546 | } |
| 547 | data_fs.close(*file); |
| 548 | |
| 549 | RenameResult rr = data_fs.rename(temp_filename.c_str(), filename); |
| 550 | return rr.error == RenameResult::SUCCESS ? 0 : -1; |
| 551 | } |
| 552 | |
| 553 | static s32 write_data_dependencies(FilesystemDisk &data_fs, const char *filename, const HashMap<StringId64, DynamicString> &index, const HashMap<StringId64, HashMap<DynamicString, u32>> &dependencies, const HashMap<StringId64, HashMap<DynamicString, u32>> &requirements) |
| 554 | { |
no test coverage detected