diff options
| author | 2023-07-03 17:26:40 +0100 | |
|---|---|---|
| committer | 2023-07-03 18:43:58 +0100 | |
| commit | 386f0dafd55897723356c75299cd02ed0b882f5b (patch) | |
| tree | be31de75870a0e1da815cf5f4203fed793eb66ba /src/modules/m_showfile.cpp | |
| parent | Fix a minor Doxygen comment issue. (diff) | |
Replace FileReader with something more sensible.
Diffstat (limited to 'src/modules/m_showfile.cpp')
| -rw-r--r-- | src/modules/m_showfile.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/modules/m_showfile.cpp b/src/modules/m_showfile.cpp index 8273885a2..60a3f4a92 100644 --- a/src/modules/m_showfile.cpp +++ b/src/modules/m_showfile.cpp @@ -20,7 +20,6 @@ #include "inspircd.h" #include "clientprotocolmsg.h" -#include "fileutils.h" enum { @@ -80,7 +79,7 @@ public: return CmdResult::SUCCESS; } - void UpdateSettings(const std::shared_ptr<ConfigTag>& tag, const std::vector<std::string>& filecontents) + void UpdateSettings(const std::shared_ptr<ConfigTag>& tag, const std::string& filecontents) { introtext = tag->getString("introtext", "Showing " + name); endtext = tag->getString("endtext", "End of " + name); @@ -97,8 +96,9 @@ public: // Process the entry. contents.clear(); - contents.reserve(filecontents.size()); - for (const auto& line : filecontents) + + irc::sepstream linestream(filecontents, '\n'); + for (std::string line; linestream.GetToken(line); ) { // Some clients can not handle receiving NOTICE/PRIVMSG/RPL_RULES // with an empty trailing parameter so if a line is empty we @@ -106,6 +106,7 @@ public: contents.push_back(line.empty() ? " " : line); } InspIRCd::ProcessColors(contents); + contents.shrink_to_fit(); } }; @@ -126,7 +127,10 @@ private: const std::string file = tag->getString("file", cmdname); if (file.empty()) throw ModuleException(this, "Empty value for 'file'"); - FileReader reader(file); + + auto reader = ServerInstance->Config->ReadFile(file); + if (!reader) + throw ModuleException(this, "Unable to read " + file + ": " + reader.error); CommandShowFile* sfcmd; Command* handler = ServerInstance->Parser.GetHandler(cmdname); @@ -148,7 +152,7 @@ private: ServerInstance->Modules.AddService(*sfcmd); } - sfcmd->UpdateSettings(tag, reader.GetVector()); + sfcmd->UpdateSettings(tag, reader.contents); newcmds.push_back(sfcmd); } |
