| 98 | } |
| 99 | |
| 100 | RecentBook RecentBooksStore::getDataFromBook(std::string path) const { |
| 101 | std::string lastBookFileName = ""; |
| 102 | const size_t lastSlash = path.find_last_of('/'); |
| 103 | if (lastSlash != std::string::npos) { |
| 104 | lastBookFileName = path.substr(lastSlash + 1); |
| 105 | } |
| 106 | |
| 107 | LOG_DBG("RBS", "Loading recent book: %s", path.c_str()); |
| 108 | |
| 109 | // If epub, try to load the metadata for title/author and cover. |
| 110 | // Use buildIfMissing=false to avoid heavy epub loading on boot; getTitle()/getAuthor() may be |
| 111 | // blank until the book is opened, and entries with missing title are omitted from recent list. |
| 112 | if (FsHelpers::hasEpubExtension(lastBookFileName)) { |
| 113 | Epub epub(path, "/.crosspoint"); |
| 114 | epub.load(false, true); |
| 115 | return RecentBook{path, epub.getTitle(), epub.getAuthor(), epub.getThumbBmpPath()}; |
| 116 | } else if (FsHelpers::hasXtcExtension(lastBookFileName)) { |
| 117 | // Handle XTC file |
| 118 | Xtc xtc(path, "/.crosspoint"); |
| 119 | if (xtc.load()) { |
| 120 | return RecentBook{path, xtc.getTitle(), xtc.getAuthor(), xtc.getThumbBmpPath()}; |
| 121 | } |
| 122 | } else if (FsHelpers::hasTxtExtension(lastBookFileName) || FsHelpers::hasMarkdownExtension(lastBookFileName)) { |
| 123 | return RecentBook{path, lastBookFileName, "", ""}; |
| 124 | } |
| 125 | return RecentBook{path, "", "", ""}; |
| 126 | } |
| 127 | |
| 128 | bool RecentBooksStore::loadFromFile() { |
| 129 | // Try JSON first |
nothing calls this directly
no test coverage detected