Settings: Add bool get()

This commit is contained in:
Eelco Dolstra 2014-09-17 15:18:13 +02:00
parent eca29bd72d
commit d37d012774
4 changed files with 13 additions and 3 deletions

View file

@ -108,7 +108,7 @@ int main(int argc, char * * argv)
/* Pass on the location of the daemon client's SSH
authentication socket. */
string sshAuthSock = settings.get("ssh-auth-sock", "");
string sshAuthSock = settings.get("ssh-auth-sock", string(""));
if (sshAuthSock != "") setenv("SSH_AUTH_SOCK", sshAuthSock.c_str(), 1);
string host = settings.sshSubstituterHosts.front();

View file

@ -1792,8 +1792,8 @@ void DerivationGoal::startBuilder()
/* Bind-mount a user-configurable set of directories from the
host file system. */
PathSet dirs = tokenizeString<StringSet>(settings.get("build-chroot-dirs", DEFAULT_CHROOT_DIRS));
PathSet dirs2 = tokenizeString<StringSet>(settings.get("build-extra-chroot-dirs", ""));
PathSet dirs = tokenizeString<StringSet>(settings.get("build-chroot-dirs", string(DEFAULT_CHROOT_DIRS)));
PathSet dirs2 = tokenizeString<StringSet>(settings.get("build-extra-chroot-dirs", string("")));
dirs.insert(dirs2.begin(), dirs2.end());
for (auto & i : dirs) {
size_t p = i.find('=');

View file

@ -136,6 +136,14 @@ Strings Settings::get(const string & name, const Strings & def)
}
bool Settings::get(const string & name, bool def)
{
bool res = def;
_get(res, name);
return res;
}
void Settings::update()
{
_get(tryFallback, "build-fallback");

View file

@ -25,6 +25,8 @@ struct Settings {
Strings get(const string & name, const Strings & def);
bool get(const string & name, bool def);
void update();
string pack();