mirror of
https://github.com/anope/anope.git
synced 2026-06-27 22:56:38 +02:00
Fixed windows problems with clearing the runtime directory
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
+10
-5
@@ -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)
|
||||
|
||||
+13
-19
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user