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
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index 5f0adb3..b96396a 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -805,6 +805,22 @@
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> TempFile::create(const Twine &Model, unsigned Mode) {
int FD;
SmallString<128> ResultPath;