Signed-off-by: Sven Baars sven.wine@gmail.com --- dlls/msvcp120/tests/msvcp120.c | 3 +++ dlls/msvcp90/ios.c | 47 ++++++++++++---------------------- 2 files changed, 19 insertions(+), 31 deletions(-)
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index 8f7b75aab4..d484cdd7ed 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -1230,6 +1230,7 @@ static void test_tr2_sys__Equivalent(void) char temp_path[MAX_PATH], current_path[MAX_PATH]; WCHAR testW[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','1',0}; WCHAR testW2[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','2',0}; + WCHAR test_dirW[] = {'t','r','2','_','t','e','s','t','_','d','i','r',0}; struct { char const *path1; char const *path2; @@ -1273,6 +1274,8 @@ static void test_tr2_sys__Equivalent(void) ok(val == 1, "tr2_sys__Equivalent(): expect: 1, got %d\n", val); val = p_tr2_sys__Equivalent_wchar(testW, testW2); ok(val == 0, "tr2_sys__Equivalent(): expect: 0, got %d\n", val); + val = p_tr2_sys__Equivalent_wchar(test_dirW, test_dirW); + ok(val == -1, "tr2_sys__Equivalent(): expect: -1, got %d\n", val);
ok(DeleteFileA("tr2_test_dir/f1"), "expect tr2_test_dir/f1 to exist\n"); ok(DeleteFileA("tr2_test_dir/f2"), "expect tr2_test_dir/f2 to exist\n"); diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index 84174e4f95..ceb3716180 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -14680,19 +14680,11 @@ ULONGLONG __cdecl tr2_sys__File_size(char const* 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) +static int equivalent_handles(HANDLE h1, HANDLE h2) { - HANDLE h1, h2; int ret; BY_HANDLE_FILE_INFORMATION info1, info2; - TRACE("(%s %s)\n", debugstr_a(path1), debugstr_a(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; @@ -14716,6 +14708,20 @@ int __cdecl tr2_sys__Equivalent(char const* path1, char const* path2) ); }
+/* ?_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; + TRACE("(%s %s)\n", debugstr_a(path1), debugstr_a(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); + return equivalent_handles(h1, h2); +} + /* ?_Current_get@sys@tr2@std@@YAPADAAY0BAE@D@Z */ /* ?_Current_get@sys@tr2@std@@YAPEADAEAY0BAE@D@Z */ char* __cdecl tr2_sys__Current_get(char *current_path) @@ -15616,35 +15622,14 @@ int __cdecl _Resize(const WCHAR *path, UINT64 size) int __cdecl tr2_sys__Equivalent_wchar(WCHAR const* path1, WCHAR const* path2) { HANDLE h1, h2; - int ret; - BY_HANDLE_FILE_INFORMATION info1, info2; TRACE("(%s %s)\n", debugstr_w(path1), debugstr_w(path2));
h1 = CreateFileW(path1, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); h2 = CreateFileW(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; - } + return equivalent_handles(h1, h2);
- 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 - ); }
/* ?_Current_get@sys@tr2@std@@YAPA_WAAY0BAE@_W@Z */