MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / load

Method load

lib/Epub/Epub/BookMetadataCache.cpp:377–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375/* ============= READING / LOADING FUNCTIONS ================ */
376
377bool BookMetadataCache::load() {
378 if (!Storage.openFileForRead("BMC", cachePath + bookBinFile, bookFile)) {
379 return false;
380 }
381
382 uint8_t version;
383 serialization::readPod(bookFile, version);
384 if (version != BOOK_CACHE_VERSION) {
385 LOG_DBG("BMC", "Cache version mismatch: expected %d, got %d", BOOK_CACHE_VERSION, version);
386 // Explicit close() required: member variable persists beyond function scope
387 bookFile.close();
388 return false;
389 }
390
391 serialization::readPod(bookFile, lutOffset);
392 serialization::readPod(bookFile, spineCount);
393 serialization::readPod(bookFile, tocCount);
394
395 serialization::readString(bookFile, coreMetadata.title);
396 serialization::readString(bookFile, coreMetadata.author);
397 serialization::readString(bookFile, coreMetadata.language);
398 serialization::readString(bookFile, coreMetadata.coverItemHref);
399 serialization::readString(bookFile, coreMetadata.textReferenceHref);
400
401 loaded = true;
402 LOG_DBG("BMC", "Loaded cache data: %d spine, %d TOC entries", spineCount, tocCount);
403 return true;
404}
405
406BookMetadataCache::SpineEntry BookMetadataCache::getSpineEntry(const int index) {
407 if (!loaded) {

Callers

nothing calls this directly

Calls 4

readPodFunction · 0.85
readStringFunction · 0.85
openFileForReadMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected