1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * tools.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 | *********************************************************************/
|
---|
25 |
|
---|
26 | #include "colservertools.h"
|
---|
27 | #include "fileutil.h"
|
---|
28 |
|
---|
29 |
|
---|
30 | text_t getcollectionpath(const text_t& gsdlhome, const text_t& dbhome,
|
---|
31 | const text_t& collecthome, const text_t& collection)
|
---|
32 | {
|
---|
33 | text_t resolved_filename;
|
---|
34 |
|
---|
35 | if (gsdlhome==dbhome) {
|
---|
36 | // dbhome has defaulted to gsdlhome which we take to means the
|
---|
37 | // database has been specifically moved out of gsdlhome area.
|
---|
38 | // => it should be whereever collecthome is set to
|
---|
39 | resolved_filename = filename_cat(collecthome, collection);
|
---|
40 | }
|
---|
41 | else {
|
---|
42 | // dbhome is explicitly set to something other than gsdlhome
|
---|
43 | // => use dbhome
|
---|
44 | resolved_filename = filename_cat(dbhome, "collect", collection);
|
---|
45 | }
|
---|
46 |
|
---|
47 | return resolved_filename;
|
---|
48 | }
|
---|
49 |
|
---|
50 | text_t resolve_db_filename(const text_t& gsdlhome, const text_t& dbhome,
|
---|
51 | const text_t& collecthome, const text_t& collection,
|
---|
52 | const text_t& idx, const text_t& file_ext)
|
---|
53 | {
|
---|
54 | text_t collection_path = getcollectionpath(gsdlhome, dbhome, collecthome, collection);
|
---|
55 | text_t resolved_filename = filename_cat(collection_path, "index", "text", idx);
|
---|
56 |
|
---|
57 | resolved_filename += file_ext;
|
---|
58 |
|
---|
59 | return resolved_filename;
|
---|
60 | }
|
---|
61 |
|
---|
62 | text_t resolve_oaidb_filename(const text_t& gsdlhome, const text_t& dbhome,
|
---|
63 | const text_t& collecthome, const text_t& collection,
|
---|
64 | const text_t& file_ext)
|
---|
65 | {
|
---|
66 | text_t collection_path = getcollectionpath(gsdlhome, dbhome, collecthome, collection);
|
---|
67 | text_t resolved_filename = filename_cat(collection_path, "etc", "oai-inf");
|
---|
68 |
|
---|
69 | resolved_filename += file_ext;
|
---|
70 |
|
---|
71 | return resolved_filename;
|
---|
72 | }
|
---|