Use llvm::sys::Path to destroy the file.

Patch contributed by Jeff Cohen. Thanks Jeff!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16564 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2004-09-28 23:58:03 +00:00
parent 10366a4ad9
commit ced4110f5b
2 changed files with 10 additions and 8 deletions

View File

@ -13,6 +13,7 @@
#include "Win32.h"
#include <llvm/System/Signals.h>
#include <stdio.h>
#include <vector>
#ifdef __MINGW_H
@ -29,7 +30,7 @@
static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep);
static BOOL WINAPI LLVMConsoleCtrlHandler(DWORD dwCtrlType);
static std::vector<std::string> *FilesToRemove = NULL;
static std::vector<llvm::sys::Path> *FilesToRemove = NULL;
static std::vector<llvm::sys::Path> *DirectoriesToRemove = NULL;
static bool RegisteredUnhandledExceptionFilter = false;
static bool CleanupExecuted = false;
@ -78,9 +79,9 @@ void sys::RemoveFileOnSignal(const std::string &Filename) {
throw std::string("Process terminating -- cannot register for removal");
if (FilesToRemove == NULL)
FilesToRemove = new std::vector<std::string>;
FilesToRemove = new std::vector<sys::Path>;
FilesToRemove->push_back(Filename);
FilesToRemove->push_back(sys::Path(Filename));
LeaveCriticalSection(&CriticalSection);
}
@ -123,7 +124,7 @@ static void Cleanup() {
if (FilesToRemove != NULL)
while (!FilesToRemove->empty()) {
try {
std::remove(FilesToRemove->back().c_str());
FilesToRemove->back().destroy_file();
} catch (...) {
}
FilesToRemove->pop_back();

View File

@ -13,6 +13,7 @@
#include "Win32.h"
#include <llvm/System/Signals.h>
#include <stdio.h>
#include <vector>
#ifdef __MINGW_H
@ -29,7 +30,7 @@
static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep);
static BOOL WINAPI LLVMConsoleCtrlHandler(DWORD dwCtrlType);
static std::vector<std::string> *FilesToRemove = NULL;
static std::vector<llvm::sys::Path> *FilesToRemove = NULL;
static std::vector<llvm::sys::Path> *DirectoriesToRemove = NULL;
static bool RegisteredUnhandledExceptionFilter = false;
static bool CleanupExecuted = false;
@ -78,9 +79,9 @@ void sys::RemoveFileOnSignal(const std::string &Filename) {
throw std::string("Process terminating -- cannot register for removal");
if (FilesToRemove == NULL)
FilesToRemove = new std::vector<std::string>;
FilesToRemove = new std::vector<sys::Path>;
FilesToRemove->push_back(Filename);
FilesToRemove->push_back(sys::Path(Filename));
LeaveCriticalSection(&CriticalSection);
}
@ -123,7 +124,7 @@ static void Cleanup() {
if (FilesToRemove != NULL)
while (!FilesToRemove->empty()) {
try {
std::remove(FilesToRemove->back().c_str());
FilesToRemove->back().destroy_file();
} catch (...) {
}
FilesToRemove->pop_back();