Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
f30265a9
Commit
f30265a9
authored
6 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/File: support wildcards in "include"
parent
fcbcec68
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
user.xml
doc/user.xml
+8
-0
File.cxx
src/config/File.cxx
+16
-3
No files found.
doc/user.xml
View file @
f30265a9
...
...
@@ -426,6 +426,14 @@ systemctl start mpd.socket</programlisting>
</para>
<programlisting>
include_optional "may_not_exist.conf"
</programlisting>
<para>
Both directives can have a shell pattern (with wildcards
'
<filename>
*
</filename>
' and '
<filename>
?
</filename>
') in the
last path segment, e.g.:
</para>
<programlisting>
include "conf.d/*.conf"
</programlisting>
</section>
<section
id=
"config_music_directory"
>
...
...
This diff is collapsed.
Click to expand it.
src/config/File.cxx
View file @
f30265a9
...
...
@@ -23,12 +23,14 @@
#include "Param.hxx"
#include "Block.hxx"
#include "Templates.hxx"
#include "system/Error.hxx"
#include "util/Tokenizer.hxx"
#include "util/StringStrip.hxx"
#include "util/StringAPI.hxx"
#include "util/Domain.hxx"
#include "util/RuntimeError.hxx"
#include "fs/FileSystem.hxx"
#include "fs/List.hxx"
#include "fs/Path.hxx"
#include "fs/io/FileReader.hxx"
#include "fs/io/BufferedReader.hxx"
...
...
@@ -179,16 +181,27 @@ ReadConfigFile(ConfigData &config_data, BufferedReader &reader, Path directory)
if
(
StringIsEqual
(
name
,
"include"
))
{
// TODO: detect recursion
// TODO: Config{Block,Param} have only line number but no file name
// TODO: support wildcards (include "conf.d/*.conf")
const
auto
path
=
AllocatedPath
::
Apply
(
directory
,
const
auto
pattern
=
AllocatedPath
::
Apply
(
directory
,
AllocatedPath
::
FromUTF8Throw
(
ExpectValueAndEnd
(
tokenizer
)));
for
(
const
auto
&
path
:
ListWildcard
(
pattern
))
ReadConfigFile
(
config_data
,
path
);
continue
;
}
if
(
StringIsEqual
(
name
,
"include_optional"
))
{
const
auto
pat
h
=
AllocatedPath
::
Apply
(
directory
,
const
auto
pat
tern
=
AllocatedPath
::
Apply
(
directory
,
AllocatedPath
::
FromUTF8Throw
(
ExpectValueAndEnd
(
tokenizer
)));
std
::
forward_list
<
AllocatedPath
>
l
;
try
{
l
=
ListWildcard
(
pattern
);
}
catch
(
const
std
::
system_error
&
e
)
{
/* ignore "file not found */
if
(
!
IsFileNotFound
(
e
)
&&
!
IsPathNotFound
(
e
))
throw
;
}
for
(
const
auto
&
path
:
l
)
if
(
PathExists
(
path
))
ReadConfigFile
(
config_data
,
path
);
continue
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment