Adjust last change to conftree: treat non-existing topmost file as an empty one to support lean config dirs

This commit is contained in:
Jean-Francois Dockes 2019-11-14 18:21:08 +01:00
parent b43d1b3287
commit 021941bf6f
2 changed files with 10 additions and 3 deletions

View File

@ -1 +1 @@
1.26.1
1.26.2pre1

View File

@ -62,6 +62,7 @@
#include <istream>
#include <ostream>
#endif
#include <iostream>
#include "pathut.h"
@ -571,17 +572,23 @@ private:
/// if some files were not readable/parsable. Now fail if any
/// fails.
void construct(const std::vector<std::string>& fns, bool ro) {
bool ok = true;
bool ok{true};
bool first{true};
for (const auto& fn : fns) {
T* p = new T(fn.c_str(), ro);
if (p && p->ok()) {
m_confs.push_back(p);
} else {
delete p;
ok = false;
// In ro mode, we accept a non-existing topmost file
// and treat it as an empty one.
if (!(ro && first && !path_exists(fn))) {
ok = false;
}
}
// Only the first file is opened rw
ro = true;
first = false;
}
m_ok = ok;
}