Use new libzim method `getFaviconEntry` to get the favicon.

This commit is contained in:
Matthieu Gautier 2020-12-08 18:53:02 +01:00 committed by Emmanuel Engelhart
parent 9941d245e1
commit ba302bed33
1 changed files with 7 additions and 11 deletions

View File

@ -179,17 +179,13 @@ Entry Reader::getMainPage() const
bool Reader::getFavicon(string& content, string& mimeType) const bool Reader::getFavicon(string& content, string& mimeType) const
{ {
static const char* const paths[] = {"-/favicon", "-/favicon.png", "I/favicon.png", "I/favicon"}; try {
auto entry = zimArchive->getFaviconEntry();
for (auto &path: paths) { auto item = entry.getItem(true);
try { content = item.getData();
auto entry = zimArchive->getEntryByPath(path); mimeType = item.getMimetype();
auto item = entry.getItem(true); return true;
content = item.getData(); } catch(zim::EntryNotFound& e) {};
mimeType = item.getMimetype();
return true;
} catch(zim::EntryNotFound& e) {};
}
return false; return false;
} }