diff options
| author | 2020-05-14 21:42:48 +0100 | |
|---|---|---|
| committer | 2020-05-19 19:45:06 +0100 | |
| commit | 7c126a98e4735cb9ecda35085ed38097c07d03e9 (patch) | |
| tree | b1544720e9d5aa86fd40ffda5db7af35b0f76ba9 /src/modulemanager.cpp | |
| parent | Fix parsing <security:announceinvites>. (diff) | |
Replace FileSystem::GetFileList with std::filesystem.
Diffstat (limited to 'src/modulemanager.cpp')
| -rw-r--r-- | src/modulemanager.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
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 <filesystem> #include <iostream> bool ModuleManager::Load(const std::string& modname, bool defer) @@ -128,27 +129,30 @@ void ModuleManager::LoadCoreModules(std::map<std::string, ServiceList>& servicem { std::cout << "Loading core modules " << std::flush; - std::vector<std::string> files; - if (!FileSystem::GetFileList(ServerInstance->Config->Paths.Module, files, "core_*.so")) - { - std::cout << "failed!" << std::endl; - ServerInstance->Exit(EXIT_STATUS_MODULE); - } - - for (std::vector<std::string>::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; } |
