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

Method getDataFromBook

src/RecentBooksStore.cpp:100–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100RecentBook 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
128bool RecentBooksStore::loadFromFile() {
129 // Try JSON first

Callers

nothing calls this directly

Calls 8

hasXtcExtensionFunction · 0.85
hasMarkdownExtensionFunction · 0.85
hasEpubExtensionFunction · 0.50
hasTxtExtensionFunction · 0.50
loadMethod · 0.45
getTitleMethod · 0.45
getAuthorMethod · 0.45
getThumbBmpPathMethod · 0.45

Tested by

no test coverage detected