aboutsummaryrefslogtreecommitdiff
path: root/src/configparser.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-05-14 21:42:48 +0100
committerGravatar Sadie Powell2020-05-19 19:45:06 +0100
commit7c126a98e4735cb9ecda35085ed38097c07d03e9 (patch)
treeb1544720e9d5aa86fd40ffda5db7af35b0f76ba9 /src/configparser.cpp
parentFix parsing <security:announceinvites>. (diff)
Replace FileSystem::GetFileList with std::filesystem.
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r--src/configparser.cpp25
1 files changed, 16 insertions, 9 deletions
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 <filesystem>
#include <fstream>
+
+#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<std::string> 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<std::string>::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)