config/File: add directive "include_optional"
This commit is contained in:
parent
035f986a91
commit
09f743dc1a
@ -418,6 +418,14 @@ systemctl start mpd.socket</programlisting>
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<programlisting>include "other.conf"</programlisting>
|
<programlisting>include "other.conf"</programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
You can use <varname>include_optional</varname> instead if you
|
||||||
|
want the included file to be optional; the directive will be
|
||||||
|
ignored if the file does not exist:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting>include_optional "may_not_exist.conf"</programlisting>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="config_music_directory">
|
<section id="config_music_directory">
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "util/StringAPI.hxx"
|
#include "util/StringAPI.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
|
#include "fs/FileSystem.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "fs/io/FileReader.hxx"
|
#include "fs/io/FileReader.hxx"
|
||||||
#include "fs/io/BufferedReader.hxx"
|
#include "fs/io/BufferedReader.hxx"
|
||||||
@ -179,13 +180,20 @@ ReadConfigFile(ConfigData &config_data, BufferedReader &reader, Path directory)
|
|||||||
// TODO: detect recursion
|
// TODO: detect recursion
|
||||||
// TODO: Config{Block,Param} have only line number but no file name
|
// TODO: Config{Block,Param} have only line number but no file name
|
||||||
// TODO: support wildcards (include "conf.d/*.conf")
|
// TODO: support wildcards (include "conf.d/*.conf")
|
||||||
// TODO: add "include_optional"
|
|
||||||
const auto path = AllocatedPath::Apply(directory,
|
const auto path = AllocatedPath::Apply(directory,
|
||||||
AllocatedPath::FromUTF8Throw(ExpectValueAndEnd(tokenizer)));
|
AllocatedPath::FromUTF8Throw(ExpectValueAndEnd(tokenizer)));
|
||||||
ReadConfigFile(config_data, path);
|
ReadConfigFile(config_data, path);
|
||||||
continue;
|
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
|
/* get the definition of that option, and check the
|
||||||
"repeatable" flag */
|
"repeatable" flag */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user