config checking: only test skippedPaths existence for user-added values, not defaults
This commit is contained in:
parent
4989d1f991
commit
c7f5318e43
@ -380,10 +380,10 @@ void RclConfig::setKeyDir(const string &dir)
|
|||||||
m_defcharset.erase();
|
m_defcharset.erase();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RclConfig::getConfParam(const string &name, int *ivp) const
|
bool RclConfig::getConfParam(const string &name, int *ivp, bool shallow) const
|
||||||
{
|
{
|
||||||
string value;
|
string value;
|
||||||
if (!getConfParam(name, value))
|
if (!getConfParam(name, value, shallow))
|
||||||
return false;
|
return false;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
long lval = strtol(value.c_str(), 0, 0);
|
long lval = strtol(value.c_str(), 0, 0);
|
||||||
@ -394,37 +394,39 @@ bool RclConfig::getConfParam(const string &name, int *ivp) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RclConfig::getConfParam(const string &name, bool *bvp) const
|
bool RclConfig::getConfParam(const string &name, bool *bvp, bool shallow) const
|
||||||
{
|
{
|
||||||
if (!bvp)
|
if (!bvp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*bvp = false;
|
*bvp = false;
|
||||||
string s;
|
string s;
|
||||||
if (!getConfParam(name, s))
|
if (!getConfParam(name, s, shallow))
|
||||||
return false;
|
return false;
|
||||||
*bvp = stringToBool(s);
|
*bvp = stringToBool(s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RclConfig::getConfParam(const string &name, vector<string> *svvp) const
|
bool RclConfig::getConfParam(const string &name, vector<string> *svvp,
|
||||||
|
bool shallow) const
|
||||||
{
|
{
|
||||||
if (!svvp)
|
if (!svvp)
|
||||||
return false;
|
return false;
|
||||||
svvp->clear();
|
svvp->clear();
|
||||||
string s;
|
string s;
|
||||||
if (!getConfParam(name, s))
|
if (!getConfParam(name, s, shallow))
|
||||||
return false;
|
return false;
|
||||||
return stringToStrings(s, *svvp);
|
return stringToStrings(s, *svvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RclConfig::getConfParam(const string &name, vector<int> *vip) const
|
bool RclConfig::getConfParam(const string &name, vector<int> *vip,
|
||||||
|
bool shallow) const
|
||||||
{
|
{
|
||||||
if (!vip)
|
if (!vip)
|
||||||
return false;
|
return false;
|
||||||
vip->clear();
|
vip->clear();
|
||||||
vector<string> vs;
|
vector<string> vs;
|
||||||
if (!getConfParam(name, &vs))
|
if (!getConfParam(name, &vs, shallow))
|
||||||
return false;
|
return false;
|
||||||
vip->reserve(vs.size());
|
vip->reserve(vs.size());
|
||||||
for (unsigned int i = 0; i < vs.size(); i++) {
|
for (unsigned int i = 0; i < vs.size(); i++) {
|
||||||
|
|||||||
@ -123,21 +123,25 @@ class RclConfig {
|
|||||||
string getKeyDir() const {return m_keydir;}
|
string getKeyDir() const {return m_keydir;}
|
||||||
|
|
||||||
/** Get generic configuration parameter according to current keydir */
|
/** Get generic configuration parameter according to current keydir */
|
||||||
bool getConfParam(const string &name, string &value) const
|
bool getConfParam(const string &name, string &value,
|
||||||
|
bool shallow=false) const
|
||||||
{
|
{
|
||||||
if (m_conf == 0)
|
if (m_conf == 0)
|
||||||
return false;
|
return false;
|
||||||
return m_conf->get(name, value, m_keydir);
|
return m_conf->get(name, value, m_keydir, shallow);
|
||||||
}
|
}
|
||||||
/** Variant with autoconversion to int */
|
/** Variant with autoconversion to int */
|
||||||
bool getConfParam(const string &name, int *value) const;
|
bool getConfParam(const string &name, int *value, bool shallow=false) const;
|
||||||
/** Variant with autoconversion to bool */
|
/** Variant with autoconversion to bool */
|
||||||
bool getConfParam(const string &name, bool *value) const;
|
bool getConfParam(const string &name, bool *value,
|
||||||
|
bool shallow=false) const;
|
||||||
/** Variant with conversion to vector<string>
|
/** Variant with conversion to vector<string>
|
||||||
* (stringToStrings). Can fail if the string is malformed. */
|
* (stringToStrings). Can fail if the string is malformed. */
|
||||||
bool getConfParam(const string &name, vector<string> *value) const;
|
bool getConfParam(const string &name, vector<string> *value,
|
||||||
|
bool shallow=false) const;
|
||||||
/** Variant with conversion to vector<int> */
|
/** Variant with conversion to vector<int> */
|
||||||
bool getConfParam(const string &name, vector<int> *value) const;
|
bool getConfParam(const string &name, vector<int> *value,
|
||||||
|
bool shallow=false) const;
|
||||||
|
|
||||||
enum ThrStage {ThrIntern=0, ThrSplit=1, ThrDbWrite=2};
|
enum ThrStage {ThrIntern=0, ThrSplit=1, ThrDbWrite=2};
|
||||||
pair<int, int> getThrConf(ThrStage who) const;
|
pair<int, int> getThrConf(ThrStage who) const;
|
||||||
|
|||||||
@ -284,7 +284,9 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->getConfParam("skippedPaths", &tdl)) {
|
// Check skippedPaths too, but only the user part (shallow==true), not
|
||||||
|
// the default values (e.g. /media, which might not exist).
|
||||||
|
if (config->getConfParam("skippedPaths", &tdl, true)) {
|
||||||
for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
|
for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
|
||||||
*it = path_tildexpand(*it);
|
*it = path_tildexpand(*it);
|
||||||
if (access(it->c_str(), 0) < 0) {
|
if (access(it->c_str(), 0) < 0) {
|
||||||
@ -293,7 +295,7 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->getConfParam("daemSkippedPaths", &tdl)) {
|
if (config->getConfParam("daemSkippedPaths", &tdl, true)) {
|
||||||
for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
|
for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
|
||||||
*it = path_tildexpand(*it);
|
*it = path_tildexpand(*it);
|
||||||
if (access(it->c_str(), 0) < 0) {
|
if (access(it->c_str(), 0) < 0) {
|
||||||
|
|||||||
@ -399,15 +399,21 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int get(const string &name, string &value, const string &sk) const
|
virtual int get(const string &name, string &value, const string &sk,
|
||||||
|
bool shallow) const
|
||||||
{
|
{
|
||||||
typename vector<T*>::const_iterator it;
|
typename vector<T*>::const_iterator it;
|
||||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||||
if ((*it)->get(name, value, sk))
|
if ((*it)->get(name, value, sk))
|
||||||
return true;
|
return true;
|
||||||
|
if (shallow)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
virtual int get(const string &name, string &value, const string &sk) const {
|
||||||
|
return get(name, value, sk, false);
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool hasNameAnywhere(const string& nm) const
|
virtual bool hasNameAnywhere(const string& nm) const
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user