From 1edd7ebd015d022d73727baa916f9a31ed8403a0 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Fri, 4 Mar 2011 14:05:59 +0000 Subject: [PATCH] + add checksum checks methods in the kiwix::reader and in the XPOM zimAccessor component --- src/common/kiwix/reader.cpp | 18 ++++++++++++++++++ src/common/kiwix/reader.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/common/kiwix/reader.cpp b/src/common/kiwix/reader.cpp index a5d3b01ab..6b0e7e5fd 100644 --- a/src/common/kiwix/reader.cpp +++ b/src/common/kiwix/reader.cpp @@ -236,4 +236,22 @@ namespace kiwix { return retVal; } + + /* Check if the file has as checksum */ + bool Reader::canCheckIntegrity() { + return this->zimFileHandler->getChecksum() != ""; + } + + /* Return true if corrupted, false otherwise */ + bool Reader::isCorrupted() { + try { + if (this->zimFileHandler->verify() == true) + return false; + } catch (exception &e) { + cerr << e.what() << endl; + return true; + } + + return true; + } } diff --git a/src/common/kiwix/reader.h b/src/common/kiwix/reader.h index 017059303..242a69c00 100644 --- a/src/common/kiwix/reader.h +++ b/src/common/kiwix/reader.h @@ -29,6 +29,8 @@ namespace kiwix { bool getContentByUrl(const string &url, string &content, unsigned int &contentLength, string &contentType); bool searchSuggestions(const string &prefix, unsigned int suggestionsCount); bool getNextSuggestion(string &title); + bool canCheckIntegrity(); + bool isCorrupted(); protected: zim::File* zimFileHandler;