From b60bb6904b63fb254f39441939dc8fdc6e3e0c78 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 16 Nov 2017 21:40:10 +0000 Subject: Convert another use of createUniqueFile to TempFile::create. This one requires a new small feature in TempFile: the ability to keep the temporary file with the temporary name. llvm-svn: 318458 --- llvm/lib/Support/Path.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'llvm/lib/Support/Path.cpp') diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 5f0adb337b9..b96396a3846 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -805,6 +805,22 @@ Error TempFile::keep(const Twine &Name) { return errorCodeToError(RenameEC); } +Error TempFile::keep() { + assert(!Done); + Done = true; + + sys::DontRemoveFileOnSignal(TmpName); + TmpName = ""; + + if (close(FD) == -1) { + std::error_code EC(errno, std::generic_category()); + return errorCodeToError(EC); + } + FD = -1; + + return Error::success(); +} + Expected TempFile::create(const Twine &Model, unsigned Mode) { int FD; SmallString<128> ResultPath; -- cgit v1.2.3