From 35cc29c872adf66b97f7707cec54601dd1ae3698 Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 29 Mar 2013 18:52:51 +0000 Subject: [PATCH] * 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/trunk@40001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ win32/win32.c | 11 +---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c84799da0..c5baab1757 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Mar 30 03:49:21 2013 NAKAMURA Usaku + + * 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) + Fri Mar 29 22:09:46 2013 Nobuyoshi Nakada * thread.c (rb_mutex_synchronize_m): yield no block params. patch by diff --git a/win32/win32.c b/win32/win32.c index 9852c907e6..07be935077 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