diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-09 06:53:33 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-09 06:53:33 +0000 |
commit | e6716b5e38003a595254abbf92757e5a98cf287a (patch) | |
tree | 3e03b3400ed43c8555e5310d570777c416c82466 /win32 | |
parent | d8a84ddbf3715ae64a38bfd4bc547e33f9e13d58 (diff) |
merge revision(s) 40001: [Backport #8609]
* win32/win32.c (wrename): use MoveFileExW instead of MoveFileW,
because the latter fails on cross device file move of some
environments.
fix [ruby-core:53492] [Bug #8109]
reported by mitchellh (Mitchell Hashimoto)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@42460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/win32/win32.c b/win32/win32.c index fbf35664b6..e04edccd8a 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4023,18 +4023,18 @@ wrename(const WCHAR *oldpath, const WCHAR *newpath) if (newatts != -1 && newatts & FILE_ATTRIBUTE_READONLY) SetFileAttributesW(newpath, newatts & ~ FILE_ATTRIBUTE_READONLY); - if (!MoveFileW(oldpath, newpath)) - res = -1; - - if (res) { - switch (GetLastError()) { - case ERROR_ALREADY_EXISTS: - case ERROR_FILE_EXISTS: - if (IsWinNT()) { - if (MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING)) - res = 0; - } - else { + if (IsWinNT()) { + if (!MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED)) + res = -1; + } + else { + if (!MoveFileW(oldpath, newpath)) + res = -1; + + if (res) { + switch (GetLastError()) { + case ERROR_ALREADY_EXISTS: + case ERROR_FILE_EXISTS: for (;;) { if (!DeleteFileW(newpath) && GetLastError() != ERROR_FILE_NOT_FOUND) break; |