diff --git a/src/indexer/kiwix-index.cpp b/src/indexer/kiwix-index.cpp deleted file mode 100644 index 36442e9..0000000 --- a/src/indexer/kiwix-index.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2009-2013 Emmanuel Engelhart - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -#include -#include - -#ifdef _WIN32 -#include -#else -#include -#endif - -void usage() { - cout << "Usage: kiwix-index [--verbose] ZIM_PATH INDEX_PATH" << endl; - exit(1); -} - -int main(int argc, char **argv) { - - /* Init the variables */ - char *zimFilePath = NULL; - char *indexPath = NULL; - bool verboseFlag = false; - int option_index = 0; - int c = 0; - - kiwix::XapianIndexer *indexer = NULL; - - /* Argument parsing */ - while (42) { - - static struct option long_options[] = { - {"verbose", no_argument, 0, 'v'}, - {0, 0, 0, 0} - }; - - if (c != -1) { - c = getopt_long(argc, argv, "v", long_options, &option_index); - - switch (c) { - case 'v': - verboseFlag = true; - break; - } - } else { - if (optind < argc) { - if (zimFilePath == NULL) { - zimFilePath = argv[optind++]; - } else if (indexPath == NULL) { - indexPath = argv[optind++]; - } else { - usage(); - } - } else { - break; - } - } - } - - /* Check if we have enough arguments */ - if (zimFilePath == NULL || indexPath == NULL) { - usage(); - } - - /* Try to prepare the indexing */ - try { - indexer = new kiwix::XapianIndexer(); - } catch (...) { - cerr << "Unable to index '" << zimFilePath << "'." << endl; - exit(1); - } - - /* Start the indexing */ - if (indexer != NULL) { - indexer->setVerboseFlag(verboseFlag); - indexer->start(zimFilePath, indexPath); - while (indexer->isRunning()) { - if (verboseFlag) - cout << indexer->getProgression() << "% of all the articles indexed..." << endl; - kiwix::sleep(1000); - } - if (verboseFlag) - cout << "100% of the articles were successfuly indexed..." << endl; - delete indexer; - } else { - cerr << "Unable instanciate the Kiwix indexer." << endl; - exit(1); - } - - exit(0); -} diff --git a/src/indexer/meson.build b/src/indexer/meson.build deleted file mode 100644 index 6bcc38e..0000000 --- a/src/indexer/meson.build +++ /dev/null @@ -1,3 +0,0 @@ -executable('kiwix-index', ['kiwix-index.cpp'], - dependencies:all_deps, - install:true) diff --git a/src/installer/kiwix-install.cpp b/src/installer/kiwix-install.cpp index ead1df7..e271c66 100644 --- a/src/installer/kiwix-install.cpp +++ b/src/installer/kiwix-install.cpp @@ -19,14 +19,13 @@ #include #include -#include #include #include enum supportedAction { NONE, ADDCONTENT }; void usage() { - cout << "Usage: kiwix-install [--verbose] [--buildIndex] addcontent ZIM_PATH KIWIX_PATH" << endl; + cout << "Usage: kiwix-install [--verbose] addcontent ZIM_PATH KIWIX_PATH" << endl; exit(1); } @@ -37,7 +36,6 @@ int main(int argc, char **argv) { const char *kiwixPath = NULL; supportedAction action = NONE; bool verboseFlag = false; - bool buildIndexFlag = false; int option_index = 0; int c = 0; @@ -46,7 +44,6 @@ int main(int argc, char **argv) { static struct option long_options[] = { {"verbose", no_argument, 0, 'v'}, - {"buildIndex", no_argument, 0, 'i'}, {0, 0, 0, 0} }; @@ -57,9 +54,6 @@ int main(int argc, char **argv) { case 'v': verboseFlag = true; break; - case 'i': - buildIndexFlag = true; - break; } } else { if (optind < argc) { @@ -137,12 +131,6 @@ int main(int argc, char **argv) { makeDirectory(dataLibraryPath); } - /* Check if the directory "data/index" structure exists */ - string dataIndexPath = computeAbsolutePath(kiwixPath, "data/index/"); - if (!fileExists(dataIndexPath)) { - makeDirectory(dataIndexPath); - } - /* Copy the file to the data/content directory */ if (verboseFlag) { std::cout << "Copy ZIM file to the target directory..." << std::endl; } string newContentPath = computeAbsolutePath(dataContentPath, contentFilename); @@ -150,33 +138,6 @@ int main(int argc, char **argv) { copyFile(contentPath, newContentPath); } - /* Index the file if necessary */ - if (verboseFlag) { std::cout << "Check if the index directory exists..." << std::endl; } - string indexFilename = contentFilename + ".idx"; - string indexPath = computeAbsolutePath(dataIndexPath, indexFilename); - if (buildIndexFlag && !fileExists(indexPath)) { - if (verboseFlag) { std::cout << "Start indexing the ZIM file..." << std::endl; } - kiwix::XapianIndexer *indexer = NULL; - try { - indexer = new kiwix::XapianIndexer(); - } catch (...) { - cerr << "Unable to index '" << contentPath << "'." << endl; - exit(1); - } - - if (indexer != NULL) { - indexer->setVerboseFlag(verboseFlag); - indexer->start(contentPath, indexPath); - while (indexer->isRunning()) { - kiwix::sleep(1000); - } - delete indexer; - } else { - cerr << "Unable instanciate the Kiwix indexer." << endl; - exit(1); - } - } - /* Add the file to the library.xml */ if (verboseFlag) { std::cout << "Create the library XML file..." << std::endl; } kiwix::Manager libraryManager; @@ -184,9 +145,6 @@ int main(int argc, char **argv) { string bookId = libraryManager.addBookFromPathAndGetId(newContentPath, "../content/" + contentFilename, "", false); if (!bookId.empty()) { libraryManager.setCurrentBookId(bookId); - if (buildIndexFlag) { - libraryManager.setBookIndex(bookId, "../index/" + indexFilename, kiwix::XAPIAN); - } libraryManager.writeFile(libraryPath); } else { cerr << "Unable to build or save library file '" << libraryPath << "'" << endl; diff --git a/src/meson.build b/src/meson.build index b768274..a427815 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,6 +1,4 @@ - -subdir('indexer') subdir('installer') subdir('manager') subdir('reader')