From 7c126a98e4735cb9ecda35085ed38097c07d03e9 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 14 May 2020 21:42:48 +0100 Subject: Replace FileSystem::GetFileList with std::filesystem. --- src/configparser.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/configparser.cpp') diff --git a/src/configparser.cpp b/src/configparser.cpp index dfc619eb4..e045d7e67 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -23,8 +23,10 @@ */ -#include "inspircd.h" +#include #include + +#include "inspircd.h" #include "configparser.h" enum ParseFlags @@ -411,18 +413,23 @@ void ParseStack::DoInclude(ConfigTag* tag, int flags) flags |= FLAG_NO_ENV; const std::string includedir = ServerInstance->Config->Paths.PrependConfig(name); - std::vector files; - if (!FileSystem::GetFileList(includedir, files, "*.conf")) - throw CoreException("Unable to read directory for include: " + includedir); + try + { + for (auto& entry : std::filesystem::directory_iterator(includedir)) + { + if (!entry.is_regular_file() || !InspIRCd::Match(entry.path().filename(), "*.conf")) + continue; - std::sort(files.begin(), files.end()); - for (std::vector::const_iterator iter = files.begin(); iter != files.end(); ++iter) + if (!ParseFile(entry.path().string(), flags, mandatorytag)) + throw CoreException("Included"); + } + } + catch (const std::filesystem::filesystem_error& err) { - const std::string path = includedir + '/' + *iter; - if (!ParseFile(path, flags, mandatorytag)) - throw CoreException("Included"); + throw CoreException("Unable to read directory for include " + includedir + ": " + err.what()); } } + else if (tag->readString("executable", name)) { if (flags & FLAG_NO_EXEC) -- cgit v1.3.1-10-gc9f91