msvcp140: Add an _Equivalent implementation that allows for directories.

Signed-off-by: Sven Baars <sven.wine@gmail.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Sven Baars 2019-10-21 20:01:54 +02:00 committed by Alexandre Julliard
parent fb1fa3a404
commit aeeb299f98
3 changed files with 24 additions and 2 deletions

View File

@ -3638,7 +3638,7 @@
@ cdecl _Current_set(wstr) tr2_sys__Current_set_wchar
@ extern _Denorm _Denorm
@ cdecl _Dtest(ptr) _Dtest
@ cdecl _Equivalent(wstr wstr) tr2_sys__Equivalent_wchar
@ cdecl _Equivalent(wstr wstr) _Equivalent
@ cdecl _Exp(ptr double long) _Exp
@ stub _FCosh
@ extern _FDenorm _FDenorm

View File

@ -1400,7 +1400,6 @@ static void test_Equivalent(void)
{ f1W, NULL, 0 },
{ f1W, wine_test_dirW, 0 },
{ wine_test_dirW, f1W, 0 },
{ wine_test_dirW, wine_test_dirW, -1 },
{ f1W_subdir, f2W, 0 },
{ f1W, f1W, 1 },
{ not_existW, f1W, 0 },
@ -1429,6 +1428,11 @@ static void test_Equivalent(void)
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
}
errno = 0xdeadbeef;
val = p_Equivalent(wine_test_dirW, wine_test_dirW);
ok(val == 1 || broken(val == -1), "_Equivalent() returned %d, expected %d\n", val, 1);
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
ok(DeleteFileW(f1W), "expect wine_test_dir/f1 to exist\n");
ok(DeleteFileW(f2W), "expect wine_test_dir/f2 to exist\n");
ok(p_Remove_dir(wine_test_dirW), "expect wine_test_dir to exist\n");

View File

@ -15632,6 +15632,24 @@ int __cdecl tr2_sys__Equivalent_wchar(WCHAR const* path1, WCHAR const* path2)
return ret;
}
/* _Equivalent, msvcp140 version */
int __cdecl _Equivalent(WCHAR const* path1, WCHAR const* path2)
{
HANDLE h1, h2;
int ret;
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, FILE_FLAG_BACKUP_SEMANTICS, 0);
h2 = CreateFileW(path2, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
ret = equivalent_handles(h1, h2);
CloseHandle(h1);
CloseHandle(h2);
return ret;
}
/* ?_Current_get@sys@tr2@std@@YAPA_WAAY0BAE@_W@Z */
/* ?_Current_get@sys@tr2@std@@YAPEA_WAEAY0BAE@_W@Z */
WCHAR* __cdecl tr2_sys__Current_get_wchar(WCHAR *current_path)