better deal with *.zimaa paths

This commit is contained in:
kelson42 2012-10-14 12:18:57 +00:00
parent 63c210db1c
commit 956d37dee8
1 changed files with 11 additions and 2 deletions

View File

@ -41,9 +41,18 @@ namespace kiwix {
/* Constructor */
Reader::Reader(const string zimFilePath)
: zimFileHandler(NULL) {
string tmpZimFilePath = zimFilePath;
/* Remove potential trailing zimaa */
size_t found = tmpZimFilePath.rfind("zimaa");
if (found != string::npos &&
tmpZimFilePath.size() > 5 &&
found == tmpZimFilePath.size() - 5) {
tmpZimFilePath.resize(tmpZimFilePath.size() - 2);
}
this->zimFileHandler = new zim::File(tmpZimFilePath);
this->zimFileHandler = new zim::File(zimFilePath);
if (this->zimFileHandler != NULL) {
this->firstArticleOffset = this->zimFileHandler->getNamespaceBeginOffset('A');
this->lastArticleOffset = this->zimFileHandler->getNamespaceEndOffset('A');