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/modulemanager.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/modulemanager.cpp') diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index ada288e75..084d10172 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -25,6 +25,7 @@ #include "inspircd.h" #include "exitcodes.h" +#include #include bool ModuleManager::Load(const std::string& modname, bool defer) @@ -128,27 +129,30 @@ void ModuleManager::LoadCoreModules(std::map& servicem { std::cout << "Loading core modules " << std::flush; - std::vector files; - if (!FileSystem::GetFileList(ServerInstance->Config->Paths.Module, files, "core_*.so")) - { - std::cout << "failed!" << std::endl; - ServerInstance->Exit(EXIT_STATUS_MODULE); - } - - for (std::vector::const_iterator iter = files.begin(); iter != files.end(); ++iter) + try { - std::cout << "." << std::flush; + for (auto& entry : std::filesystem::directory_iterator(ServerInstance->Config->Paths.Module)) + { + const std::string name = entry.path().filename(); + if (!entry.is_regular_file() || !InspIRCd::Match(name, "core_*.so")) + continue; - const std::string& name = *iter; - this->NewServices = &servicemap[name]; + std::cout << "." << std::flush; + this->NewServices = &servicemap[name]; - if (!Load(name, true)) - { - ServerInstance->Logs.Log("MODULE", LOG_DEFAULT, this->LastError()); - std::cout << std::endl << "[" << con_red << "*" << con_reset << "] " << this->LastError() << std::endl << std::endl; - ServerInstance->Exit(EXIT_STATUS_MODULE); + if (!Load(name, true)) + { + ServerInstance->Logs.Log("MODULE", LOG_DEFAULT, this->LastError()); + std::cout << std::endl << "[" << con_red << "*" << con_reset << "] " << this->LastError() << std::endl << std::endl; + ServerInstance->Exit(EXIT_STATUS_MODULE); + } } } + catch (const std::filesystem::filesystem_error& err) + { + std::cout << "failed: " << err.what() << std::endl; + ServerInstance->Exit(EXIT_STATUS_MODULE); + } std::cout << std::endl; } -- cgit v1.3.1-10-gc9f91