ToolOutputFile.cpp [plain text]
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Signals.h"
using namespace llvm;
tool_output_file::CleanupInstaller::CleanupInstaller(const char *filename)
: Filename(filename), Keep(false) {
if (Filename != "-")
sys::RemoveFileOnSignal(Filename);
}
tool_output_file::CleanupInstaller::~CleanupInstaller() {
if (!Keep && Filename != "-")
sys::fs::remove(Filename);
if (Filename != "-")
sys::DontRemoveFileOnSignal(Filename);
}
tool_output_file::tool_output_file(const char *filename, std::string &ErrorInfo,
sys::fs::OpenFlags Flags)
: Installer(filename), OS(filename, ErrorInfo, Flags) {
if (!ErrorInfo.empty())
Installer.Keep = true;
}
tool_output_file::tool_output_file(const char *Filename, int FD)
: Installer(Filename), OS(FD, true) {
}