From 6f062d1e816ff8d3127ddcbdc7ee0335873bbab8 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 26 May 2022 17:32:22 -0500 Subject: PathGetDirectory can't be responsible for stripping quotes. --- src/libs/dutil/WixToolset.DUtil/pathutil.cpp | 6 ---- src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp | 33 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp index fa07f165..9823779b 100644 --- a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp @@ -100,12 +100,6 @@ DAPI_(HRESULT) PathGetDirectory( return S_FALSE; } - if (wzPath[0] == L'\"') - { - ++wzPath; - --cchDirectory; - } - hr = StrAllocString(psczDirectory, wzPath, cchDirectory); PathExitOnFailure(hr, "Failed to copy directory."); diff --git a/src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp b/src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp index 5a1f06fd..6a05a45c 100644 --- a/src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp +++ b/src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp @@ -11,6 +11,39 @@ namespace DutilTests public ref class PathUtil { public: + [Fact] + void PathGetDirectoryTest() + { + HRESULT hr = S_OK; + LPWSTR sczPath = NULL; + LPCWSTR rgwzPaths[18] = + { + L"C:\\a\\b", L"C:\\a\\", + L"C:\\a", L"C:\\", + L"C:\\", L"C:\\", + L"\"C:\\a\\b\\c\"", L"\"C:\\a\\b\\", + L"\"C:\\a\\b\\\"c", L"\"C:\\a\\b\\", + L"\"C:\\a\\b\"\\c", L"\"C:\\a\\b\"\\", + L"\"C:\\a\\\"b\\c", L"\"C:\\a\\\"b\\", + L"C:\\a\"\\\"b\\c", L"C:\\a\"\\\"b\\", + L"C:\\a\"\\b\\c\"", L"C:\\a\"\\b\\", + }; + + try + { + for (DWORD i = 0; i < countof(rgwzPaths); i += 2) + { + hr = PathGetDirectory(rgwzPaths[i], &sczPath); + NativeAssert::Succeeded(hr, "PathGetDirectory: {0}", rgwzPaths[i]); + NativeAssert::StringEqual(rgwzPaths[i + 1], sczPath); + } + } + finally + { + ReleaseStr(sczPath); + } + } + [Fact] void PathGetHierarchyArrayTest() { -- cgit v1.2.3-55-g6feb