kernelbase: Reset last error on success in CopyFileExW().

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2022-04-11 21:44:36 +03:00 committed by Alexandre Julliard
parent d72d596070
commit 02faaea93b
3 changed files with 9 additions and 1 deletions

View File

@ -899,8 +899,15 @@ static void test_CopyFileW(void)
ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
"CopyFileW: unexpected error %ld\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CopyFileW(source, dest, FALSE);
ok(ret, "CopyFileW: error %ld\n", GetLastError());
ok(GetLastError() == ERROR_SUCCESS, "Unexpected error %lu.\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CopyFileExW(source, dest, NULL, NULL, NULL, 0 );
ok(ret, "CopyFileExW: error %ld\n", GetLastError());
ok(GetLastError() == ERROR_SUCCESS, "Unexpected error %lu.\n", GetLastError());
ret = DeleteFileW(source);
ok(ret, "DeleteFileW: error %ld\n", GetLastError());

View File

@ -588,6 +588,7 @@ done:
HeapFree( GetProcessHeap(), 0, buffer );
CloseHandle( h1 );
CloseHandle( h2 );
if (ret) SetLastError( 0 );
return ret;
}

View File

@ -1619,7 +1619,7 @@ static void test_Copy_file(void)
SetLastError(0xdeadbeef);
ret = p_Copy_file(L"wine_test_dir/f1", L"wine_test_dir/f3");
ok(ret == ERROR_SUCCESS, "Got unexpected ret %lu.\n", ret);
todo_wine ok(GetLastError() == ret, "Got unexpected err %lu.\n", GetLastError());
ok(GetLastError() == ret, "Got unexpected err %lu.\n", GetLastError());
SetLastError(0xdeadbeef);
ret = p_Copy_file(L"wine_test_dir/missing", L"wine_test_dir/f3");