Project

General

Profile

Actions

Backport #8609

closed

FileUtils.mv fails across devices on Windows

Added by luislavena (Luis Lavena) over 11 years ago. Updated over 11 years ago.

Status:
Closed

Description

Reproduction code: https://gist.github.com/luislavena/5179408

The issue is that Ruby is using MoveFile under the covers: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365239(v=vs.85).aspx

Quote directly from the MoveFile docs: "The one caveat is that the MoveFile function will fail on directory moves when the destination is on a different volume."

Instead, MoveFileEx should be used with the MOVEFILE_COPY_ALLOWED flag. This function has existed since XP, and since Ruby 1.9 is XP+, we can safely switch to this: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365240(v=vs.85).aspx

The MoveFileEx call with the proper flag will just do the right thing.


Related issues 1 (0 open1 closed)

Related to Backport200 - Backport #8109: FileUtils.mv fails across devices on WindowsClosednagachika (Tomoyuki Chikanaga)03/18/2013Actions
Actions #1

Updated by luislavena (Luis Lavena) over 11 years ago

Please backport r40001 to Ruby 1.9.3 so File.rename work across devices.

Thank you.

Actions #2

Updated by usa (Usaku NAKAMURA) over 11 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r42460.
Luis, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


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)
Actions

Also available in: Atom PDF

Like0
Like0Like0