[PATCH] D57960: [Support] Fix TempFile::discard to not leave behind temporary files
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 14 03:08:51 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354017: [Support] Fix TempFile::discard to not leave behind temporary files (authored by anng, committed by ).
Herald added a subscriber: kristina.
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D57960?vs=186437&id=186807#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57960/new/
https://reviews.llvm.org/D57960
Files:
llvm/trunk/lib/Support/Path.cpp
Index: llvm/trunk/lib/Support/Path.cpp
===================================================================
--- llvm/trunk/lib/Support/Path.cpp
+++ llvm/trunk/lib/Support/Path.cpp
@@ -1128,26 +1128,27 @@
Error TempFile::discard() {
Done = true;
- std::error_code RemoveEC;
-// On windows closing will remove the file.
-#ifndef _WIN32
- // Always try to close and remove.
- if (!TmpName.empty()) {
- RemoveEC = fs::remove(TmpName);
- sys::DontRemoveFileOnSignal(TmpName);
- }
-#endif
-
- if (!RemoveEC)
- TmpName = "";
-
if (FD != -1 && close(FD) == -1) {
std::error_code EC = std::error_code(errno, std::generic_category());
return errorCodeToError(EC);
}
FD = -1;
+#ifdef _WIN32
+ // On windows closing will remove the file.
+ TmpName = "";
+ return Error::success();
+#else
+ // Always try to close and remove.
+ std::error_code RemoveEC;
+ if (!TmpName.empty()) {
+ RemoveEC = fs::remove(TmpName);
+ sys::DontRemoveFileOnSignal(TmpName);
+ if (!RemoveEC)
+ TmpName = "";
+ }
return errorCodeToError(RemoveEC);
+#endif
}
Error TempFile::keep(const Twine &Name) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57960.186807.patch
Type: text/x-patch
Size: 1133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190214/b40cf527/attachment.bin>
More information about the llvm-commits
mailing list