2018-08-02 17:08:24 -07:00
|
|
|
From ca172d5f44df90a62426572ef6f461b27bf57689 Mon Sep 17 00:00:00 2001
|
2016-11-15 11:27:21 -08:00
|
|
|
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
|
|
|
Date: Tue, 15 Nov 2016 13:02:13 +0800
|
2018-06-11 15:51:26 -07:00
|
|
|
Subject: [PATCH] kernel32: MoveFile(source, source) should succeed.
|
2016-11-15 11:27:21 -08:00
|
|
|
|
|
|
|
---
|
|
|
|
dlls/kernel32/path.c | 15 ++++++++++-----
|
|
|
|
dlls/kernel32/tests/file.c | 2 +-
|
|
|
|
dlls/msvcp120/tests/msvcp120.c | 2 +-
|
|
|
|
programs/cmd/tests/test_builtins.cmd.exp | 4 ++--
|
|
|
|
4 files changed, 14 insertions(+), 9 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
|
2018-08-02 17:08:24 -07:00
|
|
|
index bde58e9..c7c5cbd 100644
|
2016-11-15 11:27:21 -08:00
|
|
|
--- a/dlls/kernel32/path.c
|
|
|
|
+++ b/dlls/kernel32/path.c
|
2018-06-11 15:51:26 -07:00
|
|
|
@@ -1354,7 +1354,7 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
|
2016-11-15 11:27:21 -08:00
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
IO_STATUS_BLOCK io;
|
|
|
|
NTSTATUS status;
|
|
|
|
- HANDLE source_handle = 0, dest_handle;
|
|
|
|
+ HANDLE source_handle = 0, dest_handle = 0;
|
|
|
|
ANSI_STRING source_unix, dest_unix;
|
2018-08-02 17:08:24 -07:00
|
|
|
DWORD options;
|
2016-11-15 11:27:21 -08:00
|
|
|
|
2018-08-02 17:08:24 -07:00
|
|
|
@@ -1414,18 +1414,22 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
|
|
|
|
status = NtOpenFile( &dest_handle, GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, &attr, &io, 0, options );
|
2016-11-15 11:27:21 -08:00
|
|
|
if (status == STATUS_SUCCESS) /* destination exists */
|
|
|
|
{
|
|
|
|
- NtClose( dest_handle );
|
|
|
|
if (!(flag & MOVEFILE_REPLACE_EXISTING))
|
|
|
|
{
|
|
|
|
- SetLastError( ERROR_ALREADY_EXISTS );
|
|
|
|
- RtlFreeUnicodeString( &nt_name );
|
|
|
|
- goto error;
|
|
|
|
+ if (!is_same_file( source_handle, dest_handle ))
|
|
|
|
+ {
|
|
|
|
+ SetLastError( ERROR_ALREADY_EXISTS );
|
|
|
|
+ RtlFreeUnicodeString( &nt_name );
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
else if (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) /* cannot replace directory */
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_ACCESS_DENIED );
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ NtClose( dest_handle );
|
|
|
|
}
|
|
|
|
else if (status != STATUS_OBJECT_NAME_NOT_FOUND)
|
|
|
|
{
|
2018-08-02 17:08:24 -07:00
|
|
|
@@ -1485,6 +1489,7 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
|
2016-11-15 11:27:21 -08:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (source_handle) NtClose( source_handle );
|
|
|
|
+ if (dest_handle) NtClose( dest_handle );
|
|
|
|
RtlFreeAnsiString( &source_unix );
|
|
|
|
RtlFreeAnsiString( &dest_unix );
|
|
|
|
return FALSE;
|
|
|
|
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
|
2018-08-02 17:08:24 -07:00
|
|
|
index ef4eebc..07b3ffb 100644
|
2016-11-15 11:27:21 -08:00
|
|
|
--- a/dlls/kernel32/tests/file.c
|
|
|
|
+++ b/dlls/kernel32/tests/file.c
|
2018-06-11 15:51:26 -07:00
|
|
|
@@ -1886,7 +1886,7 @@ static void test_MoveFileA(void)
|
2016-11-15 11:27:21 -08:00
|
|
|
ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = MoveFileA(source, source);
|
|
|
|
- todo_wine ok(ret, "MoveFileA: failed, error %d\n", GetLastError());
|
|
|
|
+ ok(ret, "MoveFileA: failed, error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = MoveFileA(source, dest);
|
|
|
|
ok(!ret && GetLastError() == ERROR_ALREADY_EXISTS,
|
|
|
|
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
|
2018-08-02 17:08:24 -07:00
|
|
|
index db9517d..7275e28 100644
|
2016-11-15 11:27:21 -08:00
|
|
|
--- a/dlls/msvcp120/tests/msvcp120.c
|
|
|
|
+++ b/dlls/msvcp120/tests/msvcp120.c
|
2018-08-02 17:08:24 -07:00
|
|
|
@@ -1524,7 +1524,7 @@ static void test_tr2_sys__Rename(void)
|
2016-11-15 11:27:21 -08:00
|
|
|
CloseHandle(file);
|
|
|
|
|
|
|
|
ret = p_tr2_sys__Rename("tr2_test_dir\\f1", "tr2_test_dir\\f1");
|
|
|
|
- todo_wine ok(ERROR_SUCCESS == ret, "test_tr2_sys__Rename(): expect: ERROR_SUCCESS, got %d\n", ret);
|
|
|
|
+ ok(ERROR_SUCCESS == ret, "test_tr2_sys__Rename(): expect: ERROR_SUCCESS, got %d\n", ret);
|
2018-06-11 15:51:26 -07:00
|
|
|
for(i=0; i<ARRAY_SIZE(tests); i++) {
|
2016-11-15 11:27:21 -08:00
|
|
|
errno = 0xdeadbeef;
|
|
|
|
if(tests[i].val == ERROR_SUCCESS) {
|
|
|
|
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
|
2018-08-02 17:08:24 -07:00
|
|
|
index ea4157c..298c4e9 100644
|
2016-11-15 11:27:21 -08:00
|
|
|
--- a/programs/cmd/tests/test_builtins.cmd.exp
|
|
|
|
+++ b/programs/cmd/tests/test_builtins.cmd.exp
|
2018-08-02 17:08:24 -07:00
|
|
|
@@ -1295,8 +1295,8 @@ file move succeeded
|
2016-11-15 11:27:21 -08:00
|
|
|
@todo_wine@bar@or_broken@baz
|
|
|
|
read-only files are moveable
|
|
|
|
file moved in subdirectory
|
|
|
|
-@todo_wine@moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op!
|
|
|
|
-@todo_wine@ErrorLevel: 0@or_broken@ErrorLevel: 1
|
|
|
|
+moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op!
|
|
|
|
+ErrorLevel: 0@or_broken@ErrorLevel: 1
|
|
|
|
--- directory move
|
|
|
|
simple directory move succeeded
|
|
|
|
moving a directory to itself gives error; errlevel 1
|
|
|
|
--
|
2018-06-11 15:51:26 -07:00
|
|
|
1.9.1
|
2016-11-15 11:27:21 -08:00
|
|
|
|