| 375 | /* ============= READING / LOADING FUNCTIONS ================ */ |
| 376 | |
| 377 | bool 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 | |
| 406 | BookMetadataCache::SpineEntry BookMetadataCache::getSpineEntry(const int index) { |
| 407 | if (!loaded) { |
nothing calls this directly
no test coverage detected