diff options
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/inc/pathutil.h')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/inc/pathutil.h | 252 |
1 files changed, 252 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h b/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h new file mode 100644 index 00000000..579b8454 --- /dev/null +++ b/src/libs/dutil/WixToolset.DUtil/inc/pathutil.h | |||
@@ -0,0 +1,252 @@ | |||
1 | #pragma once | ||
2 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
3 | |||
4 | |||
5 | #ifdef __cplusplus | ||
6 | extern "C" { | ||
7 | #endif | ||
8 | |||
9 | typedef enum PATH_EXPAND | ||
10 | { | ||
11 | PATH_EXPAND_ENVIRONMENT = 0x0001, | ||
12 | PATH_EXPAND_FULLPATH = 0x0002, | ||
13 | } PATH_EXPAND; | ||
14 | |||
15 | |||
16 | /******************************************************************* | ||
17 | PathCommandLineAppend - appends a command line argument on to a | ||
18 | string such that ::CommandLineToArgv() will shred them correctly | ||
19 | (i.e. quote arguments with spaces in them). | ||
20 | ********************************************************************/ | ||
21 | DAPI_(HRESULT) PathCommandLineAppend( | ||
22 | __deref_inout_z LPWSTR* psczCommandLine, | ||
23 | __in_z LPCWSTR wzArgument | ||
24 | ); | ||
25 | |||
26 | /******************************************************************* | ||
27 | PathFile - returns a pointer to the file part of the path. | ||
28 | ********************************************************************/ | ||
29 | DAPI_(LPWSTR) PathFile( | ||
30 | __in_z LPCWSTR wzPath | ||
31 | ); | ||
32 | |||
33 | /******************************************************************* | ||
34 | PathExtension - returns a pointer to the extension part of the path | ||
35 | (including the dot). | ||
36 | ********************************************************************/ | ||
37 | DAPI_(LPCWSTR) PathExtension( | ||
38 | __in_z LPCWSTR wzPath | ||
39 | ); | ||
40 | |||
41 | /******************************************************************* | ||
42 | PathGetDirectory - extracts the directory from a path. | ||
43 | ********************************************************************/ | ||
44 | DAPI_(HRESULT) PathGetDirectory( | ||
45 | __in_z LPCWSTR wzPath, | ||
46 | __out_z LPWSTR *psczDirectory | ||
47 | ); | ||
48 | |||
49 | /******************************************************************* | ||
50 | PathGetParentPath - extracts the parent directory from a full path. | ||
51 | ********************************************************************/ | ||
52 | DAPI_(HRESULT) PathGetParentPath( | ||
53 | __in_z LPCWSTR wzPath, | ||
54 | __out_z LPWSTR *psczDirectory | ||
55 | ); | ||
56 | |||
57 | /******************************************************************* | ||
58 | PathExpand - gets the full path to a file resolving environment | ||
59 | variables along the way. | ||
60 | ********************************************************************/ | ||
61 | DAPI_(HRESULT) PathExpand( | ||
62 | __out LPWSTR *psczFullPath, | ||
63 | __in_z LPCWSTR wzRelativePath, | ||
64 | __in DWORD dwResolveFlags | ||
65 | ); | ||
66 | |||
67 | /******************************************************************* | ||
68 | PathPrefix - prefixes a full path with \\?\ or \\?\UNC as | ||
69 | appropriate. | ||
70 | ********************************************************************/ | ||
71 | DAPI_(HRESULT) PathPrefix( | ||
72 | __inout LPWSTR *psczFullPath | ||
73 | ); | ||
74 | |||
75 | /******************************************************************* | ||
76 | PathFixedBackslashTerminate - appends a \ if path does not have it | ||
77 | already, but fails if the buffer is | ||
78 | insufficient. | ||
79 | ********************************************************************/ | ||
80 | DAPI_(HRESULT) PathFixedBackslashTerminate( | ||
81 | __inout_ecount_z(cchPath) LPWSTR wzPath, | ||
82 | __in SIZE_T cchPath | ||
83 | ); | ||
84 | |||
85 | /******************************************************************* | ||
86 | PathBackslashTerminate - appends a \ if path does not have it | ||
87 | already. | ||
88 | ********************************************************************/ | ||
89 | DAPI_(HRESULT) PathBackslashTerminate( | ||
90 | __inout LPWSTR* psczPath | ||
91 | ); | ||
92 | |||
93 | /******************************************************************* | ||
94 | PathForCurrentProcess - gets the full path to the currently executing | ||
95 | process or (optionally) a module inside the process. | ||
96 | ********************************************************************/ | ||
97 | DAPI_(HRESULT) PathForCurrentProcess( | ||
98 | __inout LPWSTR *psczFullPath, | ||
99 | __in_opt HMODULE hModule | ||
100 | ); | ||
101 | |||
102 | /******************************************************************* | ||
103 | PathRelativeToModule - gets the name of a file in the same | ||
104 | directory as the current process or (optionally) a module inside | ||
105 | the process | ||
106 | ********************************************************************/ | ||
107 | DAPI_(HRESULT) PathRelativeToModule( | ||
108 | __inout LPWSTR *psczFullPath, | ||
109 | __in_opt LPCWSTR wzFileName, | ||
110 | __in_opt HMODULE hModule | ||
111 | ); | ||
112 | |||
113 | /******************************************************************* | ||
114 | PathCreateTempFile | ||
115 | |||
116 | Note: if wzDirectory is null, ::GetTempPath() will be used instead. | ||
117 | if wzFileNameTemplate is null, GetTempFileName() will be used instead. | ||
118 | *******************************************************************/ | ||
119 | DAPI_(HRESULT) PathCreateTempFile( | ||
120 | __in_opt LPCWSTR wzDirectory, | ||
121 | __in_opt __format_string LPCWSTR wzFileNameTemplate, | ||
122 | __in DWORD dwUniqueCount, | ||
123 | __in DWORD dwFileAttributes, | ||
124 | __out_opt LPWSTR* psczTempFile, | ||
125 | __out_opt HANDLE* phTempFile | ||
126 | ); | ||
127 | |||
128 | /******************************************************************* | ||
129 | PathCreateTimeBasedTempFile - creates an empty temp file based on current | ||
130 | system time | ||
131 | ********************************************************************/ | ||
132 | DAPI_(HRESULT) PathCreateTimeBasedTempFile( | ||
133 | __in_z_opt LPCWSTR wzDirectory, | ||
134 | __in_z LPCWSTR wzPrefix, | ||
135 | __in_z_opt LPCWSTR wzPostfix, | ||
136 | __in_z LPCWSTR wzExtension, | ||
137 | __deref_opt_out_z LPWSTR* psczTempFile, | ||
138 | __out_opt HANDLE* phTempFile | ||
139 | ); | ||
140 | |||
141 | /******************************************************************* | ||
142 | PathCreateTempDirectory | ||
143 | |||
144 | Note: if wzDirectory is null, ::GetTempPath() will be used instead. | ||
145 | *******************************************************************/ | ||
146 | DAPI_(HRESULT) PathCreateTempDirectory( | ||
147 | __in_opt LPCWSTR wzDirectory, | ||
148 | __in __format_string LPCWSTR wzDirectoryNameTemplate, | ||
149 | __in DWORD dwUniqueCount, | ||
150 | __out LPWSTR* psczTempDirectory | ||
151 | ); | ||
152 | |||
153 | /******************************************************************* | ||
154 | PathGetKnownFolder - returns the path to a well-known shell folder | ||
155 | |||
156 | *******************************************************************/ | ||
157 | DAPI_(HRESULT) PathGetKnownFolder( | ||
158 | __in int csidl, | ||
159 | __out LPWSTR* psczKnownFolder | ||
160 | ); | ||
161 | |||
162 | /******************************************************************* | ||
163 | PathIsAbsolute - returns true if the path is absolute; false | ||
164 | otherwise. | ||
165 | *******************************************************************/ | ||
166 | DAPI_(BOOL) PathIsAbsolute( | ||
167 | __in_z LPCWSTR wzPath | ||
168 | ); | ||
169 | |||
170 | /******************************************************************* | ||
171 | PathConcat - like .NET's Path.Combine, lets you build up a path | ||
172 | one piece -- file or directory -- at a time. | ||
173 | *******************************************************************/ | ||
174 | DAPI_(HRESULT) PathConcat( | ||
175 | __in_opt LPCWSTR wzPath1, | ||
176 | __in_opt LPCWSTR wzPath2, | ||
177 | __deref_out_z LPWSTR* psczCombined | ||
178 | ); | ||
179 | |||
180 | /******************************************************************* | ||
181 | PathConcatCch - like .NET's Path.Combine, lets you build up a path | ||
182 | one piece -- file or directory -- at a time. | ||
183 | *******************************************************************/ | ||
184 | DAPI_(HRESULT) PathConcatCch( | ||
185 | __in_opt LPCWSTR wzPath1, | ||
186 | __in SIZE_T cchPath1, | ||
187 | __in_opt LPCWSTR wzPath2, | ||
188 | __in SIZE_T cchPath2, | ||
189 | __deref_out_z LPWSTR* psczCombined | ||
190 | ); | ||
191 | |||
192 | /******************************************************************* | ||
193 | PathEnsureQuoted - ensures that a path is quoted; optionally, | ||
194 | this function also terminates a directory with a backslash | ||
195 | if it is not already. | ||
196 | *******************************************************************/ | ||
197 | DAPI_(HRESULT) PathEnsureQuoted( | ||
198 | __inout LPWSTR* ppszPath, | ||
199 | __in BOOL fDirectory | ||
200 | ); | ||
201 | |||
202 | /******************************************************************* | ||
203 | PathCompare - compares the fully expanded path of the two paths using | ||
204 | ::CompareStringW(). | ||
205 | *******************************************************************/ | ||
206 | DAPI_(HRESULT) PathCompare( | ||
207 | __in_z LPCWSTR wzPath1, | ||
208 | __in_z LPCWSTR wzPath2, | ||
209 | __out int* pnResult | ||
210 | ); | ||
211 | |||
212 | /******************************************************************* | ||
213 | PathCompress - sets the compression state on an existing file or | ||
214 | directory. A no-op on file systems that don't | ||
215 | support compression. | ||
216 | *******************************************************************/ | ||
217 | DAPI_(HRESULT) PathCompress( | ||
218 | __in_z LPCWSTR wzPath | ||
219 | ); | ||
220 | |||
221 | /******************************************************************* | ||
222 | PathGetHierarchyArray - allocates an array containing, | ||
223 | in order, every parent directory of the specified path, | ||
224 | ending with the actual input path | ||
225 | This function also works with registry subkeys | ||
226 | *******************************************************************/ | ||
227 | DAPI_(HRESULT) PathGetHierarchyArray( | ||
228 | __in_z LPCWSTR wzPath, | ||
229 | __deref_inout_ecount_opt(*pcPathArray) LPWSTR **prgsczPathArray, | ||
230 | __inout LPUINT pcPathArray | ||
231 | ); | ||
232 | |||
233 | /******************************************************************* | ||
234 | PathCanonicalizePath - wrapper around PathCanonicalizeW. | ||
235 | *******************************************************************/ | ||
236 | DAPI_(HRESULT) PathCanonicalizePath( | ||
237 | __in_z LPCWSTR wzPath, | ||
238 | __deref_out_z LPWSTR* psczCanonicalized | ||
239 | ); | ||
240 | |||
241 | /******************************************************************* | ||
242 | PathDirectoryContainsPath - checks if wzPath is located inside | ||
243 | wzDirectory. | ||
244 | *******************************************************************/ | ||
245 | DAPI_(HRESULT) PathDirectoryContainsPath( | ||
246 | __in_z LPCWSTR wzDirectory, | ||
247 | __in_z LPCWSTR wzPath | ||
248 | ); | ||
249 | |||
250 | #ifdef __cplusplus | ||
251 | } | ||
252 | #endif | ||