diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-10-11 22:04:14 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-10-11 22:04:14 +0000 |
commit | b4627db34f35839793634be9f0ae36d0ecc0871f (patch) | |
tree | b062ba309b5b04348f386a13c0162c257b7b7fcb | |
parent | c6786861d6b0eef92baad1880c6807d2a78bff74 (diff) | |
download | llvm-b4627db34f35839793634be9f0ae36d0ecc0871f.tar.gz |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315520 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Support/Windows/Path.inc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc index 94cb2e422c5..5866f9a403a 100644 --- a/lib/Support/Windows/Path.inc +++ b/lib/Support/Windows/Path.inc @@ -413,6 +413,17 @@ std::error_code rename(const Twine &From, const Twine &To) { // 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; |