mirror of
https://github.com/anope/anope.git
synced 2026-07-05 21:13:13 +02:00
Fixed windows problems with clearing the runtime directory
This commit is contained in:
+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) {
|
||||
|
||||
Reference in New Issue
Block a user