mirror of https://github.com/kiwix/libkiwix.git
+ kiwix-server uses now kiwix::Reader
This commit is contained in:
parent
fb2dfdd677
commit
c9778c9097
|
@ -6,7 +6,6 @@ namespace kiwix {
|
|||
Reader::Reader(const string &zimFilePath)
|
||||
: zimFileHandler(NULL) {
|
||||
|
||||
try {
|
||||
this->zimFileHandler = new zim::File(zimFilePath);
|
||||
|
||||
if (this->zimFileHandler != NULL) {
|
||||
|
@ -15,8 +14,6 @@ namespace kiwix {
|
|||
this->currentArticleOffset = this->firstArticleOffset;
|
||||
this->articleCount = this->zimFileHandler->getNamespaceCount('A');
|
||||
}
|
||||
} catch(...) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Destructor */
|
||||
|
@ -66,7 +63,6 @@ string Reader::getMainPageUrl() {
|
|||
|
||||
/* Get a content from a zim file */
|
||||
bool Reader::getContent(const string &urlStr, string &content, unsigned int &contentLength, string &contentType) {
|
||||
|
||||
bool retVal = false;
|
||||
const char *url = urlStr.c_str();
|
||||
|
||||
|
@ -100,8 +96,16 @@ string Reader::getMainPageUrl() {
|
|||
}
|
||||
title[titleOffset] = 0;
|
||||
|
||||
/* Main page */
|
||||
if (strcmp(title, "") == 0 && strcmp(ns, "") == 0) {
|
||||
if (zimFileHandler->getFileheader().hasMainPage()) {
|
||||
zim::Article article = zimFileHandler->getArticle(zimFileHandler->getFileheader().getMainPage());
|
||||
ns[0] = article.getNamespace();
|
||||
strcpy(title, article.getUrl().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/* Extract the content from the zim file */
|
||||
try {
|
||||
std::pair<bool, zim::File::const_iterator> resultPair = zimFileHandler->findx(ns[0], title);
|
||||
|
||||
/* Test if the article was found */
|
||||
|
@ -134,9 +138,6 @@ string Reader::getMainPageUrl() {
|
|||
contentLength = 0;
|
||||
retVal = false;
|
||||
}
|
||||
} catch(...) {
|
||||
retVal = false;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue