[前][次][番号順一覧][スレッド一覧]

ruby-changes:27949

From: usa <ko1@a...>
Date: Sat, 30 Mar 2013 03:53:02 +0900 (JST)
Subject: [ruby-changes:27949] usa:r40001 (trunk): * win32/win32.c (wrename): use MoveFileExW instead of MoveFileW,

usa	2013-03-30 03:52:51 +0900 (Sat, 30 Mar 2013)

  New Revision: 40001

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40001

  Log:
    * 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)

  Modified files:
    trunk/ChangeLog
    trunk/win32/win32.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40000)
+++ ChangeLog	(revision 40001)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Mar 30 03:49:21 2013  NAKAMURA Usaku  <usa@r...>
+
+	* 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  <nobu@r...>
 
 	* thread.c (rb_mutex_synchronize_m): yield no block params.  patch by
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 40000)
+++ win32/win32.c	(revision 40001)
@@ -4344,18 +4344,9 @@ wrename(const WCHAR *oldpath, const WCHA https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4344
 	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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]