diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-05-26 17:33:41 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-05-31 13:20:44 -0500 |
commit | dea25f58e6119ef1acc5c5cc2a7c98e52cdff519 (patch) | |
tree | 853368043c98c9f8617744f8d8cb01b7a629e8a9 /src/libs/dutil/WixToolset.DUtil/inc/pathutil.h | |
parent | fb4f8c7108f43d2341ba299424646c4963b21188 (diff) | |
download | wix-dea25f58e6119ef1acc5c5cc2a7c98e52cdff519.tar.gz wix-dea25f58e6119ef1acc5c5cc2a7c98e52cdff519.tar.bz2 wix-dea25f58e6119ef1acc5c5cc2a7c98e52cdff519.zip |
Add PathCanonicalizeForComparison.
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/inc/pathutil.h')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/inc/pathutil.h | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h b/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h index 602b4a80..fc6bb3bb 100644 --- a/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h +++ b/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h | |||
@@ -6,7 +6,17 @@ | |||
6 | extern "C" { | 6 | extern "C" { |
7 | #endif | 7 | #endif |
8 | 8 | ||
9 | typedef enum PATH_EXPAND | 9 | typedef enum _PATH_CANONICALIZE |
10 | { | ||
11 | // Always prefix fully qualified paths with the long path prefix (\\?\). | ||
12 | PATH_CANONICALIZE_APPEND_LONG_PATH_PREFIX = 0x0001, | ||
13 | // Always terminate the path with \. | ||
14 | PATH_CANONICALIZE_BACKSLASH_TERMINATE = 0x0002, | ||
15 | // Don't collapse . or .. in the \\server\share portion of a UNC path. | ||
16 | PATH_CANONICALIZE_KEEP_UNC_ROOT = 0x0004, | ||
17 | } PATH_CANONICALIZE; | ||
18 | |||
19 | typedef enum _PATH_EXPAND | ||
10 | { | 20 | { |
11 | PATH_EXPAND_ENVIRONMENT = 0x0001, | 21 | PATH_EXPAND_ENVIRONMENT = 0x0001, |
12 | PATH_EXPAND_FULLPATH = 0x0002, | 22 | PATH_EXPAND_FULLPATH = 0x0002, |
@@ -29,7 +39,9 @@ DAPI_(LPCWSTR) PathExtension( | |||
29 | ); | 39 | ); |
30 | 40 | ||
31 | /******************************************************************* | 41 | /******************************************************************* |
32 | PathGetDirectory - extracts the directory from a path. | 42 | PathGetDirectory - extracts the directory from a path including the directory separator. |
43 | This means calling the function again with the previous result returns the same result. | ||
44 | Returns S_FALSE if the path only contains a file name. | ||
33 | ********************************************************************/ | 45 | ********************************************************************/ |
34 | DAPI_(HRESULT) PathGetDirectory( | 46 | DAPI_(HRESULT) PathGetDirectory( |
35 | __in_z LPCWSTR wzPath, | 47 | __in_z LPCWSTR wzPath, |
@@ -38,6 +50,7 @@ DAPI_(HRESULT) PathGetDirectory( | |||
38 | 50 | ||
39 | /******************************************************************* | 51 | /******************************************************************* |
40 | PathGetParentPath - extracts the parent directory from a full path. | 52 | PathGetParentPath - extracts the parent directory from a full path. |
53 | *psczDirectory is NULL if the path only contains a file name. | ||
41 | ********************************************************************/ | 54 | ********************************************************************/ |
42 | DAPI_(HRESULT) PathGetParentPath( | 55 | DAPI_(HRESULT) PathGetParentPath( |
43 | __in_z LPCWSTR wzPath, | 56 | __in_z LPCWSTR wzPath, |
@@ -63,6 +76,21 @@ DAPI_(HRESULT) PathPrefix( | |||
63 | ); | 76 | ); |
64 | 77 | ||
65 | /******************************************************************* | 78 | /******************************************************************* |
79 | PathFixedNormalizeSlashes - replaces all / with \ and | ||
80 | removes redundant consecutive slashes. | ||
81 | ********************************************************************/ | ||
82 | DAPI_(HRESULT) PathFixedNormalizeSlashes( | ||
83 | __inout_z LPWSTR wzPath | ||
84 | ); | ||
85 | |||
86 | /******************************************************************* | ||
87 | PathFixedReplaceForwardSlashes - replaces all / with \ | ||
88 | ********************************************************************/ | ||
89 | DAPI_(void) PathFixedReplaceForwardSlashes( | ||
90 | __inout_z LPWSTR wzPath | ||
91 | ); | ||
92 | |||
93 | /******************************************************************* | ||
66 | PathFixedBackslashTerminate - appends a \ if path does not have it | 94 | PathFixedBackslashTerminate - appends a \ if path does not have it |
67 | already, but fails if the buffer is | 95 | already, but fails if the buffer is |
68 | insufficient. | 96 | insufficient. |
@@ -77,7 +105,7 @@ DAPI_(HRESULT) PathFixedBackslashTerminate( | |||
77 | already. | 105 | already. |
78 | ********************************************************************/ | 106 | ********************************************************************/ |
79 | DAPI_(HRESULT) PathBackslashTerminate( | 107 | DAPI_(HRESULT) PathBackslashTerminate( |
80 | __inout LPWSTR* psczPath | 108 | __inout_z LPWSTR* psczPath |
81 | ); | 109 | ); |
82 | 110 | ||
83 | /******************************************************************* | 111 | /******************************************************************* |
@@ -168,7 +196,7 @@ DAPI_(HRESULT) PathGetKnownFolder( | |||
168 | /******************************************************************* | 196 | /******************************************************************* |
169 | PathIsFullyQualified - returns true if the path is fully qualified; false otherwise. | 197 | PathIsFullyQualified - returns true if the path is fully qualified; false otherwise. |
170 | Note that some rooted paths like C:dir are not fully qualified. | 198 | Note that some rooted paths like C:dir are not fully qualified. |
171 | For example, these are all fully qualified: C:\dir, \\server\share, \\?\C:\dir. | 199 | For example, these are all fully qualified: C:\dir, C:/dir, \\server\share, \\?\C:\dir. |
172 | For example, these are not fully qualified: C:dir, C:, \dir, dir, dir\subdir. | 200 | For example, these are not fully qualified: C:dir, C:, \dir, dir, dir\subdir. |
173 | *******************************************************************/ | 201 | *******************************************************************/ |
174 | DAPI_(BOOL) PathIsFullyQualified( | 202 | DAPI_(BOOL) PathIsFullyQualified( |
@@ -179,7 +207,7 @@ DAPI_(BOOL) PathIsFullyQualified( | |||
179 | /******************************************************************* | 207 | /******************************************************************* |
180 | PathIsRooted - returns true if the path is rooted; false otherwise. | 208 | PathIsRooted - returns true if the path is rooted; false otherwise. |
181 | Note that some rooted paths like C:dir are not fully qualified. | 209 | Note that some rooted paths like C:dir are not fully qualified. |
182 | For example, these are all rooted: C:\dir, C:dir, C:, \dir, \\server\share, \\?\C:\dir. | 210 | For example, these are all rooted: C:\dir, C:/dir, C:dir, C:, \dir, \\server\share, \\?\C:\dir. |
183 | For example, these are not rooted: dir, dir\subdir. | 211 | For example, these are not rooted: dir, dir\subdir. |
184 | *******************************************************************/ | 212 | *******************************************************************/ |
185 | DAPI_(BOOL) PathIsRooted( | 213 | DAPI_(BOOL) PathIsRooted( |
@@ -240,7 +268,7 @@ DAPI_(HRESULT) PathGetHierarchyArray( | |||
240 | ); | 268 | ); |
241 | 269 | ||
242 | /******************************************************************* | 270 | /******************************************************************* |
243 | PathCanonicalizePath - wrapper around PathCanonicalizeW. | 271 | PathCanonicalizePath - wrapper around PathCanonicalizeW. |
244 | *******************************************************************/ | 272 | *******************************************************************/ |
245 | DAPI_(HRESULT) PathCanonicalizePath( | 273 | DAPI_(HRESULT) PathCanonicalizePath( |
246 | __in_z LPCWSTR wzPath, | 274 | __in_z LPCWSTR wzPath, |
@@ -248,8 +276,20 @@ DAPI_(HRESULT) PathCanonicalizePath( | |||
248 | ); | 276 | ); |
249 | 277 | ||
250 | /******************************************************************* | 278 | /******************************************************************* |
251 | PathDirectoryContainsPath - checks if wzPath is located inside | 279 | PathCanonicalizeForComparison - canonicalizes the path based on the given flags. |
252 | wzDirectory. | 280 | . and .. directories are collapsed. |
281 | All / are replaced with \. | ||
282 | All redundant consecutive slashes are replaced with a single \. | ||
283 | *******************************************************************/ | ||
284 | DAPI_(HRESULT) PathCanonicalizeForComparison( | ||
285 | __in_z LPCWSTR wzPath, | ||
286 | __in DWORD dwCanonicalizeFlags, | ||
287 | __deref_out_z LPWSTR* psczCanonicalized | ||
288 | ); | ||
289 | |||
290 | /******************************************************************* | ||
291 | PathDirectoryContainsPath - checks if wzPath is located inside wzDirectory. | ||
292 | wzDirectory must be a fully qualified path. | ||
253 | *******************************************************************/ | 293 | *******************************************************************/ |
254 | DAPI_(HRESULT) PathDirectoryContainsPath( | 294 | DAPI_(HRESULT) PathDirectoryContainsPath( |
255 | __in_z LPCWSTR wzDirectory, | 295 | __in_z LPCWSTR wzDirectory, |