From 386f0dafd55897723356c75299cd02ed0b882f5b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 3 Jul 2023 17:26:40 +0100 Subject: Replace FileReader with something more sensible. --- src/modules/m_opermotd.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/modules/m_opermotd.cpp') diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp index 7a844d8cd..c61d979ff 100644 --- a/src/modules/m_opermotd.cpp +++ b/src/modules/m_opermotd.cpp @@ -25,7 +25,6 @@ #include "inspircd.h" -#include "fileutils.h" enum { @@ -104,23 +103,19 @@ private: if (motd.empty() || newmotds.find(motd) != newmotds.end()) return; - FileReader reader; - try - { - reader.Load(motd); - } - catch (const CoreException& ce) + auto file = ServerInstance->Config->ReadFile(motd); + if (!file) { // We can't process the file if it doesn't exist. ServerInstance->Logs.Normal(MODNAME, "Unable to read server operator motd for oper {} \"{}\" at {}: {}", - type, oper->GetName(), oper->GetConfig()->source.str(), ce.GetReason()); + type, oper->GetName(), oper->GetConfig()->source.str(), file.error); return; } // Process the MOTD entry. auto& newmotd = newmotds[motd]; - newmotd.reserve(reader.GetVector().size()); - for (const auto& line : reader.GetVector()) + irc::sepstream linestream(file.contents, '\n'); + for (std::string line; linestream.GetToken(line); ) { // Some clients can not handle receiving RPL_OMOTD with an empty // trailing parameter so if a line is empty we replace it with -- cgit v1.3.1-10-gc9f91