From 7e513564e2ae1e24fb65f93c724c83fb01331ce7 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Thu, 12 Oct 2017 17:38:22 +0000 Subject: [PATCH] Work around lack of Wine support for SetFileInformationByHandle harder In r315079 I added a check for the ERROR_CALL_NOT_IMPLEMENTED error code, but it turns out earlier versions of Wine just returned false without setting any error code. This patch handles the unset error code case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315597 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Windows/Path.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc index 5866f9a403a..31462633ee8 100644 --- a/lib/Support/Windows/Path.inc +++ b/lib/Support/Windows/Path.inc @@ -377,9 +377,14 @@ static std::error_code rename_internal(HANDLE FromHandle, const Twine &To, RenameInfo.FileNameLength = ToWide.size(); std::copy(ToWide.begin(), ToWide.end(), &RenameInfo.FileName[0]); + SetLastError(ERROR_SUCCESS); if (!SetFileInformationByHandle(FromHandle, FileRenameInfo, &RenameInfo, - RenameInfoBuf.size())) - return mapWindowsError(GetLastError()); + RenameInfoBuf.size())) { + unsigned Error = GetLastError(); + if (Error == ERROR_SUCCESS) + Error = ERROR_CALL_NOT_IMPLEMENTED; // Wine doesn't always set error code. + return mapWindowsError(Error); + } return std::error_code(); } -- 2.40.0