Zhiyi Zhang : kernelbase: Implement PathCchCombine.
Alexandre Julliard
julliard at winehq.org
Mon Nov 26 16:20:11 CST 2018
Module: wine
Branch: master
Commit: 6043898ccdf67a9173de341533e95a796db16e71
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6043898ccdf67a9173de341533e95a796db16e71
Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date: Mon Nov 26 10:31:22 2018 +0800
kernelbase: Implement PathCchCombine.
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
.../api-ms-win-core-path-l1-1-0.spec | 2 +-
dlls/kernelbase/kernelbase.spec | 2 +-
dlls/kernelbase/path.c | 7 +++
dlls/kernelbase/tests/path.c | 64 ++++++++++++++++++++++
include/pathcch.h | 1 +
5 files changed, 74 insertions(+), 2 deletions(-)
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 dfa7b81..a722f24 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
@@ -7,7 +7,7 @@
@ stub PathCchAppendEx
@ stdcall PathCchCanonicalize(ptr long wstr) kernelbase.PathCchCanonicalize
@ stdcall PathCchCanonicalizeEx(ptr long wstr long) kernelbase.PathCchCanonicalizeEx
-@ stub PathCchCombine
+@ stdcall PathCchCombine(ptr long wstr wstr) kernelbase.PathCchCombine
@ stdcall PathCchCombineEx(ptr long wstr wstr long) kernelbase.PathCchCombineEx
@ stdcall PathCchFindExtension(wstr long ptr) kernelbase.PathCchFindExtension
@ stdcall PathCchIsRoot(wstr) kernelbase.PathCchIsRoot
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index 9040633..bad32e8 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -1036,7 +1036,7 @@
# @ stub PathCchAppendEx
@ stdcall PathCchCanonicalize(ptr long wstr)
@ stdcall PathCchCanonicalizeEx(ptr long wstr long)
-# @ stub PathCchCombine
+@ stdcall PathCchCombine(ptr long wstr wstr)
@ stdcall PathCchCombineEx(ptr long wstr wstr long)
@ stdcall PathCchFindExtension(wstr long ptr)
@ stdcall PathCchIsRoot(wstr)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c
index 92a747b..a9186a1 100644
--- a/dlls/kernelbase/path.c
+++ b/dlls/kernelbase/path.c
@@ -496,6 +496,13 @@ HRESULT WINAPI PathCchCanonicalizeEx(WCHAR *out, SIZE_T size, const WCHAR *in, D
return hr;
}
+HRESULT WINAPI PathCchCombine(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2)
+{
+ TRACE("%p %s %s\n", out, wine_dbgstr_w(path1), wine_dbgstr_w(path2));
+
+ return PathCchCombineEx(out, size, path1, path2, PATHCCH_NONE);
+}
+
HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags)
{
HRESULT hr;
diff --git a/dlls/kernelbase/tests/path.c b/dlls/kernelbase/tests/path.c
index 4061988..30528b7 100644
--- a/dlls/kernelbase/tests/path.c
+++ b/dlls/kernelbase/tests/path.c
@@ -37,6 +37,7 @@ HRESULT (WINAPI *pPathCchAddBackslashEx)(WCHAR *out, SIZE_T size, WCHAR **endptr
HRESULT (WINAPI *pPathCchAddExtension)(WCHAR *path, SIZE_T size, const WCHAR *extension);
HRESULT (WINAPI *pPathCchCanonicalize)(WCHAR *out, SIZE_T size, const WCHAR *in);
HRESULT (WINAPI *pPathCchCanonicalizeEx)(WCHAR *out, SIZE_T size, const WCHAR *in, DWORD flags);
+HRESULT (WINAPI *pPathCchCombine)(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2);
HRESULT (WINAPI *pPathCchCombineEx)(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags);
HRESULT (WINAPI *pPathCchFindExtension)(const WCHAR *path, SIZE_T size, const WCHAR **extension);
BOOL (WINAPI *pPathCchIsRoot)(const WCHAR *path);
@@ -474,6 +475,67 @@ static void test_PathAllocCombine(void)
}
}
+static void test_PathCchCombine(void)
+{
+ WCHAR expected[PATHCCH_MAX_CCH] = {'C', ':', '\\', 'a', 0};
+ WCHAR p1[PATHCCH_MAX_CCH] = {'C', ':', '\\', 0};
+ WCHAR p2[PATHCCH_MAX_CCH] = {'a', 0};
+ WCHAR output[PATHCCH_MAX_CCH];
+ HRESULT hr;
+ INT i;
+
+ if (!pPathCchCombine)
+ {
+ win_skip("PathCchCombine() is not available.\n");
+ return;
+ }
+
+ hr = pPathCchCombine(output, 5, NULL, NULL);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+
+ hr = pPathCchCombine(NULL, 2, p1, p2);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+
+ memset(output, 0xff, sizeof(output));
+ hr = pPathCchCombine(output, 0, p1, p2);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+ ok(output[0] == 0xffff, "Expected output buffer to be unchanged\n");
+
+ memset(output, 0xff, sizeof(output));
+ hr = pPathCchCombine(output, 1, p1, p2);
+ ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "Expected STRSAFE_E_INSUFFICIENT_BUFFER, got %08x\n", hr);
+ ok(output[0] == 0, "Expected output buffer to contain NULL string\n");
+
+ memset(output, 0xff, sizeof(output));
+ hr = pPathCchCombine(output, 4, p1, p2);
+ ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "Expected STRSAFE_E_INSUFFICIENT_BUFFER, got %08x\n", hr);
+ ok(output[0] == 0x0, "Expected output buffer to contain NULL string\n");
+
+ memset(output, 0xff, sizeof(output));
+ hr = pPathCchCombine(output, 5, p1, p2);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(!lstrcmpW(output, expected), "Combination of %s + %s returned %s, expected %s\n", wine_dbgstr_w(p1),
+ wine_dbgstr_w(p2), wine_dbgstr_w(output), wine_dbgstr_w(expected));
+
+ hr = pPathCchCombine(output, PATHCCH_MAX_CCH + 1, p1, p2);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+
+ hr = pPathCchCombine(output, PATHCCH_MAX_CCH, p1, p2);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ for (i = 0; i < ARRAY_SIZE(combine_tests); i++)
+ {
+ MultiByteToWideChar(CP_ACP, 0, combine_tests[i].path1, -1, p1, ARRAY_SIZE(p1));
+ MultiByteToWideChar(CP_ACP, 0, combine_tests[i].path2, -1, p2, ARRAY_SIZE(p2));
+ MultiByteToWideChar(CP_ACP, 0, combine_tests[i].result, -1, expected, ARRAY_SIZE(expected));
+
+ hr = pPathCchCombine(output, ARRAY_SIZE(output), p1, p2);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(!lstrcmpW(output, expected), "Combining %s with %s returned %s, expected %s\n", wine_dbgstr_w(p1),
+ wine_dbgstr_w(p2), wine_dbgstr_w(output), wine_dbgstr_w(expected));
+ }
+}
+
static void test_PathCchCombineEx(void)
{
WCHAR expected[MAX_PATH] = {'C',':','\\','a',0};
@@ -2049,6 +2111,7 @@ START_TEST(path)
pPathCchAddExtension = (void *)GetProcAddress(hmod, "PathCchAddExtension");
pPathCchCanonicalize = (void *)GetProcAddress(hmod, "PathCchCanonicalize");
pPathCchCanonicalizeEx = (void *)GetProcAddress(hmod, "PathCchCanonicalizeEx");
+ pPathCchCombine = (void *)GetProcAddress(hmod, "PathCchCombine");
pPathCchCombineEx = (void *)GetProcAddress(hmod, "PathCchCombineEx");
pPathCchFindExtension = (void *)GetProcAddress(hmod, "PathCchFindExtension");
pPathCchIsRoot = (void *)GetProcAddress(hmod, "PathCchIsRoot");
@@ -2069,6 +2132,7 @@ START_TEST(path)
test_PathCchAddExtension();
test_PathCchCanonicalize();
test_PathCchCanonicalizeEx();
+ test_PathCchCombine();
test_PathCchCombineEx();
test_PathCchFindExtension();
test_PathCchIsRoot();
diff --git a/include/pathcch.h b/include/pathcch.h
index 3cec09c..205d4a2 100644
--- a/include/pathcch.h
+++ b/include/pathcch.h
@@ -33,6 +33,7 @@ HRESULT WINAPI PathCchAddBackslashEx(WCHAR *path, SIZE_T size, WCHAR **end, SIZE
HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extension);
HRESULT WINAPI PathCchCanonicalize(WCHAR *out, SIZE_T size, const WCHAR *in);
HRESULT WINAPI PathCchCanonicalizeEx(WCHAR *out, SIZE_T size, const WCHAR *in, DWORD flags);
+HRESULT WINAPI PathCchCombine(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2);
HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags);
HRESULT WINAPI PathCchFindExtension(const WCHAR *path, SIZE_T size, const WCHAR **extension);
BOOL WINAPI PathCchIsRoot(const WCHAR *path);
More information about the wine-cvs
mailing list