From de571b8a74ac5ab9358a7e51d77dc882af524a91 Mon Sep 17 00:00:00 2001 From: YongHao Hu Date: Tue, 7 Jul 2015 15:09:39 +0800 Subject: [PATCH] msvcp110: Add tr2_sys__Rename implementation and test. --- dlls/msvcp110/msvcp110.spec | 4 +- dlls/msvcp120/msvcp120.spec | 4 +- dlls/msvcp120/tests/msvcp120.c | 83 +++++++++++++++++++++++++++++ dlls/msvcp120_app/msvcp120_app.spec | 4 +- dlls/msvcp90/ios.c | 14 +++++ 5 files changed, 103 insertions(+), 6 deletions(-) diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index 5054016507e..edc43a88f50 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 2305af4d4c3..4993e01c481 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 40c01179f0d..3b43c13d5e4 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"); @@ -586,6 +591,83 @@ 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; + char temp_path[MAX_PATH], current_path[MAX_PATH]; + LARGE_INTEGER file_size; + struct { + char const *old_path; + char const *new_path; + int val; + } tests[] = { + { "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 } + }; + + memset(current_path, 0, MAX_PATH); + GetCurrentDirectoryA(MAX_PATH, current_path); + memset(temp_path, 0, MAX_PATH); + GetTempPathA(MAX_PATH, temp_path); + ok(SetCurrentDirectoryA(temp_path), "SetCurrentDirectoryA to temp_path failed\n"); + 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); + + 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); + for(i=0; i