From: YongHaoHu Subject: [PATCH 2/6]: msvcp110: Add tr2_sys__Rename implementation and test. Message-Id: <558EE249.2020307@gmail.com> Date: Sun, 28 Jun 2015 01:50:01 +0800 --- dlls/msvcp110/msvcp110.spec | 4 +-- dlls/msvcp120/msvcp120.spec | 4 +-- dlls/msvcp120/tests/msvcp120.c | 60 +++++++++++++++++++++++++++++++++++++ dlls/msvcp120_app/msvcp120_app.spec | 4 +-- dlls/msvcp90/ios.c | 14 +++++++++ 5 files changed, 80 insertions(+), 6 deletions(-) diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index 79bfc47..46f49a0 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -1722,8 +1722,8 @@ @ cdecl -arch=win64 ?_Remove_dir@sys@tr2@std@@YA_NPEBD@Z(str) tr2_sys__Remove_dir @ stub -arch=win32 ?_Remove_dir@sys@tr2@std@@YA_NPB_W@Z @ stub -arch=win64 ?_Remove_dir@sys@tr2@std@@YA_NPEB_W@Z -@ stub -arch=win32 ?_Rename@sys@tr2@std@@YAHPBD0@Z -@ stub -arch=win64 ?_Rename@sys@tr2@std@@YAHPEBD0@Z +@ cdecl -arch=win32 ?_Rename@sys@tr2@std@@YAHPBD0@Z(str str) tr2_sys__Rename +@ cdecl -arch=win64 ?_Rename@sys@tr2@std@@YAHPEBD0@Z(str str) tr2_sys__Rename @ stub -arch=win32 ?_Rename@sys@tr2@std@@YAHPB_W0@Z @ stub -arch=win64 ?_Rename@sys@tr2@std@@YAHPEB_W0@Z @ cdecl -arch=win32 ?_Rep@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABA?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@DI@Z(ptr ptr long ptr long long) num_put_char__Rep diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec index 2305af4..4993e01 100644 --- a/dlls/msvcp120/msvcp120.spec +++ b/dlls/msvcp120/msvcp120.spec @@ -1683,8 +1683,8 @@ @ cdecl -arch=win64 ?_Remove_dir@sys@tr2@std@@YA_NPEBD@Z(str) tr2_sys__Remove_dir @ stub -arch=win32 ?_Remove_dir@sys@tr2@std@@YA_NPB_W@Z @ stub -arch=win64 ?_Remove_dir@sys@tr2@std@@YA_NPEB_W@Z -@ stub -arch=win32 ?_Rename@sys@tr2@std@@YAHPBD0@Z -@ stub -arch=win64 ?_Rename@sys@tr2@std@@YAHPEBD0@Z +@ cdecl -arch=win32 ?_Rename@sys@tr2@std@@YAHPBD0@Z(str str) tr2_sys__Rename +@ cdecl -arch=win64 ?_Rename@sys@tr2@std@@YAHPEBD0@Z(str str) tr2_sys__Rename @ stub -arch=win32 ?_Rename@sys@tr2@std@@YAHPB_W0@Z @ stub -arch=win64 ?_Rename@sys@tr2@std@@YAHPEB_W0@Z @ cdecl -arch=win32 ?_Rep@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABA?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@DI@Z(ptr ptr long ptr long long) num_put_char__Rep diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index 89164ea..c262031 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -67,6 +67,7 @@ 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 int (__cdecl *p_tr2_sys__Rename)(char const*, char const*); static HMODULE msvcp; #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y) @@ -109,6 +110,8 @@ static BOOL init(void) "?_Remove_dir@sys@tr2@std@@YA_NPEBD@Z"); SET(p_tr2_sys__Copy_file, "?_Copy_file@sys@tr2@std@@YAHPEBD0_N@Z"); + SET(p_tr2_sys__Rename, + "?_Rename@sys@tr2@std@@YAHPEBD0@Z"); } else { SET(p_tr2_sys__File_size, "?_File_size@sys@tr2@std@@YA_KPBD@Z"); @@ -124,6 +127,8 @@ static BOOL init(void) "?_Remove_dir@sys@tr2@std@@YA_NPBD@Z"); SET(p_tr2_sys__Copy_file, "?_Copy_file@sys@tr2@std@@YAHPBD0_N@Z"); + SET(p_tr2_sys__Rename, + "?_Rename@sys@tr2@std@@YAHPBD0@Z"); } msvcr = GetModuleHandleA("msvcr120.dll"); @@ -580,6 +585,60 @@ static void test_tr2_sys__Copy_file(void) ok(ret == 1, "test_tr2_sys__Remove_dir(): expect 1 got %d\n", ret); } +static void test_tr2_sys__Rename(void) +{ + int ret, i; + HANDLE file, h1, h2; + BY_HANDLE_FILE_INFORMATION info1, info2; + struct { + char const *old_path; + char const *new_path; + int val; + } tests[] = { + { "tr2_test_dir\\f1", "tr2_test_dir\\f1", ERROR_SUCCESS }, + { "tr2_test_dir\\f1", "tr2_test_dir\\f1_rename", ERROR_SUCCESS }, + { "tr2_test_dir\\f1", NULL, ERROR_INVALID_PARAMETER }, + { "tr2_test_dir\\f1", "tr2_test_dir\\f1_rename", ERROR_FILE_NOT_FOUND }, + { NULL, "tr2_test_dir\\NULL_rename", ERROR_INVALID_PARAMETER }, + { "tr2_test_dir\\f1_rename", "tr2_test_dir\\??invalid_name>>", ERROR_INVALID_NAME }, + { "tr2_test_dir\\not_exist_file", "tr2_test_dir\\not_exist_rename", ERROR_FILE_NOT_FOUND } + }; + 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("tr2_test_dir\\f1", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n"); + CloseHandle(file); + + for(i=0; i