Module: wine Branch: master Commit: 94e034245defa314b995ce96f4842ea3b04a3710 URL: http://source.winehq.org/git/wine.git/?a=commit;h=94e034245defa314b995ce96f4...
Author: YongHao Hu christopherwuy@gmail.com Date: Sat Jun 13 00:29:18 2015 +0800
msvcp110: Add tr2_sys__Equivalent implementation and test.
---
dlls/msvcp110/msvcp110.spec | 4 +-- dlls/msvcp120/msvcp120.spec | 4 +-- dlls/msvcp120/tests/msvcp120.c | 58 +++++++++++++++++++++++++++++++++++++ dlls/msvcp120_app/msvcp120_app.spec | 4 +-- dlls/msvcp90/ios.c | 36 +++++++++++++++++++++++ 5 files changed, 100 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index 5c48c76..c388eaf 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -1196,8 +1196,8 @@ @ cdecl -arch=arm ?_Empty@?$_Yarn@_W@std@@QBA_NXZ(ptr) _Yarn_wchar__Empty @ thiscall -arch=i386 ?_Empty@?$_Yarn@_W@std@@QBE_NXZ(ptr) _Yarn_wchar__Empty @ cdecl -arch=win64 ?_Empty@?$_Yarn@_W@std@@QEBA_NXZ(ptr) _Yarn_wchar__Empty -@ stub -arch=win32 ?_Equivalent@sys@tr2@std@@YAHPBD0@Z -@ stub -arch=win64 ?_Equivalent@sys@tr2@std@@YAHPEBD0@Z +@ cdecl -arch=win32 ?_Equivalent@sys@tr2@std@@YAHPBD0@Z(str str) tr2_sys__Equivalent +@ cdecl -arch=win64 ?_Equivalent@sys@tr2@std@@YAHPEBD0@Z(str str) tr2_sys__Equivalent @ stub -arch=win32 ?_Equivalent@sys@tr2@std@@YAHPB_W0@Z @ stub -arch=win64 ?_Equivalent@sys@tr2@std@@YAHPEB_W0@Z @ cdecl -arch=win32 ?_Ffmt@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABAPADPADDH@Z(ptr ptr long long) num_put_char__Ffmt diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec index a6e60b1..c74e6ca 100644 --- a/dlls/msvcp120/msvcp120.spec +++ b/dlls/msvcp120/msvcp120.spec @@ -1161,8 +1161,8 @@ @ cdecl -arch=arm ?_Empty@?$_Yarn@_W@std@@QBA_NXZ(ptr) _Yarn_wchar__Empty @ thiscall -arch=i386 ?_Empty@?$_Yarn@_W@std@@QBE_NXZ(ptr) _Yarn_wchar__Empty @ cdecl -arch=win64 ?_Empty@?$_Yarn@_W@std@@QEBA_NXZ(ptr) _Yarn_wchar__Empty -@ stub -arch=win32 ?_Equivalent@sys@tr2@std@@YAHPBD0@Z -@ stub -arch=win64 ?_Equivalent@sys@tr2@std@@YAHPEBD0@Z +@ cdecl -arch=win32 ?_Equivalent@sys@tr2@std@@YAHPBD0@Z(str str) tr2_sys__Equivalent +@ cdecl -arch=win64 ?_Equivalent@sys@tr2@std@@YAHPEBD0@Z(str str) tr2_sys__Equivalent @ stub -arch=win32 ?_Equivalent@sys@tr2@std@@YAHPB_W0@Z @ stub -arch=win64 ?_Equivalent@sys@tr2@std@@YAHPEB_W0@Z @ cdecl -arch=win32 ?_Ffmt@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABAPADPADDH@Z(ptr ptr long long) num_put_char__Ffmt diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index 41e4c56..defa934 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -60,6 +60,7 @@ static void (CDECL *p__Do_call)(void *this);
/* filesystem */ static ULONGLONG(__cdecl *p_tr2_sys__File_size)(char const*); +static int (__cdecl *p_tr2_sys__Equivalent)(char const*, char const*);
static HMODULE msvcp; #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y) @@ -90,9 +91,13 @@ static BOOL init(void) if(sizeof(void*) == 8) { /* 64-bit initialization */ SET(p_tr2_sys__File_size, "?_File_size@sys@tr2@std@@YA_KPEBD@Z"); + SET(p_tr2_sys__Equivalent, + "?_Equivalent@sys@tr2@std@@YAHPEBD0@Z"); } else { SET(p_tr2_sys__File_size, "?_File_size@sys@tr2@std@@YA_KPBD@Z"); + SET(p_tr2_sys__Equivalent, + "?_Equivalent@sys@tr2@std@@YAHPBD0@Z"); }
msvcr = GetModuleHandleA("msvcr120.dll"); @@ -338,6 +343,58 @@ static void test_tr2_sys__File_size(void) ok(RemoveDirectoryA("tr2_test_dir"), "Expected tr2_test_dir to exist\n"); }
+static void test_tr2_sys__Equivalent(void) +{ + int val, i; + HANDLE file; + char temp_path[MAX_PATH], current_path[MAX_PATH]; + struct { + char const *path1; + char const *path2; + int equivalent; + } tests[] = { + { NULL, NULL, -1 }, + { NULL, "f1", -1 }, + { "f1", NULL, -1 }, + { "f1", "tr2_test_dir", -1 }, + { "tr2_test_dir", "f1", -1 }, + { "tr2_test_dir", "tr2_test_dir", -1 }, + { "tr2_test_dir/./f1", "tr2_test_dir/f2", 0 }, + { "tr2_test_dir/f1" , "tr2_test_dir/f1", 1 }, + { "not_exists_file" , "tr2_test_dir/f1", 0 }, + { "tr2_test_dir\f1" , "tr2_test_dir/./f1", 1 }, + { "not_exists_file" , "not_exists_file", -1 }, + { "tr2_test_dir/f1" , "not_exists_file", 0 }, + { "tr2_test_dir/../tr2_test_dir/f1", "tr2_test_dir/f1", 1 } + }; + + 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"); + CreateDirectoryA("tr2_test_dir", NULL); + + file = CreateFileA("tr2_test_dir/f1", 0, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n"); + CloseHandle(file); + file = CreateFileA("tr2_test_dir/f2", 0, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n"); + CloseHandle(file); + + for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) { + errno = 0xdeadbeef; + val = p_tr2_sys__Equivalent(tests[i].path1, tests[i].path2); + ok(tests[i].equivalent == val, "tr2_sys__Equivalent(): test %d expect: %d, got %d\n", i+1, tests[i].equivalent, val); + ok(errno == 0xdeadbeef, "errno = %d\n", errno); + } + + ok(DeleteFileA("tr2_test_dir/f1"), "Expected tr2_test_dir/f1 to exist\n"); + ok(DeleteFileA("tr2_test_dir/f2"), "Expected tr2_test_dir/f2 to exist\n"); + ok(RemoveDirectoryA("tr2_test_dir"), "Expected tr2_test_dir to exist\n"); + ok(SetCurrentDirectoryA(current_path), "SetCurrentDirectoryA failed\n"); +} + START_TEST(msvcp120) { if(!init()) return; @@ -348,5 +405,6 @@ START_TEST(msvcp120) test__Do_call();
test_tr2_sys__File_size(); + test_tr2_sys__Equivalent(); FreeLibrary(msvcp); } diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec index e317987..fdbda65 100644 --- a/dlls/msvcp120_app/msvcp120_app.spec +++ b/dlls/msvcp120_app/msvcp120_app.spec @@ -1161,8 +1161,8 @@ @ cdecl -arch=arm ?_Empty@?$_Yarn@_W@std@@QBA_NXZ(ptr) msvcp120.?_Empty@?$_Yarn@_W@std@@QBA_NXZ @ thiscall -arch=i386 ?_Empty@?$_Yarn@_W@std@@QBE_NXZ(ptr) msvcp120.?_Empty@?$_Yarn@_W@std@@QBE_NXZ @ cdecl -arch=win64 ?_Empty@?$_Yarn@_W@std@@QEBA_NXZ(ptr) msvcp120.?_Empty@?$_Yarn@_W@std@@QEBA_NXZ -@ stub -arch=win32 ?_Equivalent@sys@tr2@std@@YAHPBD0@Z -@ stub -arch=win64 ?_Equivalent@sys@tr2@std@@YAHPEBD0@Z +@ cdecl -arch=win32 ?_Equivalent@sys@tr2@std@@YAHPBD0@Z(str str) msvcp120.?_Equivalent@sys@tr2@std@@YAHPBD0@Z +@ cdecl -arch=win64 ?_Equivalent@sys@tr2@std@@YAHPEBD0@Z(str str) msvcp120.?_Equivalent@sys@tr2@std@@YAHPEBD0@Z @ stub -arch=win32 ?_Equivalent@sys@tr2@std@@YAHPB_W0@Z @ stub -arch=win64 ?_Equivalent@sys@tr2@std@@YAHPEB_W0@Z @ cdecl -arch=win32 ?_Ffmt@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABAPADPADDH@Z(ptr ptr long long) msvcp120.?_Ffmt@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABAPADPADDH@Z diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index 7b8e226..d68e26a 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -14205,6 +14205,42 @@ ULONGLONG __cdecl tr2_sys__File_size(const char* path) return ((ULONGLONG)(fad.nFileSizeHigh) << 32) + fad.nFileSizeLow; }
+/* ?_Equivalent@sys@tr2@std@@YAHPBD0@Z */ +/* ?_Equivalent@sys@tr2@std@@YAHPEBD0@Z */ +int __cdecl tr2_sys__Equivalent(char const* path1, char const* path2) +{ + HANDLE h1, h2; + int ret; + BY_HANDLE_FILE_INFORMATION info1, info2; + TRACE("(%p %p)\n", path1, path2); + + h1 = CreateFileA(path1, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, 0); + h2 = CreateFileA(path2, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, 0); + if(h1 == INVALID_HANDLE_VALUE) { + if(h2 == INVALID_HANDLE_VALUE) { + return -1; + }else { + CloseHandle(h2); + return 0; + } + }else if(h2 == INVALID_HANDLE_VALUE) { + CloseHandle(h1); + return 0; + } + + ret = GetFileInformationByHandle(h1, &info1) && GetFileInformationByHandle(h2, &info2); + CloseHandle(h1); + CloseHandle(h2); + if(!ret) + return -1; + return (info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber + && info1.nFileIndexHigh == info2.nFileIndexHigh + && info1.nFileIndexLow == info2.nFileIndexLow + ); +} + /* ??0strstream@std@@QAE@PADHH@Z */ /* ??0strstream@std@@QEAA@PEAD_JH@Z */ #if STREAMSIZE_BITS == 64