diff options
author | Peter Powell <petpow@saberuk.com> | 2019-06-10 14:06:28 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-06-10 14:06:28 +0100 |
commit | 9a0cefb52f68e666a1ec19380ceed086070e9492 (patch) | |
tree | ebbd8bc943cfc7d0dafbc45a9647160fefb92255 /src/configparser.cpp | |
parent | 6e898936d6e0f44da0992ad09139f0e8e6d141af (diff) |
Add support for including directories containing .conf files.
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r-- | src/configparser.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp index abdf6f3de..b965bc015 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -394,9 +394,30 @@ void ParseStack::DoInclude(ConfigTag* tag, int flags) flags |= FLAG_NO_INC; if (tag->getBool("noexec", false)) flags |= FLAG_NO_EXEC; + if (!ParseFile(ServerInstance->Config->Paths.PrependConfig(name), flags, mandatorytag)) throw CoreException("Included"); } + else if (tag->readString("directory", name)) + { + if (tag->getBool("noinclude", false)) + flags |= FLAG_NO_INC; + if (tag->getBool("noexec", false)) + flags |= FLAG_NO_EXEC; + + const std::string includedir = ServerInstance->Config->Paths.PrependConfig(name); + std::vector<std::string> files; + if (!FileSystem::GetFileList(includedir, files, "*.conf")) + throw CoreException("Unable to read directory for include: " + includedir); + + std::sort(files.begin(), files.end()); + for (std::vector<std::string>::const_iterator iter = files.begin(); iter != files.end(); ++iter) + { + const std::string path = includedir + '/' + *iter; + if (!ParseFile(path, flags, mandatorytag)) + throw CoreException("Included"); + } + } else if (tag->readString("executable", name)) { if (flags & FLAG_NO_EXEC) @@ -405,6 +426,7 @@ void ParseStack::DoInclude(ConfigTag* tag, int flags) flags |= FLAG_NO_INC; if (tag->getBool("noexec", true)) flags |= FLAG_NO_EXEC; + if (!ParseFile(name, flags, mandatorytag, true)) throw CoreException("Included"); } |