summaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/path2utl.cpp')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/path2utl.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
index 61c1803a..1957a8c5 100644
--- a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
@@ -118,11 +118,19 @@ DAPI_(HRESULT) PathCanonicalizeForComparison(
118 PathExitOnFailure(hr, "Failed to backslash terminate the canonicalized path"); 118 PathExitOnFailure(hr, "Failed to backslash terminate the canonicalized path");
119 } 119 }
120 120
121 if ((PATH_CANONICALIZE_APPEND_LONG_PATH_PREFIX & dwCanonicalizeFlags) && 121 if (PathIsFullyQualified(*psczCanonicalized, &fHasPrefix) && !fHasPrefix &&
122 PathIsFullyQualified(*psczCanonicalized, &fHasPrefix) && !fHasPrefix) 122 (PATH_CANONICALIZE_APPEND_LONG_PATH_PREFIX & dwCanonicalizeFlags))
123 { 123 {
124 hr = PathPrefix(psczCanonicalized); 124 hr = PathPrefix(psczCanonicalized);
125 PathExitOnFailure(hr, "Failed to ensure the long path prefix on the canonicalized path"); 125 PathExitOnFailure(hr, "Failed to ensure the long path prefix on the canonicalized path");
126
127 fHasPrefix = TRUE;
128 }
129
130 if (fHasPrefix)
131 {
132 // Canonicalize \??\ into \\?\.
133 (*psczCanonicalized)[1] = L'\\';
126 } 134 }
127 135
128LExit: 136LExit:
@@ -171,6 +179,40 @@ LExit:
171 return hr; 179 return hr;
172} 180}
173 181
182DAPI_(HRESULT) PathCompareCanonicalized(
183 __in_z LPCWSTR wzPath1,
184 __in_z LPCWSTR wzPath2,
185 __out BOOL* pfEqual
186 )
187{
188 HRESULT hr = S_OK;
189 LPWSTR sczCanonicalized1 = NULL;
190 LPWSTR sczCanonicalized2 = NULL;
191 DWORD dwDefaultFlags = PATH_CANONICALIZE_APPEND_LONG_PATH_PREFIX | PATH_CANONICALIZE_KEEP_UNC_ROOT;
192 int nResult = 0;
193
194 if (!wzPath1 || !wzPath2)
195 {
196 PathExitWithRootFailure(hr, E_INVALIDARG, "Both paths are required.");
197 }
198
199 hr = PathCanonicalizeForComparison(wzPath1, dwDefaultFlags, &sczCanonicalized1);
200 PathExitOnFailure(hr, "Failed to canonicalize wzPath1.");
201
202 hr = PathCanonicalizeForComparison(wzPath2, dwDefaultFlags, &sczCanonicalized2);
203 PathExitOnFailure(hr, "Failed to canonicalize wzPath2.");
204
205 nResult = ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, sczCanonicalized1, -1, sczCanonicalized2, -1);
206 PathExitOnNullWithLastError(nResult, hr, "Failed to compare canonicalized paths.");
207
208 *pfEqual = CSTR_EQUAL == nResult;
209
210LExit:
211 ReleaseStr(sczCanonicalized1);
212 ReleaseStr(sczCanonicalized2);
213 return hr;
214}
215
174DAPI_(HRESULT) PathDirectoryContainsPath( 216DAPI_(HRESULT) PathDirectoryContainsPath(
175 __in_z LPCWSTR wzDirectory, 217 __in_z LPCWSTR wzDirectory,
176 __in_z LPCWSTR wzPath 218 __in_z LPCWSTR wzPath