diff options
Diffstat (limited to 'src/modulemanager.cpp')
-rw-r--r-- | src/modulemanager.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 3317a6f09..0ef2421e6 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -15,11 +15,12 @@ #include <sys/types.h> #include <sys/stat.h> #ifndef _WIN32 -#include <dirent.h> #include <sys/types.h> #include <dlfcn.h> #endif +#include <filesystem> + std::list<Module *> ModuleManager::Modules; std::vector<Module *> ModuleManager::EventHandlers[I_SIZE]; @@ -29,25 +30,18 @@ void ModuleManager::CleanupRuntimeDirectory() Anope::string dirbuf = Anope::DataDir + "/runtime"; Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment, please wait"; - - DIR *dirp = opendir(dirbuf.c_str()); - if (!dirp) + try { - Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")"; - return; + for (const auto &entry : std::filesystem::directory_iterator(dirbuf.str())) + { + if (entry.is_regular_file()) + std::filesystem::remove(entry); + } } - - for (dirent *dp; (dp = readdir(dirp));) + catch (const std::filesystem::filesystem_error &err) { - if (!dp->d_ino) - continue; - if (Anope::string(dp->d_name).equals_cs(".") || Anope::string(dp->d_name).equals_cs("..")) - continue; - Anope::string filebuf = dirbuf + "/" + dp->d_name; - unlink(filebuf.c_str()); + Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << "): " << err.what(); } - - closedir(dirp); } /** |