MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / isCacheFresh

Method isCacheFresh

3ds/source/loader.cpp:385–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383}
384
385bool TitleCatalog::isCacheFresh(void)
386{
387 u8 hash[SHA256_BLOCK_SIZE];
388 calculateTitleDBHash(hash);
389
390 auto writeHash = [&] {
391 FSUSER_DeleteFile(Archive::sdmc(), fsMakePath(PATH_UTF16, titlesHashPath.data()));
392 FSStream output(Archive::sdmc(), titlesHashPath, FS_OPEN_WRITE, SHA256_BLOCK_SIZE);
393 output.write(hash, SHA256_BLOCK_SIZE);
394 output.close();
395 };
396
397 if (!io::fileExists(Archive::sdmc(), titlesHashPath) || !io::fileExists(Archive::sdmc(), saveCachePath) ||
398 !io::fileExists(Archive::sdmc(), extdataCachePath)) {
399 writeHash();
400 return false;
401 }
402
403 FSStream input(Archive::sdmc(), titlesHashPath, FS_OPEN_READ);
404 if (input.good() && input.size() == SHA256_BLOCK_SIZE) {
405 u8 buf[SHA256_BLOCK_SIZE];
406 input.read(buf, SHA256_BLOCK_SIZE);
407 input.close();
408 if (memcmp(hash, buf, SHA256_BLOCK_SIZE) == 0) {
409 return true;
410 }
411 writeHash();
412 }
413 return false;
414}
415
416void TitleCatalog::loadFromCache(std::vector<Title>& saves, std::vector<Title>& extdatas, IconStore& icons)
417{

Callers

nothing calls this directly

Calls 7

calculateTitleDBHashFunction · 0.85
dataMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
goodMethod · 0.45
sizeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected