diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-05-26 17:34:48 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-05-31 13:20:44 -0500 |
commit | 90982fbf1c887a3ed3454f9ab3ab8dfbd57a1383 (patch) | |
tree | 7d87b21f0879de446f5db7053d349f32b4882cbe /src/libs/dutil/WixToolset.DUtil | |
parent | a070d8c7b57d6c9a54106abeb359a6c868b6d7ae (diff) | |
download | wix-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.h | 11 | ||||
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/path2utl.cpp | 40 |
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 | *******************************************************************/ | ||
244 | DAPI_(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 | ||
134 | DAPI_(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 | |||
168 | LExit: | ||
169 | ReleaseStr(sczCanonicalizedRelative); | ||
170 | |||
171 | return hr; | ||
172 | } | ||
173 | |||
134 | DAPI_(HRESULT) PathDirectoryContainsPath( | 174 | DAPI_(HRESULT) PathDirectoryContainsPath( |
135 | __in_z LPCWSTR wzDirectory, | 175 | __in_z LPCWSTR wzDirectory, |
136 | __in_z LPCWSTR wzPath | 176 | __in_z LPCWSTR wzPath |