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

Function write_data_index

src/resource/data_compiler.cpp:458–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456}
457
458static 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
488static s32 write_data_versions(FilesystemDisk &data_fs
489 , const char *filename

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