MCPcopy Create free account
hub / github.com/crownengine/crown / write_data_mtimes

Function write_data_mtimes

src/resource/data_compiler.cpp:523–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

521}
522
523static 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
553static 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{

Callers 1

compile_internalMethod · 0.85

Calls 9

open_temporaryMethod · 0.80
from_string_idMethod · 0.80
beginFunction · 0.50
endFunction · 0.50
is_openMethod · 0.45
c_strMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
renameMethod · 0.45

Tested by

no test coverage detected