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"};
for (auto &path: paths) {
try { try {
auto entry = zimArchive->getEntryByPath(path); auto entry = zimArchive->getFaviconEntry();
auto item = entry.getItem(true); auto item = entry.getItem(true);
content = item.getData(); content = item.getData();
mimeType = item.getMimetype(); mimeType = item.getMimetype();
return true; return true;
} catch(zim::EntryNotFound& e) {}; } catch(zim::EntryNotFound& e) {};
}
return false; return false;
} }