mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 17:14:01 +02:00
merge revision(s) 49634,49658,49663: [Backport #10865]
* win32/win32.c (wrename): return EXDEV if moving a directory to another drive, since MoveFileExW does not set proper error code. [ruby-core:68162] [Bug #10865] * win32/win32.c (different_device_p): compare by volume serial numbers, not by path names. numbers, not by path names. [ruby-core:68162] [Bug #10865] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2098b5aea5
commit
4a670c2bb6
3 changed files with 45 additions and 3 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Sat Feb 21 13:48:11 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* win32/win32.c (different_device_p): compare by volume serial
|
||||||
|
numbers, not by path names. [ruby-core:68162] [Bug #10865]
|
||||||
|
|
||||||
|
Sat Feb 21 13:48:11 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* win32/win32.c (wrename): return EXDEV if moving a directory to
|
||||||
|
another drive, since MoveFileExW does not set proper error code.
|
||||||
|
[ruby-core:68162] [Bug #10865]
|
||||||
|
|
||||||
Sat Feb 21 12:46:51 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Feb 21 12:46:51 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* win32/file.c (rb_file_expand_path_internal): neither the drive
|
* win32/file.c (rb_file_expand_path_internal): neither the drive
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#define RUBY_VERSION "2.2.0"
|
#define RUBY_VERSION "2.2.0"
|
||||||
#define RUBY_RELEASE_DATE "2015-02-21"
|
#define RUBY_RELEASE_DATE "2015-02-21"
|
||||||
#define RUBY_PATCHLEVEL 72
|
#define RUBY_PATCHLEVEL 73
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2015
|
#define RUBY_RELEASE_YEAR 2015
|
||||||
#define RUBY_RELEASE_MONTH 2
|
#define RUBY_RELEASE_MONTH 2
|
||||||
|
|
|
@ -4701,6 +4701,31 @@ rb_w32_getenv(const char *name)
|
||||||
return w32_getenv(name, CP_ACP);
|
return w32_getenv(name, CP_ACP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* License: Ruby's */
|
||||||
|
static DWORD
|
||||||
|
get_volume_serial_number(const WCHAR *path)
|
||||||
|
{
|
||||||
|
const DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||||
|
const DWORD creation = OPEN_EXISTING;
|
||||||
|
const DWORD flags = FILE_FLAG_BACKUP_SEMANTICS;
|
||||||
|
BY_HANDLE_FILE_INFORMATION st = {0};
|
||||||
|
HANDLE h = CreateFileW(path, 0, share_mode, NULL, creation, flags, NULL);
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
if (h == INVALID_HANDLE_VALUE) return 0;
|
||||||
|
ret = GetFileInformationByHandle(h, &st);
|
||||||
|
CloseHandle(h);
|
||||||
|
if (!ret) return 0;
|
||||||
|
return st.dwVolumeSerialNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* License: Ruby's */
|
||||||
|
static int
|
||||||
|
different_device_p(const WCHAR *oldpath, const WCHAR *newpath)
|
||||||
|
{
|
||||||
|
return get_volume_serial_number(oldpath) != get_volume_serial_number(newpath);
|
||||||
|
}
|
||||||
|
|
||||||
/* License: Artistic or GPL */
|
/* License: Artistic or GPL */
|
||||||
static int
|
static int
|
||||||
wrename(const WCHAR *oldpath, const WCHAR *newpath)
|
wrename(const WCHAR *oldpath, const WCHAR *newpath)
|
||||||
|
@ -4724,8 +4749,14 @@ wrename(const WCHAR *oldpath, const WCHAR *newpath)
|
||||||
if (!MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
|
if (!MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
|
||||||
res = -1;
|
res = -1;
|
||||||
|
|
||||||
if (res)
|
if (res) {
|
||||||
errno = map_errno(GetLastError());
|
DWORD e = GetLastError();
|
||||||
|
if ((e == ERROR_ACCESS_DENIED) && (oldatts & FILE_ATTRIBUTE_DIRECTORY) &&
|
||||||
|
different_device_p(oldpath, newpath))
|
||||||
|
errno = EXDEV;
|
||||||
|
else
|
||||||
|
errno = map_errno(e);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
SetFileAttributesW(newpath, oldatts);
|
SetFileAttributesW(newpath, oldatts);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue