1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * colservrconfig.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * A component of the Greenstone digital library software
|
---|
7 | * from the New Zealand Digital Library Project at the
|
---|
8 | * University of Waikato, New Zealand.
|
---|
9 | *
|
---|
10 | * This program is free software; you can redistribute it and/or modify
|
---|
11 | * it under the terms of the GNU General Public License as published by
|
---|
12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
13 | * (at your option) any later version.
|
---|
14 | *
|
---|
15 | * This program is distributed in the hope that it will be useful,
|
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | * GNU General Public License for more details.
|
---|
19 | *
|
---|
20 | * You should have received a copy of the GNU General Public License
|
---|
21 | * along with this program; if not, write to the Free Software
|
---|
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | *
|
---|
24 | * $Id: colservrconfig.cpp 16310 2008-07-09 01:12:15Z davidb $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | #include "colservrconfig.h"
|
---|
29 | #include "fileutil.h"
|
---|
30 | #include "cfgread.h"
|
---|
31 |
|
---|
32 |
|
---|
33 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
34 | # include <ospace/std/iostream>
|
---|
35 | # include <ospace/std/fstream>
|
---|
36 | #elif defined(GSDL_USE_IOS_H)
|
---|
37 | # include <iostream.h>
|
---|
38 | # include <fstream.h>
|
---|
39 | #else
|
---|
40 | # include <iostream>
|
---|
41 | # include <fstream>
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | // collect_cfg_read reads collect.cfg returning true on success.
|
---|
45 | bool collect_cfg_read (collectserver &cserver, const text_t &gsdlhome,
|
---|
46 | const text_t& collecthome,
|
---|
47 | const text_t &collection)
|
---|
48 | {
|
---|
49 | text_t filename = filename_cat (collecthome, collection);
|
---|
50 | filename = filename_cat (filename, "custom",collection,"etc","custom.cfg");
|
---|
51 |
|
---|
52 | if (!file_exists (filename)) {
|
---|
53 | filename = filename_cat (collecthome, collection, "etc", "collect.cfg");
|
---|
54 |
|
---|
55 | if (!file_exists (filename)) {
|
---|
56 | filename = filename_cat (gsdlhome, "etc", "collect.cfg");
|
---|
57 | if (!file_exists (filename)) return false;
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | return cserver.read_configfile(filename);
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | // build_cfg_read reads build.cfg and returns true on success.
|
---|
66 | bool build_cfg_read (collectserver &cserver, const text_t &gsdlhome,
|
---|
67 | const text_t& collecthome,
|
---|
68 | const text_t &collection) {
|
---|
69 | text_t filename = filename_cat (collecthome, collection,"index","build.cfg");
|
---|
70 |
|
---|
71 | if (!file_exists (filename)) {
|
---|
72 | filename = filename_cat (gsdlhome, "index", "build.cfg");
|
---|
73 | if (!file_exists (filename)) return false;
|
---|
74 | }
|
---|
75 |
|
---|
76 | return cserver.read_configfile(filename);
|
---|
77 |
|
---|
78 | }
|
---|