diff --git a/src/common/kiwix/manager.cpp b/src/common/kiwix/manager.cpp index a33794da4..dfe375d92 100644 --- a/src/common/kiwix/manager.cpp +++ b/src/common/kiwix/manager.cpp @@ -321,6 +321,16 @@ namespace kiwix { } } + unsigned int Manager::getBookCount(const bool localBooks, const bool remoteBooks) { + unsigned int result = 0; + std::vector::iterator itr; + for ( itr = library.books.begin(); itr != library.books.end(); ++itr ) { + if (!itr->path.empty() && localBooks || itr->path.empty() && remoteBooks) + result++; + } + return result; + } + bool Manager::listBooks(const supportedListMode mode) { this->bookIdList.clear(); std::vector::iterator itr; diff --git a/src/common/kiwix/manager.h b/src/common/kiwix/manager.h index 15806a168..89abd8829 100644 --- a/src/common/kiwix/manager.h +++ b/src/common/kiwix/manager.h @@ -58,6 +58,7 @@ namespace kiwix { bool addBookFromPath(const string path, const string url = "", const bool checkMetaData = false); Library cloneLibrary(); bool getBookById(const string id, Book &book); + unsigned int getBookCount(const bool localBooks, const bool remoteBooks); bool updateBookLastOpenDateById(const string id); void removeBookPaths(); bool listBooks(const supportedListMode);