Define system specific default configuration directory to allow sharing most of the default configuration files contents

This commit is contained in:
Jean-Francois Dockes
2022-01-15 09:12:39 +00:00
parent 844b4e8b03
commit 265bbd0c6e
5 changed files with 69 additions and 617 deletions
+20 -2
View File
@@ -58,6 +58,16 @@
using namespace std;
// Naming the directory for platform-specific default config files, overriding the top-level ones
// E.g. /usr/share/recoll/examples/windows
#ifdef _WIN32
static const string confsysdir{"windows"};
#elif defined(_APPLE__)
static const string confsysdir{"macos"};
#else
static const string confsysdir;
#endif
// Static, logically const, RclConfig members or module static
// variables are initialized once from the first object build during
// process initialization.
@@ -303,8 +313,15 @@ RclConfig::RclConfig(const string *argcnf)
m_cdirs.push_back(cp);
}
// Base/installation config
m_cdirs.push_back(path_cat(m_datadir, "examples"));
// Base/installation config, and its platform-specific overrides
std::string defaultsdir = path_cat(m_datadir, "examples");
if (!confsysdir.empty()) {
std::string sdir = path_cat(defaultsdir, confsysdir);
if (path_isdir(sdir)) {
m_cdirs.push_back(sdir);
}
}
m_cdirs.push_back(defaultsdir);
string cnferrloc;
for (const auto& dir : m_cdirs) {
@@ -376,6 +393,7 @@ bool RclConfig::updateMainConfig()
{
ConfStack<ConfTree> *newconf = new ConfStack<ConfTree>("recoll.conf", m_cdirs, true);
if (newconf == 0 || !newconf->ok()) {
std::cerr << "updateMainConfig: new Confstack not ok\n";
if (m_conf)
return false;
m_ok = false;