mirror of https://github.com/kiwix/libkiwix.git
Merge pull request #433 from kiwix/small_fixes
Fixes related to libzim next.
This commit is contained in:
commit
2659f323cd
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -343,10 +339,6 @@ string Reader::getOrigId() const
|
||||||
|
|
||||||
Entry Reader::getEntryFromPath(const std::string& path) const
|
Entry Reader::getEntryFromPath(const std::string& path) const
|
||||||
{
|
{
|
||||||
if (!this->zimArchive) {
|
|
||||||
throw NoEntry();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path.empty() || path == "/") {
|
if (path.empty() || path == "/") {
|
||||||
return getMainPage();
|
return getMainPage();
|
||||||
}
|
}
|
||||||
|
@ -365,10 +357,6 @@ Entry Reader::getEntryFromEncodedPath(const std::string& path) const
|
||||||
|
|
||||||
Entry Reader::getEntryFromTitle(const std::string& title) const
|
Entry Reader::getEntryFromTitle(const std::string& title) const
|
||||||
{
|
{
|
||||||
if (!this->zimArchive) {
|
|
||||||
throw NoEntry();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return zimArchive->getEntryByTitle(title);
|
return zimArchive->getEntryByTitle(title);
|
||||||
} catch(zim::EntryNotFound& e) {
|
} catch(zim::EntryNotFound& e) {
|
||||||
|
@ -378,34 +366,13 @@ Entry Reader::getEntryFromTitle(const std::string& title) const
|
||||||
|
|
||||||
bool Reader::pathExists(const string& path) const
|
bool Reader::pathExists(const string& path) const
|
||||||
{
|
{
|
||||||
if (!zimArchive)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return zimArchive->hasEntryByPath(path);
|
return zimArchive->hasEntryByPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Does the ZIM file has a fulltext index */
|
/* Does the ZIM file has a fulltext index */
|
||||||
bool Reader::hasFulltextIndex() const
|
bool Reader::hasFulltextIndex() const
|
||||||
{
|
{
|
||||||
if (!zimArchive)
|
return zimArchive->hasFulltextIndex();
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto path: {"Z//fulltextIndex/xapian", "X/fulltext/xapian"}) {
|
|
||||||
try {
|
|
||||||
auto entry = zimArchive->getEntryByPath(path);
|
|
||||||
auto item = entry.getItem(true);
|
|
||||||
auto accessInfo = item.getDirectAccessInformation();
|
|
||||||
if (accessInfo.second) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch(...) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search titles by prefix */
|
/* Search titles by prefix */
|
||||||
|
@ -608,9 +575,6 @@ bool Reader::isCorrupted() const
|
||||||
/* Return the file size, works also for splitted files */
|
/* Return the file size, works also for splitted files */
|
||||||
unsigned int Reader::getFileSize() const
|
unsigned int Reader::getFileSize() const
|
||||||
{
|
{
|
||||||
if (!zimArchive) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return zimArchive->getFilesize() / 1024;
|
return zimArchive->getFilesize() / 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue