diff --git a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec index 796b57f457c..4f375e0c30d 100644 --- a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec +++ b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec @@ -3,7 +3,7 @@ @ stdcall PathCchAddBackslash(wstr long) kernelbase.PathCchAddBackslash @ stdcall PathCchAddBackslashEx(wstr long ptr ptr) kernelbase.PathCchAddBackslashEx @ stdcall PathCchAddExtension(wstr long wstr) kernelbase.PathCchAddExtension -@ stub PathCchAppend +@ stdcall PathCchAppend(wstr long wstr) kernelbase.PathCchAppend @ stdcall PathCchAppendEx(wstr long wstr long) kernelbase.PathCchAppendEx @ stdcall PathCchCanonicalize(ptr long wstr) kernelbase.PathCchCanonicalize @ stdcall PathCchCanonicalizeEx(ptr long wstr long) kernelbase.PathCchCanonicalizeEx diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index 04023e31b6f..d1bff9fec5c 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -1032,7 +1032,7 @@ @ stdcall PathCchAddBackslash(wstr long) @ stdcall PathCchAddBackslashEx(wstr long ptr ptr) @ stdcall PathCchAddExtension(wstr long wstr) -# @ stub PathCchAppend +@ stdcall PathCchAppend(wstr long wstr) @ stdcall PathCchAppendEx(wstr long wstr long) @ stdcall PathCchCanonicalize(ptr long wstr) @ stdcall PathCchCanonicalizeEx(ptr long wstr long) diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index c5817e26fdd..bcd129cce93 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -446,6 +446,13 @@ HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extens return S_OK; } +HRESULT WINAPI PathCchAppend(WCHAR *path1, SIZE_T size, const WCHAR *path2) +{ + TRACE("%s %lu %s\n", wine_dbgstr_w(path1), size, wine_dbgstr_w(path2)); + + return PathCchAppendEx(path1, size, path2, PATHCCH_NONE); +} + HRESULT WINAPI PathCchAppendEx(WCHAR *path1, SIZE_T size, const WCHAR *path2, DWORD flags) { HRESULT hr; diff --git a/dlls/kernelbase/tests/path.c b/dlls/kernelbase/tests/path.c index 0b9b8683dab..7b24f00178c 100644 --- a/dlls/kernelbase/tests/path.c +++ b/dlls/kernelbase/tests/path.c @@ -35,6 +35,7 @@ HRESULT (WINAPI *pPathAllocCombine)(const WCHAR *path1, const WCHAR *path2, DWOR HRESULT (WINAPI *pPathCchAddBackslash)(WCHAR *out, SIZE_T size); HRESULT (WINAPI *pPathCchAddBackslashEx)(WCHAR *out, SIZE_T size, WCHAR **endptr, SIZE_T *remaining); HRESULT (WINAPI *pPathCchAddExtension)(WCHAR *path, SIZE_T size, const WCHAR *extension); +HRESULT (WINAPI *pPathCchAppend)(WCHAR *path1, SIZE_T size, const WCHAR *path2); HRESULT (WINAPI *pPathCchAppendEx)(WCHAR *path1, SIZE_T size, const WCHAR *path2, DWORD flags); HRESULT (WINAPI *pPathCchCanonicalize)(WCHAR *out, SIZE_T size, const WCHAR *in); HRESULT (WINAPI *pPathCchCanonicalizeEx)(WCHAR *out, SIZE_T size, const WCHAR *in, DWORD flags); @@ -855,6 +856,53 @@ static const struct append_test append_tests[] = {"a", "b", "a\\b"} }; +static void test_PathCchAppend(void) +{ + WCHAR path1W[PATHCCH_MAX_CCH]; + WCHAR path2W[PATHCCH_MAX_CCH]; + CHAR path1A[PATHCCH_MAX_CCH]; + HRESULT hr; + INT i; + + if (!pPathCchAppend) + { + win_skip("PathCchAppend() is not available.\n"); + return; + } + + MultiByteToWideChar(CP_ACP, 0, "\\a", -1, path1W, ARRAY_SIZE(path1W)); + MultiByteToWideChar(CP_ACP, 0, "\\b", -1, path2W, ARRAY_SIZE(path2W)); + hr = pPathCchAppend(NULL, PATHCCH_MAX_CCH, path2W); + ok(hr == E_INVALIDARG, "expect hr %#x, got %#x\n", E_INVALIDARG, hr); + + hr = pPathCchAppend(path1W, 0, path2W); + ok(hr == E_INVALIDARG, "expect hr %#x, got %#x\n", E_INVALIDARG, hr); + + hr = pPathCchAppend(path1W, PATHCCH_MAX_CCH + 1, path2W); + ok(hr == E_INVALIDARG, "expect hr %#x, got %#x\n", E_INVALIDARG, hr); + + hr = pPathCchAppend(path1W, PATHCCH_MAX_CCH, NULL); + ok(hr == S_OK, "expect hr %#x, got %#x\n", S_OK, hr); + WideCharToMultiByte(CP_ACP, 0, path1W, -1, path1A, ARRAY_SIZE(path1A), NULL, NULL); + ok(!lstrcmpA(path1A, "\\a"), "expect \\a, got %s\n", path1A); + + for (i = 0; i < ARRAY_SIZE(append_tests); i++) + { + const struct append_test *t = append_tests + i; + + MultiByteToWideChar(CP_ACP, 0, t->path1, -1, path1W, ARRAY_SIZE(path1W)); + MultiByteToWideChar(CP_ACP, 0, t->path2, -1, path2W, ARRAY_SIZE(path2W)); + hr = pPathCchAppend(path1W, PATHCCH_MAX_CCH, path2W); + ok(hr == S_OK, "append \"%s\" \"%s\" expect hr %#x, got %#x\n", t->path1, t->path2, S_OK, hr); + if (SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, path1W, -1, path1A, ARRAY_SIZE(path1A), NULL, NULL); + ok(!lstrcmpA(path1A, t->result), "append \"%s\" \"%s\" expect result \"%s\", got \"%s\"\n", t->path1, + t->path2, t->result, path1A); + } + } +} + static void test_PathCchAppendEx(void) { WCHAR path1W[PATHCCH_MAX_CCH]; @@ -2230,6 +2278,7 @@ START_TEST(path) pPathCchAddBackslash = (void *)GetProcAddress(hmod, "PathCchAddBackslash"); pPathCchAddBackslashEx = (void *)GetProcAddress(hmod, "PathCchAddBackslashEx"); pPathCchAddExtension = (void *)GetProcAddress(hmod, "PathCchAddExtension"); + pPathCchAppend = (void *)GetProcAddress(hmod, "PathCchAppend"); pPathCchAppendEx = (void *)GetProcAddress(hmod, "PathCchAppendEx"); pPathCchCanonicalize = (void *)GetProcAddress(hmod, "PathCchCanonicalize"); pPathCchCanonicalizeEx = (void *)GetProcAddress(hmod, "PathCchCanonicalizeEx"); @@ -2252,6 +2301,7 @@ START_TEST(path) test_PathCchAddBackslash(); test_PathCchAddBackslashEx(); test_PathCchAddExtension(); + test_PathCchAppend(); test_PathCchAppendEx(); test_PathCchCanonicalize(); test_PathCchCanonicalizeEx(); diff --git a/include/pathcch.h b/include/pathcch.h index 18f065c4c63..0c2dc63c41b 100644 --- a/include/pathcch.h +++ b/include/pathcch.h @@ -31,6 +31,7 @@ HRESULT WINAPI PathAllocCombine(const WCHAR *path1, const WCHAR *path2, DWORD fl HRESULT WINAPI PathCchAddBackslash(WCHAR *path, SIZE_T size); HRESULT WINAPI PathCchAddBackslashEx(WCHAR *path, SIZE_T size, WCHAR **end, SIZE_T *remaining); HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extension); +HRESULT WINAPI PathCchAppend(WCHAR *path1, SIZE_T size, const WCHAR *path2); HRESULT WINAPI PathCchAppendEx(WCHAR *path1, SIZE_T size, const WCHAR *path2, DWORD flags); HRESULT WINAPI PathCchCanonicalize(WCHAR *out, SIZE_T size, const WCHAR *in); HRESULT WINAPI PathCchCanonicalizeEx(WCHAR *out, SIZE_T size, const WCHAR *in, DWORD flags);