[llvm] r315520 - Support: Work around missing SetFileInformationByHandle on Wine

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 15:04:14 PDT 2017


Author: hans
Date: Wed Oct 11 15:04:14 2017
New Revision: 315520

URL: http://llvm.org/viewvc/llvm-project?rev=315520&view=rev
Log:
Support: Work around missing SetFileInformationByHandle on Wine

In r315079, fs::rename was reimplemented in terms of CreateFile and
SetFileInformationByHandle. Unfortunately, the latter isn't supported by
Wine. This adds a fallback to MoveFileEx for that case.

Differential Revision: https://reviews.llvm.org/D38817

Modified:
    llvm/trunk/lib/Support/Windows/Path.inc

Modified: llvm/trunk/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=315520&r1=315519&r2=315520&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc (original)
+++ llvm/trunk/lib/Support/Windows/Path.inc Wed Oct 11 15:04:14 2017
@@ -413,6 +413,17 @@ std::error_code rename(const Twine &From
   // a true error, so stop trying.
   for (unsigned Retry = 0; Retry != 200; ++Retry) {
     auto EC = rename_internal(FromHandle, To, true);
+
+    if (EC ==
+        std::error_code(ERROR_CALL_NOT_IMPLEMENTED, std::system_category())) {
+      // Wine doesn't support SetFileInformationByHandle in rename_internal.
+      // Fall back to MoveFileEx.
+      if (::MoveFileExW(WideFrom.begin(), WideTo.begin(),
+                        MOVEFILE_REPLACE_EXISTING))
+        return std::error_code();
+      return mapWindowsError(GetLastError());
+    }
+
     if (!EC || EC != errc::permission_denied)
       return EC;
 




More information about the llvm-commits mailing list