From: YongHaoHu Subject: [PATCH 1/6] msvcp110: Add tr2_sys__Copy_file implementation and test.(resend try2) Message-Id: <5596622B.7010007@gmail.com> Date: Fri, 3 Jul 2015 18:21:31 +0800 resend: Fix a mistake in the implementation. (thanks QianHong) try2 : Add is_todo in test. Delete useless SetLastError. --- dlls/msvcp110/msvcp110.spec | 4 +-- dlls/msvcp120/msvcp120.spec | 4 +-- dlls/msvcp120/tests/msvcp120.c | 59 +++++++++++++++++++++++++++++++++++++ dlls/msvcp120_app/msvcp120_app.spec | 4 +-- dlls/msvcp90/ios.c | 11 +++++++ 5 files changed, 76 insertions(+), 6 deletions(-) diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index 9ba3224..79bfc47 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -1163,8 +1163,8 @@ @ extern -arch=win64 ?_Clocptr@_Locimp@locale@std@@0PEAV123@EA locale__Locimp__Clocptr @ stub -arch=win32 ?_Close_dir@sys@tr2@std@@YAXPAX@Z @ stub -arch=win64 ?_Close_dir@sys@tr2@std@@YAXPEAX@Z -@ stub -arch=win32 ?_Copy_file@sys@tr2@std@@YAHPBD0_N@Z -@ stub -arch=win64 ?_Copy_file@sys@tr2@std@@YAHPEBD0_N@Z +@ cdecl -arch=win32 ?_Copy_file@sys@tr2@std@@YAHPBD0_N@Z(str str long) tr2_sys__Copy_file +@ cdecl -arch=win64 ?_Copy_file@sys@tr2@std@@YAHPEBD0_N@Z(str str long) tr2_sys__Copy_file @ stub -arch=win32 ?_Copy_file@sys@tr2@std@@YAHPB_W0_N@Z @ stub -arch=win64 ?_Copy_file@sys@tr2@std@@YAHPEB_W0_N@Z @ cdecl -arch=win32 ?_Current_get@sys@tr2@std@@YAPADPAD@Z(ptr) tr2_sys__Current_get diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec index 488bb01..2305af4 100644 --- a/dlls/msvcp120/msvcp120.spec +++ b/dlls/msvcp120/msvcp120.spec @@ -1128,8 +1128,8 @@ @ extern -arch=win64 ?_Clocptr@_Locimp@locale@std@@0PEAV123@EA locale__Locimp__Clocptr @ stub -arch=win32 ?_Close_dir@sys@tr2@std@@YAXPAX@Z @ stub -arch=win64 ?_Close_dir@sys@tr2@std@@YAXPEAX@Z -@ stub -arch=win32 ?_Copy_file@sys@tr2@std@@YAHPBD0_N@Z -@ stub -arch=win64 ?_Copy_file@sys@tr2@std@@YAHPEBD0_N@Z +@ cdecl -arch=win32 ?_Copy_file@sys@tr2@std@@YAHPBD0_N@Z(str str long) tr2_sys__Copy_file +@ cdecl -arch=win64 ?_Copy_file@sys@tr2@std@@YAHPEBD0_N@Z(str str long) tr2_sys__Copy_file @ stub -arch=win32 ?_Copy_file@sys@tr2@std@@YAHPB_W0_N@Z @ stub -arch=win64 ?_Copy_file@sys@tr2@std@@YAHPEB_W0_N@Z @ cdecl -arch=win32 ?_Current_get@sys@tr2@std@@YAPADAAY0BAE@D@Z(ptr) tr2_sys__Current_get diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index e97aa55..2a258a4 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -66,6 +66,7 @@ static char* (__cdecl *p_tr2_sys__Current_get)(char *); static MSVCP_bool (__cdecl *p_tr2_sys__Current_set)(char const*); static int (__cdecl *p_tr2_sys__Make_dir)(char const*); static MSVCP_bool (__cdecl *p_tr2_sys__Remove_dir)(char const*); +static int (__cdecl *p_tr2_sys__Copy_file)(char const*, char const*, MSVCP_bool); static HMODULE msvcp; #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y) @@ -106,6 +107,8 @@ static BOOL init(void) "?_Make_dir@sys@tr2@std@@YAHPEBD@Z"); SET(p_tr2_sys__Remove_dir, "?_Remove_dir@sys@tr2@std@@YA_NPEBD@Z"); + SET(p_tr2_sys__Copy_file, + "?_Copy_file@sys@tr2@std@@YAHPEBD0_N@Z"); } else { SET(p_tr2_sys__File_size, "?_File_size@sys@tr2@std@@YA_KPBD@Z"); @@ -119,6 +122,8 @@ static BOOL init(void) "?_Make_dir@sys@tr2@std@@YAHPBD@Z"); SET(p_tr2_sys__Remove_dir, "?_Remove_dir@sys@tr2@std@@YA_NPBD@Z"); + SET(p_tr2_sys__Copy_file, + "?_Copy_file@sys@tr2@std@@YAHPBD0_N@Z"); } msvcr = GetModuleHandleA("msvcr120.dll"); @@ -526,6 +531,59 @@ static void test_tr2_sys__Remove_dir(void) } } +static void test_tr2_sys__Copy_file(void) +{ + HANDLE file; + int ret, i; + LARGE_INTEGER file_size = {{7, 0}}; + struct { + char const *source; + char const *dest; + MSVCP_bool fail_if_exists; + int last_error; + MSVCP_bool is_todo; + } tests[] = { + { "f1", "f1_copy", TRUE, ERROR_SUCCESS, FALSE }, + { "f1", "tr2_test_dir\\f1_copy", TRUE, ERROR_SUCCESS, FALSE }, + { "f1", "tr2_test_dir\\f1_copy", TRUE, ERROR_FILE_EXISTS, FALSE }, + { "f1", "tr2_test_dir\\f1_copy", FALSE, ERROR_SUCCESS, FALSE }, + { "f1", "tr2_test_dir", TRUE, ERROR_ACCESS_DENIED, TRUE }, + { "tr2_test_dir", "f1", TRUE, ERROR_ACCESS_DENIED, FALSE }, + { "tr2_test_dir", "tr2_test_dir_copy", TRUE, ERROR_ACCESS_DENIED, FALSE }, + { NULL, "f1", TRUE, ERROR_INVALID_PARAMETER, TRUE }, + { "f1", NULL, TRUE, ERROR_INVALID_PARAMETER, TRUE }, + { "not_exist", "tr2_test_dir", TRUE, ERROR_FILE_NOT_FOUND, FALSE }, + { "f1", "not_exist_dir\\f1_copy", TRUE, ERROR_PATH_NOT_FOUND, FALSE } + }; + + ret = p_tr2_sys__Make_dir("tr2_test_dir"); + ok(ret == 1, "test_tr2_sys__Make_dir(): expect 1 got %d\n", ret); + file = CreateFileA("f1", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n"); + ok(SetFilePointerEx(file, file_size, NULL, FILE_BEGIN), "SetFilePointerEx failed\n"); + ok(SetEndOfFile(file), "SetEndOfFile failed\n"); + CloseHandle(file); + + for(i=0; i