Extract book cover utilities into BookCoverUtils

Refactors book cover and metadata handling out of Epub class into a dedicated BookCoverUtils utility. Moves FootnoteEntry struct into reader activity directory. Simplifies cache clearing to use direct storage operations instead of Epub class.
This commit is contained in:
Justin Mitchell
2026-07-08 01:31:24 -04:00
parent d364e54a69
commit 78c71f1c77
93 changed files with 276 additions and 77118 deletions
+7 -7
View File
@@ -1,6 +1,5 @@
#include "RecentBooksStore.h"
#include <Epub.h>
#include <FsHelpers.h>
#include <HalStorage.h>
#include <JsonSettingsIO.h>
@@ -11,6 +10,8 @@
#include <algorithm>
#include <iterator>
#include "util/BookCoverUtils.h"
namespace {
constexpr uint8_t RECENT_BOOKS_FILE_VERSION = 3;
constexpr char RECENT_BOOKS_FILE_BIN[] = "/.crosspoint/recent.bin";
@@ -106,13 +107,12 @@ RecentBook RecentBooksStore::getDataFromBook(std::string path) const {
LOG_DBG("RBS", "Loading recent book: %s", path.c_str());
// If epub, try to load the metadata for title/author and cover.
// Use buildIfMissing=false to avoid heavy epub loading on boot; getTitle()/getAuthor() may be
// blank until the book is opened, and entries with missing title are omitted from recent list.
// If epub, read title/author straight from the OPF (Book::open is a light
// container parse — no pagination, no CSS).
if (FsHelpers::hasEpubExtension(lastBookFileName)) {
Epub epub(path, "/.crosspoint");
epub.load(false, true);
return RecentBook{path, epub.getTitle(), epub.getAuthor(), epub.getThumbBmpPath()};
std::string title, author;
BookCoverUtils::readMetadata(path, &title, &author);
return RecentBook{path, title, author, BookCoverUtils::thumbBmpPathTemplate(path)};
} else if (FsHelpers::hasXtcExtension(lastBookFileName)) {
// Handle XTC file
Xtc xtc(path, "/.crosspoint");