Skip to content

Commit

Permalink
Work around lack of Wine support for SetFileInformationByHandle harder
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zmodem committed Oct 12, 2017
1 parent 499a404 commit 7e51356
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Support/Windows/Path.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 7e51356

Please sign in to comment.