From 7aeb1d3360eab3b957d2d2ea1df276a0843d8b2a Mon Sep 17 00:00:00 2001 From: YongHao Hu Date: Mon, 11 Jan 2016 21:56:02 +0800 Subject: [PATCH] msvcp110: Add tr2_sys__Link implementation and test. Signed-off-by: YongHao Hu Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcp110/msvcp110.spec | 4 +- dlls/msvcp120/msvcp120.spec | 4 +- dlls/msvcp120/tests/msvcp120.c | 90 +++++++++++++++++++++++++++++ dlls/msvcp120_app/msvcp120_app.spec | 4 +- dlls/msvcp90/ios.c | 13 +++++ 5 files changed, 109 insertions(+), 6 deletions(-) diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index 6c8aee4c17f..1df4c55177c 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -1570,8 +1570,8 @@ @ stub -arch=arm ?_Launch@_Pad@std@@QAAXPAU_Thrd_imp_t@@@Z @ stub -arch=i386 ?_Launch@_Pad@std@@QAEXPAU_Thrd_imp_t@@@Z @ stub -arch=win64 ?_Launch@_Pad@std@@QEAAXPEAU_Thrd_imp_t@@@Z -@ stub -arch=win32 ?_Link@sys@tr2@std@@YAHPBD0@Z -@ stub -arch=win64 ?_Link@sys@tr2@std@@YAHPEBD0@Z +@ cdecl -arch=win32 ?_Link@sys@tr2@std@@YAHPBD0@Z(str str) tr2_sys__Link +@ cdecl -arch=win64 ?_Link@sys@tr2@std@@YAHPEBD0@Z(str str) tr2_sys__Link @ stub -arch=win32 ?_Link@sys@tr2@std@@YAHPB_W0@Z @ stub -arch=win64 ?_Link@sys@tr2@std@@YAHPEB_W0@Z @ cdecl -arch=win32 ?_Locimp_Addfac@_Locimp@locale@std@@CAXPAV123@PAVfacet@23@I@Z(ptr ptr long) locale__Locimp__Locimp_Addfac diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec index e3200a2f9d4..626ead806b0 100644 --- a/dlls/msvcp120/msvcp120.spec +++ b/dlls/msvcp120/msvcp120.spec @@ -1531,8 +1531,8 @@ @ stub -arch=arm ?_Launch@_Pad@std@@QAAXPAU_Thrd_imp_t@@@Z @ stub -arch=i386 ?_Launch@_Pad@std@@QAEXPAU_Thrd_imp_t@@@Z @ stub -arch=win64 ?_Launch@_Pad@std@@QEAAXPEAU_Thrd_imp_t@@@Z -@ stub -arch=win32 ?_Link@sys@tr2@std@@YAHPBD0@Z -@ stub -arch=win64 ?_Link@sys@tr2@std@@YAHPEBD0@Z +@ cdecl -arch=win32 ?_Link@sys@tr2@std@@YAHPBD0@Z(str str) tr2_sys__Link +@ cdecl -arch=win64 ?_Link@sys@tr2@std@@YAHPEBD0@Z(str str) tr2_sys__Link @ stub -arch=win32 ?_Link@sys@tr2@std@@YAHPB_W0@Z @ stub -arch=win64 ?_Link@sys@tr2@std@@YAHPEB_W0@Z @ cdecl -arch=win32 ?_Locimp_Addfac@_Locimp@locale@std@@CAXPAV123@PAVfacet@23@I@Z(ptr ptr long) locale__Locimp__Locimp_Addfac diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index 27244703b9b..77a6050e4b3 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -132,6 +132,7 @@ static void (__cdecl *p_tr2_sys__Last_write_time_set)(char const*, __int64); static void* (__cdecl *p_tr2_sys__Open_dir)(char*, char const*, int *, enum file_type*); static char* (__cdecl *p_tr2_sys__Read_dir)(char*, void*, enum file_type*); static void (__cdecl *p_tr2_sys__Close_dir)(void*); +static int (__cdecl *p_tr2_sys__Link)(char const*, char const*); /* thrd */ typedef struct @@ -265,6 +266,8 @@ static BOOL init(void) "?_Read_dir@sys@tr2@std@@YAPEADAEAY0BAE@DPEAXAEAW4file_type@123@@Z"); SET(p_tr2_sys__Close_dir, "?_Close_dir@sys@tr2@std@@YAXPEAX@Z"); + SET(p_tr2_sys__Link, + "?_Link@sys@tr2@std@@YAHPEBD0@Z"); SET(p__Thrd_current, "_Thrd_current"); } else { @@ -318,6 +321,8 @@ static BOOL init(void) "?_Read_dir@sys@tr2@std@@YAPADAAY0BAE@DPAXAAW4file_type@123@@Z"); SET(p_tr2_sys__Close_dir, "?_Close_dir@sys@tr2@std@@YAXPAX@Z"); + SET(p_tr2_sys__Link, + "?_Link@sys@tr2@std@@YAHPBD0@Z"); #ifdef __i386__ SET(p_i386_Thrd_current, "_Thrd_current"); @@ -1319,6 +1324,90 @@ static void test_tr2_sys__dir_operation(void) ok(RemoveDirectoryA("tr2_test_dir"), "expect tr2_test_dir to exist\n"); } +static void test_tr2_sys__Link(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 *existing_path; + char const *new_path; + MSVCP_bool fail_if_exists; + int last_error; + } tests[] = { + { "f1", "f1_link", TRUE, ERROR_SUCCESS }, + { "f1", "tr2_test_dir\\f1_link", TRUE, ERROR_SUCCESS }, + { "tr2_test_dir\\f1_link", "tr2_test_dir\\f1_link_link", TRUE, ERROR_SUCCESS }, + { "tr2_test_dir", "dir_link", TRUE, ERROR_ACCESS_DENIED }, + { NULL, "NULL_link", TRUE, ERROR_INVALID_PARAMETER }, + { "f1", NULL, TRUE, ERROR_INVALID_PARAMETER }, + { "not_exist", "not_exist_link", TRUE, ERROR_FILE_NOT_FOUND }, + { "f1", "not_exist_dir\\f1_link", TRUE, ERROR_PATH_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("f1", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n"); + file_size.QuadPart = 7; + ok(SetFilePointerEx(file, file_size, NULL, FILE_BEGIN), "SetFilePointerEx failed\n"); + ok(SetEndOfFile(file), "SetEndOfFile failed\n"); + CloseHandle(file); + + for(i=0; i