LCOV - code coverage report
Current view: top level - helpcompiler/source - HelpIndexer_main.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 41 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <helpcompiler/HelpIndexer.hxx>
      11             : #include <osl/file.hxx>
      12             : #include <osl/process.h>
      13             : #include <osl/thread.h>
      14             : #include <string>
      15             : #include <iostream>
      16             : 
      17             : #include "LuceneHelper.hxx"
      18             : 
      19           0 : int main(int argc, char **argv) {
      20           0 :     const std::string pLang("-lang");
      21           0 :     const std::string pModule("-mod");
      22           0 :     const std::string pDir("-dir");
      23             : 
      24           0 :     std::string lang;
      25           0 :     std::string module;
      26           0 :     std::string dir;
      27             : 
      28           0 :     bool error = false;
      29           0 :     for (int i = 1; i < argc; ++i) {
      30           0 :         if (pLang.compare(argv[i]) == 0) {
      31           0 :             if (i + 1 < argc) {
      32           0 :                 lang = argv[++i];
      33             :             } else {
      34           0 :                 error = true;
      35             :             }
      36           0 :         } else if (pModule.compare(argv[i]) == 0) {
      37           0 :             if (i + 1 < argc) {
      38           0 :                 module = argv[++i];
      39             :             } else {
      40           0 :                 error = true;
      41             :             }
      42           0 :         } else if (pDir.compare(argv[i]) == 0) {
      43           0 :             if (i + 1 < argc) {
      44           0 :                 dir = argv[++i];
      45             :             } else {
      46           0 :                 error = true;
      47             :             }
      48             :         } else {
      49           0 :             error = true;
      50             :         }
      51             :     }
      52             : 
      53           0 :     if (error) {
      54           0 :         std::cerr << "Error parsing command-line arguments" << std::endl;
      55             :     }
      56             : 
      57           0 :     if (error || lang.empty() || module.empty() || dir.empty()) {
      58           0 :         std::cerr << "Usage: HelpIndexer -lang ISOLangCode -mod HelpModule -dir Dir" << std::endl;
      59           0 :         return 1;
      60             :     }
      61             : 
      62           0 :     OUString sDir;
      63             : 
      64             :     osl::File::getFileURLFromSystemPath(
      65           0 :         OUString(dir.c_str(), dir.size(), osl_getThreadTextEncoding()),
      66           0 :         sDir);
      67             : 
      68           0 :     OUString cwd;
      69           0 :     osl_getProcessWorkingDir(&cwd.pData);
      70             : 
      71           0 :     osl::File::getAbsoluteFileURL(cwd, sDir, sDir);
      72             : 
      73             :     HelpIndexer indexer(
      74           0 :         OUString(lang.c_str(), lang.size(), osl_getThreadTextEncoding()),
      75           0 :         OUString(module.c_str(), module.size(), osl_getThreadTextEncoding()),
      76           0 :         sDir, sDir);
      77             : 
      78           0 :     if (!indexer.indexDocuments()) {
      79           0 :         std::cerr << OUStringToOString(indexer.getErrorMessage(), osl_getThreadTextEncoding()).getStr()  << std::endl;
      80           0 :         return 2;
      81             :     }
      82           0 :     return 0;
      83           0 : }
      84             : 
      85             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11