MCPcopy Create free account
hub / github.com/WiVRn/WiVRn / write_cache_entry

Function write_cache_entry

client/render/scene_loader.cpp:1249–1265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1247}
1248
1249static void write_cache_entry(const std::filesystem::path & path, const cache_entry & entry)
1250{
1251 std::ofstream json{path / "index.json"};
1252 json << "{\"filename\":" << json_string(entry.filename);
1253 json << ",\"size\":" << entry.size;
1254
1255 // TODO get a timestamp for assets
1256 if (not entry.filename.starts_with("assets://"))
1257 {
1258 auto mtime = std::chrono::file_clock::to_sys(std::filesystem::last_write_time(entry.filename));
1259 auto timestamp = std::chrono::duration_cast<std::chrono::seconds>(mtime.time_since_epoch()).count();
1260 auto size = entry.size;
1261
1262 json << ",\"timestamp\":" << timestamp;
1263 }
1264 json << "}";
1265}
1266
1267// Returns false if the cache is out of date and must be deleted
1268static bool check_cache_entry(const std::filesystem::path & path)

Callers 1

operator()Method · 0.85

Calls 2

json_stringFunction · 0.85
countMethod · 0.45

Tested by

no test coverage detected