diff options
author | Adam <Adam@anope.org> | 2010-06-21 01:46:27 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-06-21 17:51:34 -0400 |
commit | f63aed908f4bbca7b89ce26a0116712fe01cf2f1 (patch) | |
tree | 4d6853e905aea594082cff6c5a469a17ac6321cf | |
parent | 8b9ba9676736d00c8fb97889b875420b641659a7 (diff) |
Fixed windows problems with clearing the runtime directory
-rw-r--r-- | src/module.cpp | 2 | ||||
-rw-r--r-- | src/modulemanager.cpp | 15 | ||||
-rw-r--r-- | src/modules.c | 32 | ||||
-rw-r--r-- | src/modules/m_helpchan.cpp | 2 |
4 files changed, 24 insertions, 27 deletions
diff --git a/src/module.cpp b/src/module.cpp index 70592112e..9fac3179e 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -59,8 +59,6 @@ Module::~Module() for (i = 0; i < NUM_LANGS; i++) this->DeleteLanguage(i); - remove(this->filename.c_str()); - int idx; CommandHash *current = NULL; diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index c4bceb119..69c74b64e 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -19,9 +19,7 @@ void ModuleManager::LoadModuleList(std::list<std::string> &ModuleList) { for (std::list<std::string>::iterator it = ModuleList.begin(); it != ModuleList.end(); ++it) { - Module *m = findModule(it->c_str()); - if (!m) - ModuleManager::LoadModule(*it, NULL); + ModuleManager::LoadModule(*it, NULL); } } @@ -53,11 +51,13 @@ static int moduleCopyFile(const char *name, const char *output) #ifndef _WIN32 if ((srcfp = mkstemp(const_cast<char *>(output))) == -1) - return MOD_ERR_FILE_IO; #else if (!mktemp(const_cast<char *>(output))) - return MOD_ERR_FILE_IO; #endif + { + fclose(source); + return MOD_ERR_FILE_IO; + } Alog(LOG_DEBUG) << "Runtime module location: " << output; @@ -66,6 +66,7 @@ static int moduleCopyFile(const char *name, const char *output) #else if ((target = fopen(output, "wb")) == NULL) { #endif + fclose(source); return MOD_ERR_FILE_IO; } while ((ch = fgetc(source)) != EOF) { @@ -291,6 +292,7 @@ void ModuleManager::DeleteModule(Module *m) DetachAll(m); handle = m->handle; + std::string filename = m->filename; ano_modclearerr(); destroy_func = function_cast<void (*)(Module *)>(dlsym(m->handle, "destroy_module")); @@ -309,6 +311,9 @@ void ModuleManager::DeleteModule(Module *m) if ((dlclose(handle)) != 0) Alog() << dlerror(); } + + if (!filename.empty()) + DeleteFile(filename.c_str()); } bool ModuleManager::Attach(Implementation i, Module* mod) diff --git a/src/modules.c b/src/modules.c index 55085ccd3..6169b7b86 100644 --- a/src/modules.c +++ b/src/modules.c @@ -717,16 +717,6 @@ void Module::DeleteLanguage(int langNumber) void ModuleRunTimeDirCleanUp() { -#ifndef _WIN32 - DIR *dirp; - struct dirent *dp; -#else - BOOL fFinished; - HANDLE hList; - TCHAR szDir[MAX_PATH + 1]; - WIN32_FIND_DATA FileData; - char buffer[_MAX_PATH]; -#endif char dirbuf[BUFSIZE]; char filebuf[BUFSIZE]; @@ -736,9 +726,12 @@ void ModuleRunTimeDirCleanUp() #ifndef _WIN32 + DIR *dirp; + struct dirent *dp; + if ((dirp = opendir(dirbuf)) == NULL) { - Alog(LOG_DEBUG) << "cannot open directory (" << dirbuf << ")"; + Alog(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")"; return; } while ((dp = readdir(dirp)) != NULL) { @@ -749,16 +742,16 @@ void ModuleRunTimeDirCleanUp() continue; } snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, dp->d_name); - unlink(filebuf); + DeleteFile(filebuf); } closedir(dirp); #else - /* Get the current working directory: */ - if (_getcwd(buffer, _MAX_PATH) == NULL) - { - Alog(LOG_DEBUG) << "Unable to set Current working directory"; - } - snprintf(szDir, sizeof(szDir), "%s\\%s\\*", buffer, dirbuf); + BOOL fFinished; + HANDLE hList; + TCHAR szDir[MAX_PATH + 1]; + WIN32_FIND_DATA FileData; + + snprintf(szDir, sizeof(szDir), "%s/*", dirbuf); hList = FindFirstFile(szDir, &FileData); if (hList != INVALID_HANDLE_VALUE) { @@ -766,7 +759,8 @@ void ModuleRunTimeDirCleanUp() while (!fFinished) { if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, FileData.cFileName); - DeleteFile(filebuf); + if (!DeleteFile(filebuf)) + Alog(LOG_DEBUG) << "Error deleting file " << filebuf << " - GetLastError() reports " << dlerror(); } if (!FindNextFile(hList, &FileData)) { if (GetLastError() == ERROR_NO_MORE_FILES) { diff --git a/src/modules/m_helpchan.cpp b/src/modules/m_helpchan.cpp index 6255d5012..2fff5bdab 100644 --- a/src/modules/m_helpchan.cpp +++ b/src/modules/m_helpchan.cpp @@ -31,7 +31,7 @@ class HelpChannel : public Module User *u = finduser(param); if (u) - u->SetMode(OperServ, UMODE_HELPOP); + u->SetMode(findbot(Config.s_OperServ), UMODE_HELPOP); } return EVENT_CONTINUE; |