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