diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-11-16 21:40:10 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-11-16 21:40:10 +0000 |
commit | b60bb6904b63fb254f39441939dc8fdc6e3e0c78 (patch) | |
tree | 5e9e0411efa93410052d6587e0897c59f1328bab /llvm/lib/Support/Path.cpp | |
parent | 2758fa8710d5fef5f9787b7dd1039d72209f5ec4 (diff) | |
download | bcm5719-llvm-b60bb6904b63fb254f39441939dc8fdc6e3e0c78.tar.gz bcm5719-llvm-b60bb6904b63fb254f39441939dc8fdc6e3e0c78.zip |
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
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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> TempFile::create(const Twine &Model, unsigned Mode) { int FD; SmallString<128> ResultPath; |