fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / helpcompiler / source / HelpIndexer_main.cxx
blob97b1d7a179107f4561f1cc0dfe8fae3a332ee4b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
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>
17 #include "LuceneHelper.hxx"
19 int main(int argc, char **argv) {
20 const std::string pLang("-lang");
21 const std::string pModule("-mod");
22 const std::string pDir("-dir");
24 std::string lang;
25 std::string module;
26 std::string dir;
28 bool error = false;
29 for (int i = 1; i < argc; ++i) {
30 if (pLang.compare(argv[i]) == 0) {
31 if (i + 1 < argc) {
32 lang = argv[++i];
33 } else {
34 error = true;
36 } else if (pModule.compare(argv[i]) == 0) {
37 if (i + 1 < argc) {
38 module = argv[++i];
39 } else {
40 error = true;
42 } else if (pDir.compare(argv[i]) == 0) {
43 if (i + 1 < argc) {
44 dir = argv[++i];
45 } else {
46 error = true;
48 } else {
49 error = true;
53 if (error) {
54 std::cerr << "Error parsing command-line arguments" << std::endl;
57 if (error || lang.empty() || module.empty() || dir.empty()) {
58 std::cerr << "Usage: HelpIndexer -lang ISOLangCode -mod HelpModule -dir Dir" << std::endl;
59 return 1;
62 OUString sDir;
64 osl::File::getFileURLFromSystemPath(
65 OUString(dir.c_str(), dir.size(), osl_getThreadTextEncoding()),
66 sDir);
68 OUString cwd;
69 osl_getProcessWorkingDir(&cwd.pData);
71 osl::File::getAbsoluteFileURL(cwd, sDir, sDir);
73 HelpIndexer indexer(
74 OUString(lang.c_str(), lang.size(), osl_getThreadTextEncoding()),
75 OUString(module.c_str(), module.size(), osl_getThreadTextEncoding()),
76 sDir, sDir);
78 if (!indexer.indexDocuments()) {
79 std::cerr << OUStringToOString(indexer.getErrorMessage(), osl_getThreadTextEncoding()).getStr() << std::endl;
80 return 2;
82 return 0;
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */