Add Reader::urlExists

This commit is contained in:
kelson42 2016-10-02 17:16:39 +02:00
parent c1b5eb42bf
commit 39ad3313df
2 changed files with 10 additions and 0 deletions

View File

@ -511,6 +511,15 @@ namespace kiwix {
return retVal;
}
/* Check if an article exists */
bool Reader::urlExists(const string &url) {
char ns = 0;
string titleStr;
this->parseUrl(url, &ns, titleStr);
zim::File::const_iterator findItr = zimFileHandler->find(ns, titleStr);
return findItr->getUrl() == titleStr;
}
/* Search titles by prefix */
bool Reader::searchSuggestions(const string &prefix, unsigned int suggestionsCount, const bool reset) {
bool retVal = false;

View File

@ -71,6 +71,7 @@ namespace kiwix {
bool getContentByDecodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType);
bool searchSuggestions(const string &prefix, unsigned int suggestionsCount, const bool reset = true);
bool searchSuggestionsSmart(const string &prefix, unsigned int suggestionsCount);
bool urlExists(const string &url);
std::vector<std::string> getTitleVariants(const std::string &title);
bool getNextSuggestion(string &title);
bool getNextSuggestion(string &title, string &url);