summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/Path.inc
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2017-10-11 22:04:14 +0000
committerHans Wennborg <hans@hanshq.net>2017-10-11 22:04:14 +0000
commit17701ab5bd9e4137cbab32ea9a1ccd1e8dc2aa71 (patch)
tree46d9bec48b318506710d6cabdcac3cfa4a45ba66 /llvm/lib/Support/Windows/Path.inc
parent6f1ae631f77bc3f7549ff7fecb4caa6e40591dc6 (diff)
downloadbcm5719-llvm-17701ab5bd9e4137cbab32ea9a1ccd1e8dc2aa71.tar.gz
bcm5719-llvm-17701ab5bd9e4137cbab32ea9a1ccd1e8dc2aa71.zip
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 llvm-svn: 315520
Diffstat (limited to 'llvm/lib/Support/Windows/Path.inc')
-rw-r--r--llvm/lib/Support/Windows/Path.inc11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 94cb2e422c5..5866f9a403a 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/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;
OpenPOWER on IntegriCloud