summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-04 13:42:25 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-04 13:42:25 +0000
commitc632c925708d7c0d7d9ea23dfaa48e8ee2994020 (patch)
tree5e1246ac07c4c8241aaa15c32331a45d84c234dc /win32
parent9a37bfceecc4018146de0df51d1c70ee77e28279 (diff)
merge revision(s) 40001: [Backport #8109]
* 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_2_0_0@42375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 7e151d498e..c284194577 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4344,18 +4344,9 @@ wrename(const WCHAR *oldpath, const WCHAR *newpath)
if (newatts != -1 && newatts & FILE_ATTRIBUTE_READONLY)
SetFileAttributesW(newpath, newatts & ~ FILE_ATTRIBUTE_READONLY);
- if (!MoveFileW(oldpath, newpath))
+ if (!MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
res = -1;
- if (res) {
- switch (GetLastError()) {
- case ERROR_ALREADY_EXISTS:
- case ERROR_FILE_EXISTS:
- if (MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING))
- res = 0;
- }
- }
-
if (res)
errno = map_errno(GetLastError());
else