Commit d72d5960 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

msvcp140: Implement _Copy_file().

parent fa09e3f3
......@@ -3632,7 +3632,7 @@
@ cdecl _Cnd_timedwait(ptr ptr ptr)
@ cdecl _Cnd_unregister_at_thread_exit(ptr)
@ cdecl _Cnd_wait(ptr ptr)
@ stub _Copy_file
@ cdecl _Copy_file(wstr wstr)
@ stub _Cosh
@ cdecl _Current_get(ptr)
@ cdecl _Current_set(wstr) tr2_sys__Current_set_wchar
......
......@@ -227,6 +227,7 @@ static int (__cdecl *p__Xtime_diff_to_millis2)(const xtime*, const xtime*);
static int (__cdecl *p_xtime_get)(xtime*, int);
static void (__cdecl *p_Close_dir)(void*);
static DWORD (__cdecl *p_Copy_file)(WCHAR const *, WCHAR const *);
static MSVCP_bool (__cdecl *p_Current_get)(WCHAR *);
static MSVCP_bool (__cdecl *p_Current_set)(WCHAR const *);
static int (__cdecl *p_Equivalent)(WCHAR const*, WCHAR const*);
......@@ -338,6 +339,7 @@ static BOOL init(void)
SET(p_xtime_get, "xtime_get");
SET(p_Close_dir, "_Close_dir");
SET(p_Copy_file, "_Copy_file");
SET(p_Current_get, "_Current_get");
SET(p_Current_set, "_Current_set");
SET(p_Equivalent, "_Equivalent");
......@@ -1575,6 +1577,65 @@ static void test_cnd(void)
CloseHandle(cm.initialized);
}
static void test_Copy_file(void)
{
WCHAR origin_path[MAX_PATH], temp_path[MAX_PATH];
HANDLE file;
DWORD ret;
GetCurrentDirectoryW(MAX_PATH, origin_path);
GetTempPathW(MAX_PATH, temp_path);
ok(SetCurrentDirectoryW(temp_path), "SetCurrentDirectoryW to temp_path failed\n");
CreateDirectoryW(L"wine_test_dir", NULL);
file = CreateFileW(L"wine_test_dir/f1", 0, 0, NULL, CREATE_NEW, 0, NULL);
ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n");
ok(CloseHandle(file), "CloseHandle\n");
file = CreateFileW(L"wine_test_dir/f2", 0, 0, NULL, CREATE_NEW, 0, NULL);
ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n");
ok(CloseHandle(file), "CloseHandle\n");
SetFileAttributesW(L"wine_test_dir/f2", FILE_ATTRIBUTE_READONLY);
ok(CreateDirectoryW(L"wine_test_dir/d1", NULL) || GetLastError() == ERROR_ALREADY_EXISTS,
"CreateDirectoryW failed.\n");
SetLastError(0xdeadbeef);
ret = p_Copy_file(L"wine_test_dir/f1", L"wine_test_dir/d1");
ok(ret == ERROR_ACCESS_DENIED, "Got unexpected ret %lu.\n", ret);
ok(GetLastError() == ret, "Got unexpected err %lu.\n", GetLastError());
SetLastError(0xdeadbeef);
ret = p_Copy_file(L"wine_test_dir/f1", L"wine_test_dir/f2");
ok(ret == ERROR_ACCESS_DENIED, "Got unexpected ret %lu.\n", ret);
ok(GetLastError() == ret, "Got unexpected err %lu.\n", GetLastError());
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);
ok(GetLastError() == ret, "Got unexpected err %lu.\n", GetLastError());
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());
SetLastError(0xdeadbeef);
ret = p_Copy_file(L"wine_test_dir/missing", L"wine_test_dir/f3");
ok(ret == ERROR_FILE_NOT_FOUND, "Got unexpected ret %lu.\n", ret);
ok(GetLastError() == ret, "Got unexpected err %lu.\n", GetLastError());
ok(RemoveDirectoryW(L"wine_test_dir/d1"), "expect wine_test_dir to exist\n");
ok(DeleteFileW(L"wine_test_dir/f1"), "expect wine_test_dir/f1 to exist\n");
SetFileAttributesW(L"wine_test_dir/f2", FILE_ATTRIBUTE_NORMAL);
ok(DeleteFileW(L"wine_test_dir/f2"), "expect wine_test_dir/f2 to exist\n");
ok(DeleteFileW(L"wine_test_dir/f3"), "expect wine_test_dir/f3 to exist\n");
ok(RemoveDirectoryW(L"wine_test_dir"), "expect wine_test_dir to exist\n");
ok(SetCurrentDirectoryW(origin_path), "SetCurrentDirectoryW to origin_path failed\n");
}
START_TEST(msvcp140)
{
if(!init()) return;
......@@ -1601,5 +1662,6 @@ START_TEST(msvcp140)
test__Syserror_map();
test_Equivalent();
test_cnd();
test_Copy_file();
FreeLibrary(msvcp);
}
......@@ -15776,6 +15776,17 @@ enum file_type __cdecl _Stat(WCHAR const* path, int* permissions)
return (attr & FILE_ATTRIBUTE_DIRECTORY) ? directory_file : regular_file;
}
/* _Copy_file, msvcp140 version */
DWORD __cdecl _Copy_file(WCHAR const* src, WCHAR const* dst)
{
TRACE("src %s, dst %s.\n", debugstr_w(src), debugstr_w(dst));
if (CopyFileW(src, dst, FALSE))
return ERROR_SUCCESS;
return GetLastError();
}
/* ?_Lstat@sys@tr2@std@@YA?AW4file_type@123@PB_WAAH@Z */
/* ?_Lstat@sys@tr2@std@@YA?AW4file_type@123@PEB_WAEAH@Z */
enum file_type __cdecl tr2_sys__Lstat_wchar(WCHAR const* path, int* err_code)
......
......@@ -3632,7 +3632,7 @@
@ cdecl _Cnd_timedwait(ptr ptr ptr) msvcp140._Cnd_timedwait
@ cdecl _Cnd_unregister_at_thread_exit(ptr) msvcp140._Cnd_unregister_at_thread_exit
@ cdecl _Cnd_wait(ptr ptr) msvcp140._Cnd_wait
@ stub _Copy_file
@ cdecl _Copy_file(wstr wstr) msvcp140._Copy_file
@ stub _Cosh
@ cdecl _Current_get(ptr) msvcp140._Current_get
@ cdecl _Current_set(wstr) msvcp140._Current_set
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment