config/File: add directive "include_optional"

This commit is contained in:
Max Kellermann
2018-07-18 13:10:36 +02:00
parent 035f986a91
commit 09f743dc1a
2 changed files with 17 additions and 1 deletions

View File

@@ -28,6 +28,7 @@
#include "util/StringAPI.hxx"
#include "util/Domain.hxx"
#include "util/RuntimeError.hxx"
#include "fs/FileSystem.hxx"
#include "fs/Path.hxx"
#include "fs/io/FileReader.hxx"
#include "fs/io/BufferedReader.hxx"
@@ -179,13 +180,20 @@ ReadConfigFile(ConfigData &config_data, BufferedReader &reader, Path directory)
// TODO: detect recursion
// TODO: Config{Block,Param} have only line number but no file name
// TODO: support wildcards (include "conf.d/*.conf")
// TODO: add "include_optional"
const auto path = AllocatedPath::Apply(directory,
AllocatedPath::FromUTF8Throw(ExpectValueAndEnd(tokenizer)));
ReadConfigFile(config_data, path);
continue;
}
if (StringIsEqual(name, "include_optional")) {
const auto path = AllocatedPath::Apply(directory,
AllocatedPath::FromUTF8Throw(ExpectValueAndEnd(tokenizer)));
if (PathExists(path))
ReadConfigFile(config_data, path);
continue;
}
/* get the definition of that option, and check the
"repeatable" flag */