aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-05-26 17:34:48 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-05-31 13:20:44 -0500
commit90982fbf1c887a3ed3454f9ab3ab8dfbd57a1383 (patch)
tree7d87b21f0879de446f5db7053d349f32b4882cbe /src/libs/dutil/WixToolset.DUtil
parenta070d8c7b57d6c9a54106abeb359a6c868b6d7ae (diff)
downloadwix-90982fbf1c887a3ed3454f9ab3ab8dfbd57a1383.tar.gz
wix-90982fbf1c887a3ed3454f9ab3ab8dfbd57a1383.tar.bz2
wix-90982fbf1c887a3ed3454f9ab3ab8dfbd57a1383.zip
Add PathConcatRelativeToBase and use it in Burn.
Fixes 6707
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/pathutil.h11
-rw-r--r--src/libs/dutil/WixToolset.DUtil/path2utl.cpp40
2 files changed, 51 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h b/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h
index fc6bb3bb..941793f8 100644
--- a/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h
+++ b/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h
@@ -237,6 +237,17 @@ DAPI_(HRESULT) PathConcatCch(
237 ); 237 );
238 238
239/******************************************************************* 239/*******************************************************************
240 PathConcatRelativeToBase - canonicalizes a relative path before
241 concatenating it to the base path to ensure the resulting path
242 is inside the base path.
243*******************************************************************/
244DAPI_(HRESULT) PathConcatRelativeToBase(
245 __in LPCWSTR wzBase,
246 __in_opt LPCWSTR wzRelative,
247 __deref_out_z LPWSTR* psczCombined
248 );
249
250/*******************************************************************
240 PathCompare - compares the fully expanded path of the two paths using 251 PathCompare - compares the fully expanded path of the two paths using
241 ::CompareStringW(). 252 ::CompareStringW().
242*******************************************************************/ 253*******************************************************************/
diff --git a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
index 45157d0b..61c1803a 100644
--- a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
@@ -131,6 +131,46 @@ LExit:
131 return hr; 131 return hr;
132} 132}
133 133
134DAPI_(HRESULT) PathConcatRelativeToBase(
135 __in LPCWSTR wzBase,
136 __in_opt LPCWSTR wzRelative,
137 __deref_out_z LPWSTR* psczCombined
138 )
139{
140 HRESULT hr = S_OK;
141 LPWSTR sczCanonicalizedRelative = NULL;
142
143 if (!wzBase || !*wzBase)
144 {
145 PathExitWithRootFailure(hr, E_INVALIDARG, "wzBase is required.");
146 }
147
148 if (PathIsRooted(wzRelative))
149 {
150 PathExitWithRootFailure(hr, E_INVALIDARG, "wzRelative cannot be rooted.");
151 }
152
153 hr = StrAllocString(psczCombined, wzBase, 0);
154 PathExitOnFailure(hr, "Failed to copy base to output.");
155
156 if (wzRelative && *wzRelative)
157 {
158 hr = PathBackslashTerminate(psczCombined);
159 PathExitOnFailure(hr, "Failed to backslashify.");
160
161 hr = PathCanonicalizeForComparison(wzRelative, 0, &sczCanonicalizedRelative);
162 PathExitOnFailure(hr, "Failed to canonicalize wzRelative.");
163
164 hr = StrAllocConcat(psczCombined, sczCanonicalizedRelative, 0);
165 PathExitOnFailure(hr, "Failed to append relative to output.");
166 }
167
168LExit:
169 ReleaseStr(sczCanonicalizedRelative);
170
171 return hr;
172}
173
134DAPI_(HRESULT) PathDirectoryContainsPath( 174DAPI_(HRESULT) PathDirectoryContainsPath(
135 __in_z LPCWSTR wzDirectory, 175 __in_z LPCWSTR wzDirectory,
136 __in_z LPCWSTR wzPath 176 __in_z LPCWSTR wzPath