1 | /** @file
|
---|
2 | * IPRT - Path Manipulation.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2013 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___iprt_path_h
|
---|
27 | #define ___iprt_path_h
|
---|
28 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 | #ifdef IN_RING3
|
---|
32 | # include <iprt/fs.h>
|
---|
33 | #endif
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 | RT_C_DECLS_BEGIN
|
---|
38 |
|
---|
39 | /** @defgroup grp_rt_path RTPath - Path Manipulation
|
---|
40 | * @ingroup grp_rt
|
---|
41 | * @{
|
---|
42 | */
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Host max path (the reasonable value).
|
---|
46 | * @remarks defined both by iprt/param.h and iprt/path.h.
|
---|
47 | */
|
---|
48 | #if !defined(___iprt_param_h) || defined(DOXYGEN_RUNNING)
|
---|
49 | # define RTPATH_MAX (4096 + 4) /* (PATH_MAX + 1) on linux w/ some alignment */
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | /** @def RTPATH_SLASH
|
---|
53 | * The preferred slash character.
|
---|
54 | *
|
---|
55 | * @remark IPRT will always accept unix slashes. So, normally you would
|
---|
56 | * never have to use this define.
|
---|
57 | */
|
---|
58 | #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
|
---|
59 | # define RTPATH_SLASH '\\'
|
---|
60 | #else
|
---|
61 | # define RTPATH_SLASH '/'
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | /** @deprecated Use '/'! */
|
---|
65 | #define RTPATH_DELIMITER RTPATH_SLASH
|
---|
66 |
|
---|
67 |
|
---|
68 | /** @def RTPATH_SLASH_STR
|
---|
69 | * The preferred slash character as a string, handy for concatenations
|
---|
70 | * with other strings.
|
---|
71 | *
|
---|
72 | * @remark IPRT will always accept unix slashes. So, normally you would
|
---|
73 | * never have to use this define.
|
---|
74 | */
|
---|
75 | #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
|
---|
76 | # define RTPATH_SLASH_STR "\\"
|
---|
77 | #else
|
---|
78 | # define RTPATH_SLASH_STR "/"
|
---|
79 | #endif
|
---|
80 |
|
---|
81 |
|
---|
82 | /** @def RTPATH_IS_SLASH
|
---|
83 | * Checks if a character is a slash.
|
---|
84 | *
|
---|
85 | * @returns true if it's a slash and false if not.
|
---|
86 | * @returns @param ch Char to check.
|
---|
87 | */
|
---|
88 | #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
|
---|
89 | # define RTPATH_IS_SLASH(ch) ( (ch) == '\\' || (ch) == '/' )
|
---|
90 | #else
|
---|
91 | # define RTPATH_IS_SLASH(ch) ( (ch) == '/' )
|
---|
92 | #endif
|
---|
93 |
|
---|
94 |
|
---|
95 | /** @def RTPATH_IS_VOLSEP
|
---|
96 | * Checks if a character marks the end of the volume specification.
|
---|
97 | *
|
---|
98 | * @remark This is sufficient for the drive letter concept on PC.
|
---|
99 | * However it might be insufficient on other platforms
|
---|
100 | * and even on PC a UNC volume spec won't be detected this way.
|
---|
101 | * Use the RTPath@<too be created@>() instead.
|
---|
102 | *
|
---|
103 | * @returns true if it is and false if it isn't.
|
---|
104 | * @returns @param ch Char to check.
|
---|
105 | */
|
---|
106 | #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
|
---|
107 | # define RTPATH_IS_VOLSEP(ch) ( (ch) == ':' )
|
---|
108 | #else
|
---|
109 | # define RTPATH_IS_VOLSEP(ch) (false)
|
---|
110 | #endif
|
---|
111 |
|
---|
112 |
|
---|
113 | /** @def RTPATH_IS_SEP
|
---|
114 | * Checks if a character is path component separator
|
---|
115 | *
|
---|
116 | * @returns true if it is and false if it isn't.
|
---|
117 | * @returns @param ch Char to check.
|
---|
118 | * @
|
---|
119 | */
|
---|
120 | #define RTPATH_IS_SEP(ch) ( RTPATH_IS_SLASH(ch) || RTPATH_IS_VOLSEP(ch) )
|
---|
121 |
|
---|
122 |
|
---|
123 | /** @name Generic RTPath flags
|
---|
124 | * @{ */
|
---|
125 | /** Last component: Work on the link. */
|
---|
126 | #define RTPATH_F_ON_LINK RT_BIT_32(0)
|
---|
127 | /** Last component: Follow if link. */
|
---|
128 | #define RTPATH_F_FOLLOW_LINK RT_BIT_32(1)
|
---|
129 | /** Don't allow symbolic links as part of the path.
|
---|
130 | * @remarks this flag is currently not implemented and will be ignored. */
|
---|
131 | #define RTPATH_F_NO_SYMLINKS RT_BIT_32(2)
|
---|
132 | /** @} */
|
---|
133 |
|
---|
134 |
|
---|
135 | /** Validates a flags parameter containing RTPATH_F_*.
|
---|
136 | * @remarks The parameters will be referenced multiple times. */
|
---|
137 | #define RTPATH_F_IS_VALID(fFlags, fIgnore) \
|
---|
138 | ( ((fFlags) & ~(uint32_t)((fIgnore)|RTPATH_F_NO_SYMLINKS)) == RTPATH_F_ON_LINK \
|
---|
139 | || ((fFlags) & ~(uint32_t)((fIgnore)|RTPATH_F_NO_SYMLINKS)) == RTPATH_F_FOLLOW_LINK )
|
---|
140 |
|
---|
141 |
|
---|
142 | /**
|
---|
143 | * Checks if the path exists.
|
---|
144 | *
|
---|
145 | * Symbolic links will all be attempted resolved and broken links means false.
|
---|
146 | *
|
---|
147 | * @returns true if it exists and false if it doesn't.
|
---|
148 | * @param pszPath The path to check.
|
---|
149 | */
|
---|
150 | RTDECL(bool) RTPathExists(const char *pszPath);
|
---|
151 |
|
---|
152 | /**
|
---|
153 | * Checks if the path exists.
|
---|
154 | *
|
---|
155 | * @returns true if it exists and false if it doesn't.
|
---|
156 | * @param pszPath The path to check.
|
---|
157 | * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
|
---|
158 | */
|
---|
159 | RTDECL(bool) RTPathExistsEx(const char *pszPath, uint32_t fFlags);
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * Sets the current working directory of the process.
|
---|
163 | *
|
---|
164 | * @returns IPRT status code.
|
---|
165 | * @param pszPath The path to the new working directory.
|
---|
166 | */
|
---|
167 | RTDECL(int) RTPathSetCurrent(const char *pszPath);
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * Gets the current working directory of the process.
|
---|
171 | *
|
---|
172 | * @returns IPRT status code.
|
---|
173 | * @param pszPath Where to store the path.
|
---|
174 | * @param cchPath The size of the buffer pszPath points to.
|
---|
175 | */
|
---|
176 | RTDECL(int) RTPathGetCurrent(char *pszPath, size_t cchPath);
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Get the real path (no symlinks, no . or .. components), must exist.
|
---|
180 | *
|
---|
181 | * @returns iprt status code.
|
---|
182 | * @param pszPath The path to resolve.
|
---|
183 | * @param pszRealPath Where to store the real path.
|
---|
184 | * @param cchRealPath Size of the buffer.
|
---|
185 | */
|
---|
186 | RTDECL(int) RTPathReal(const char *pszPath, char *pszRealPath, size_t cchRealPath);
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * Same as RTPathReal only the result is RTStrDup()'ed.
|
---|
190 | *
|
---|
191 | * @returns Pointer to real path. Use RTStrFree() to free this string.
|
---|
192 | * @returns NULL if RTPathReal() or RTStrDup() fails.
|
---|
193 | * @param pszPath The path to resolve.
|
---|
194 | */
|
---|
195 | RTDECL(char *) RTPathRealDup(const char *pszPath);
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * Get the absolute path (starts from root, no . or .. components), doesn't have
|
---|
199 | * to exist. Note that this method is designed to never perform actual file
|
---|
200 | * system access, therefore symlinks are not resolved.
|
---|
201 | *
|
---|
202 | * @returns iprt status code.
|
---|
203 | * @param pszPath The path to resolve.
|
---|
204 | * @param pszAbsPath Where to store the absolute path.
|
---|
205 | * @param cchAbsPath Size of the buffer.
|
---|
206 | */
|
---|
207 | RTDECL(int) RTPathAbs(const char *pszPath, char *pszAbsPath, size_t cchAbsPath);
|
---|
208 |
|
---|
209 | /**
|
---|
210 | * Same as RTPathAbs only the result is RTStrDup()'ed.
|
---|
211 | *
|
---|
212 | * @returns Pointer to the absolute path. Use RTStrFree() to free this string.
|
---|
213 | * @returns NULL if RTPathAbs() or RTStrDup() fails.
|
---|
214 | * @param pszPath The path to resolve.
|
---|
215 | */
|
---|
216 | RTDECL(char *) RTPathAbsDup(const char *pszPath);
|
---|
217 |
|
---|
218 | /**
|
---|
219 | * Get the absolute path (no symlinks, no . or .. components), assuming the
|
---|
220 | * given base path as the current directory. The resulting path doesn't have
|
---|
221 | * to exist.
|
---|
222 | *
|
---|
223 | * @returns iprt status code.
|
---|
224 | * @param pszBase The base path to act like a current directory.
|
---|
225 | * When NULL, the actual cwd is used (i.e. the call
|
---|
226 | * is equivalent to RTPathAbs(pszPath, ...).
|
---|
227 | * @param pszPath The path to resolve.
|
---|
228 | * @param pszAbsPath Where to store the absolute path.
|
---|
229 | * @param cchAbsPath Size of the buffer.
|
---|
230 | */
|
---|
231 | RTDECL(int) RTPathAbsEx(const char *pszBase, const char *pszPath, char *pszAbsPath, size_t cchAbsPath);
|
---|
232 |
|
---|
233 | /**
|
---|
234 | * Same as RTPathAbsEx only the result is RTStrDup()'ed.
|
---|
235 | *
|
---|
236 | * @returns Pointer to the absolute path. Use RTStrFree() to free this string.
|
---|
237 | * @returns NULL if RTPathAbsEx() or RTStrDup() fails.
|
---|
238 | * @param pszBase The base path to act like a current directory.
|
---|
239 | * When NULL, the actual cwd is used (i.e. the call
|
---|
240 | * is equivalent to RTPathAbs(pszPath, ...).
|
---|
241 | * @param pszPath The path to resolve.
|
---|
242 | */
|
---|
243 | RTDECL(char *) RTPathAbsExDup(const char *pszBase, const char *pszPath);
|
---|
244 |
|
---|
245 | /**
|
---|
246 | * Strips the filename from a path. Truncates the given string in-place by overwriting the
|
---|
247 | * last path separator character with a null byte in a platform-neutral way.
|
---|
248 | *
|
---|
249 | * @param pszPath Path from which filename should be extracted, will be truncated.
|
---|
250 | * If the string contains no path separator, it will be changed to a "." string.
|
---|
251 | */
|
---|
252 | RTDECL(void) RTPathStripFilename(char *pszPath);
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Strips the extension from a path.
|
---|
256 | *
|
---|
257 | * @param pszPath Path which extension should be stripped.
|
---|
258 | */
|
---|
259 | RTDECL(void) RTPathStripExt(char *pszPath);
|
---|
260 |
|
---|
261 | /**
|
---|
262 | * Strips the trailing slashes of a path name.
|
---|
263 | *
|
---|
264 | * Won't strip root slashes.
|
---|
265 | *
|
---|
266 | * @returns The new length of pszPath.
|
---|
267 | * @param pszPath Path to strip.
|
---|
268 | */
|
---|
269 | RTDECL(size_t) RTPathStripTrailingSlash(char *pszPath);
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * Changes all the slashes in the specified path to DOS style.
|
---|
273 | *
|
---|
274 | * Unless @a fForce is set, nothing will be done when on a UNIX flavored system
|
---|
275 | * since paths wont work with DOS style slashes there.
|
---|
276 | *
|
---|
277 | * @returns @a pszPath.
|
---|
278 | * @param pszPath The path to modify.
|
---|
279 | * @param fForce Whether to force the conversion on non-DOS OSes.
|
---|
280 | */
|
---|
281 | RTDECL(char *) RTPathChangeToDosSlashes(char *pszPath, bool fForce);
|
---|
282 |
|
---|
283 | /**
|
---|
284 | * Changes all the slashes in the specified path to unix style.
|
---|
285 | *
|
---|
286 | * Unless @a fForce is set, nothing will be done when on a UNIX flavored system
|
---|
287 | * since paths wont work with DOS style slashes there.
|
---|
288 | *
|
---|
289 | * @returns @a pszPath.
|
---|
290 | * @param pszPath The path to modify.
|
---|
291 | * @param fForce Whether to force the conversion on non-DOS OSes.
|
---|
292 | */
|
---|
293 | RTDECL(char *) RTPathChangeToUnixSlashes(char *pszPath, bool fForce);
|
---|
294 |
|
---|
295 | /**
|
---|
296 | * Simple parsing of the a path.
|
---|
297 | *
|
---|
298 | * It figures the length of the directory component, the offset of
|
---|
299 | * the file name and the location of the suffix dot.
|
---|
300 | *
|
---|
301 | * @returns The path length.
|
---|
302 | *
|
---|
303 | * @param pszPath Path to find filename in.
|
---|
304 | * @param pcchDir Where to put the length of the directory component. If
|
---|
305 | * no directory, this will be 0. Optional.
|
---|
306 | * @param poffName Where to store the filename offset.
|
---|
307 | * If empty string or if it's ending with a slash this
|
---|
308 | * will be set to -1. Optional.
|
---|
309 | * @param poffSuff Where to store the suffix offset (the last dot).
|
---|
310 | * If empty string or if it's ending with a slash this
|
---|
311 | * will be set to -1. Optional.
|
---|
312 | */
|
---|
313 | RTDECL(size_t) RTPathParseSimple(const char *pszPath, size_t *pcchDir, ssize_t *poffName, ssize_t *poffSuff);
|
---|
314 |
|
---|
315 | /**
|
---|
316 | * Finds the filename in a path.
|
---|
317 | *
|
---|
318 | * @returns Pointer to filename within pszPath.
|
---|
319 | * @returns NULL if no filename (i.e. empty string or ends with a slash).
|
---|
320 | * @param pszPath Path to find filename in.
|
---|
321 | */
|
---|
322 | RTDECL(char *) RTPathFilename(const char *pszPath);
|
---|
323 |
|
---|
324 | /**
|
---|
325 | * Finds the extension part of in a path.
|
---|
326 | *
|
---|
327 | * @returns Pointer to extension within pszPath.
|
---|
328 | * @returns NULL if no extension.
|
---|
329 | * @param pszPath Path to find extension in.
|
---|
330 | */
|
---|
331 | RTDECL(char *) RTPathExt(const char *pszPath);
|
---|
332 |
|
---|
333 | /**
|
---|
334 | * Checks if a path has an extension.
|
---|
335 | *
|
---|
336 | * @returns true if extension present.
|
---|
337 | * @returns false if no extension.
|
---|
338 | * @param pszPath Path to check.
|
---|
339 | */
|
---|
340 | RTDECL(bool) RTPathHasExt(const char *pszPath);
|
---|
341 | /** Misspelled, don't use. */
|
---|
342 | #define RTPathHaveExt RTPathHasExt
|
---|
343 |
|
---|
344 | /**
|
---|
345 | * Checks if a path includes more than a filename.
|
---|
346 | *
|
---|
347 | * @returns true if path present.
|
---|
348 | * @returns false if no path.
|
---|
349 | * @param pszPath Path to check.
|
---|
350 | */
|
---|
351 | RTDECL(bool) RTPathHasPath(const char *pszPath);
|
---|
352 | /** Misspelled, don't use. */
|
---|
353 | #define RTPathHavePath RTPathHasPath
|
---|
354 |
|
---|
355 | /**
|
---|
356 | * Checks if the path starts with a root specifier or not.
|
---|
357 | *
|
---|
358 | * @returns @c true if it starts with root, @c false if not.
|
---|
359 | *
|
---|
360 | * @param pszPath Path to check.
|
---|
361 | */
|
---|
362 | RTDECL(bool) RTPathStartsWithRoot(const char *pszPath);
|
---|
363 |
|
---|
364 | /**
|
---|
365 | * Counts the components in the specified path.
|
---|
366 | *
|
---|
367 | * An empty string has zero components. A lone root slash is considered have
|
---|
368 | * one. The paths "/init" and "/bin/" are considered having two components. An
|
---|
369 | * UNC share specifier like "\\myserver\share" will be considered as one single
|
---|
370 | * component.
|
---|
371 | *
|
---|
372 | * @returns The number of path components.
|
---|
373 | * @param pszPath The path to parse.
|
---|
374 | */
|
---|
375 | RTDECL(size_t) RTPathCountComponents(const char *pszPath);
|
---|
376 |
|
---|
377 | /**
|
---|
378 | * Copies the specified number of path components from @a pszSrc and into @a
|
---|
379 | * pszDst.
|
---|
380 | *
|
---|
381 | * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW. In the latter case the buffer
|
---|
382 | * is not touched.
|
---|
383 | *
|
---|
384 | * @param pszDst The destination buffer.
|
---|
385 | * @param cbDst The size of the destination buffer.
|
---|
386 | * @param pszSrc The source path.
|
---|
387 | * @param cComponents The number of components to copy from @a pszSrc.
|
---|
388 | */
|
---|
389 | RTDECL(int) RTPathCopyComponents(char *pszDst, size_t cbDst, const char *pszSrc, size_t cComponents);
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Compares two paths.
|
---|
393 | *
|
---|
394 | * The comparison takes platform-dependent details into account,
|
---|
395 | * such as:
|
---|
396 | * <ul>
|
---|
397 | * <li>On DOS-like platforms, both separator chars (|\| and |/|) are considered
|
---|
398 | * to be equal.
|
---|
399 | * <li>On platforms with case-insensitive file systems, mismatching characters
|
---|
400 | * are uppercased and compared again.
|
---|
401 | * </ul>
|
---|
402 | *
|
---|
403 | * @returns @< 0 if the first path less than the second path.
|
---|
404 | * @returns 0 if the first path identical to the second path.
|
---|
405 | * @returns @> 0 if the first path greater than the second path.
|
---|
406 | *
|
---|
407 | * @param pszPath1 Path to compare (must be an absolute path).
|
---|
408 | * @param pszPath2 Path to compare (must be an absolute path).
|
---|
409 | *
|
---|
410 | * @remarks File system details are currently ignored. This means that you won't
|
---|
411 | * get case-insensitive compares on unix systems when a path goes into a
|
---|
412 | * case-insensitive filesystem like FAT, HPFS, HFS, NTFS, JFS, or
|
---|
413 | * similar. For NT, OS/2 and similar you'll won't get case-sensitive
|
---|
414 | * compares on a case-sensitive file system.
|
---|
415 | */
|
---|
416 | RTDECL(int) RTPathCompare(const char *pszPath1, const char *pszPath2);
|
---|
417 |
|
---|
418 | /**
|
---|
419 | * Checks if a path starts with the given parent path.
|
---|
420 | *
|
---|
421 | * This means that either the path and the parent path matches completely, or
|
---|
422 | * that the path is to some file or directory residing in the tree given by the
|
---|
423 | * parent directory.
|
---|
424 | *
|
---|
425 | * The path comparison takes platform-dependent details into account,
|
---|
426 | * see RTPathCompare() for details.
|
---|
427 | *
|
---|
428 | * @returns |true| when \a pszPath starts with \a pszParentPath (or when they
|
---|
429 | * are identical), or |false| otherwise.
|
---|
430 | *
|
---|
431 | * @param pszPath Path to check, must be an absolute path.
|
---|
432 | * @param pszParentPath Parent path, must be an absolute path.
|
---|
433 | * No trailing directory slash!
|
---|
434 | *
|
---|
435 | * @remarks This API doesn't currently handle root directory compares in a
|
---|
436 | * manner consistent with the other APIs. RTPathStartsWith(pszSomePath,
|
---|
437 | * "/") will not work if pszSomePath isn't "/".
|
---|
438 | */
|
---|
439 | RTDECL(bool) RTPathStartsWith(const char *pszPath, const char *pszParentPath);
|
---|
440 |
|
---|
441 | /**
|
---|
442 | * Appends one partial path to another.
|
---|
443 | *
|
---|
444 | * The main purpose of this function is to deal correctly with the slashes when
|
---|
445 | * concatenating the two partial paths.
|
---|
446 | *
|
---|
447 | * @retval VINF_SUCCESS on success.
|
---|
448 | * @retval VERR_BUFFER_OVERFLOW if the result is too big to fit within
|
---|
449 | * cbPathDst bytes. No changes has been made.
|
---|
450 | * @retval VERR_INVALID_PARAMETER if the string pointed to by pszPath is longer
|
---|
451 | * than cbPathDst-1 bytes (failed to find terminator). Asserted.
|
---|
452 | *
|
---|
453 | * @param pszPath The path to append pszAppend to. This serves as both
|
---|
454 | * input and output. This can be empty, in which case
|
---|
455 | * pszAppend is just copied over.
|
---|
456 | * @param cbPathDst The size of the buffer pszPath points to, terminator
|
---|
457 | * included. This should NOT be strlen(pszPath).
|
---|
458 | * @param pszAppend The partial path to append to pszPath. This can be
|
---|
459 | * NULL, in which case nothing is done.
|
---|
460 | *
|
---|
461 | * @remarks See the RTPathAppendEx remarks.
|
---|
462 | */
|
---|
463 | RTDECL(int) RTPathAppend(char *pszPath, size_t cbPathDst, const char *pszAppend);
|
---|
464 |
|
---|
465 | /**
|
---|
466 | * Appends one partial path to another.
|
---|
467 | *
|
---|
468 | * The main purpose of this function is to deal correctly with the slashes when
|
---|
469 | * concatenating the two partial paths.
|
---|
470 | *
|
---|
471 | * @retval VINF_SUCCESS on success.
|
---|
472 | * @retval VERR_BUFFER_OVERFLOW if the result is too big to fit within
|
---|
473 | * cbPathDst bytes. No changes has been made.
|
---|
474 | * @retval VERR_INVALID_PARAMETER if the string pointed to by pszPath is longer
|
---|
475 | * than cbPathDst-1 bytes (failed to find terminator). Asserted.
|
---|
476 | *
|
---|
477 | * @param pszPath The path to append pszAppend to. This serves as both
|
---|
478 | * input and output. This can be empty, in which case
|
---|
479 | * pszAppend is just copied over.
|
---|
480 | * @param cbPathDst The size of the buffer pszPath points to, terminator
|
---|
481 | * included. This should NOT be strlen(pszPath).
|
---|
482 | * @param pszAppend The partial path to append to pszPath. This can be
|
---|
483 | * NULL, in which case nothing is done.
|
---|
484 | * @param cchAppendMax The maximum number or characters to take from @a
|
---|
485 | * pszAppend. RTSTR_MAX is fine.
|
---|
486 | *
|
---|
487 | * @remarks On OS/2, Window and similar systems, concatenating a drive letter
|
---|
488 | * specifier with a slash prefixed path will result in an absolute
|
---|
489 | * path. Meaning, RTPathAppend(strcpy(szBuf, "C:"), sizeof(szBuf),
|
---|
490 | * "/bar") will result in "C:/bar". (This follows directly from the
|
---|
491 | * behavior when pszPath is empty.)
|
---|
492 | *
|
---|
493 | * On the other hand, when joining a drive letter specifier with a
|
---|
494 | * partial path that does not start with a slash, the result is not an
|
---|
495 | * absolute path. Meaning, RTPathAppend(strcpy(szBuf, "C:"),
|
---|
496 | * sizeof(szBuf), "bar") will result in "C:bar".
|
---|
497 | */
|
---|
498 | RTDECL(int) RTPathAppendEx(char *pszPath, size_t cbPathDst, const char *pszAppend, size_t cchAppendMax);
|
---|
499 |
|
---|
500 | /**
|
---|
501 | * Like RTPathAppend, but with the base path as a separate argument instead of
|
---|
502 | * in the path buffer.
|
---|
503 | *
|
---|
504 | * @retval VINF_SUCCESS on success.
|
---|
505 | * @retval VERR_BUFFER_OVERFLOW if the result is too big to fit within
|
---|
506 | * cbPathDst bytes.
|
---|
507 | * @retval VERR_INVALID_PARAMETER if the string pointed to by pszPath is longer
|
---|
508 | * than cbPathDst-1 bytes (failed to find terminator). Asserted.
|
---|
509 | *
|
---|
510 | * @param pszPathDst Where to store the resulting path.
|
---|
511 | * @param cbPathDst The size of the buffer pszPathDst points to,
|
---|
512 | * terminator included.
|
---|
513 | * @param pszPathSrc The base path to copy into @a pszPathDst before
|
---|
514 | * appending @a pszAppend.
|
---|
515 | * @param pszAppend The partial path to append to pszPathSrc. This can
|
---|
516 | * be NULL, in which case nothing is done.
|
---|
517 | *
|
---|
518 | */
|
---|
519 | RTDECL(int) RTPathJoin(char *pszPathDst, size_t cbPathDst, const char *pszPathSrc,
|
---|
520 | const char *pszAppend);
|
---|
521 |
|
---|
522 | /**
|
---|
523 | * Same as RTPathJoin, except that the output buffer is allocated.
|
---|
524 | *
|
---|
525 | * @returns Buffer containing the joined up path, call RTStrFree to free. NULL
|
---|
526 | * on allocation failure.
|
---|
527 | * @param pszPathSrc The base path to copy into @a pszPathDst before
|
---|
528 | * appending @a pszAppend.
|
---|
529 | * @param pszAppend The partial path to append to pszPathSrc. This can
|
---|
530 | * be NULL, in which case nothing is done.
|
---|
531 | *
|
---|
532 | */
|
---|
533 | RTDECL(char *) RTPathJoinA(const char *pszPathSrc, const char *pszAppend);
|
---|
534 |
|
---|
535 | /**
|
---|
536 | * Extended version of RTPathJoin, both inputs can be specified as substrings.
|
---|
537 | *
|
---|
538 | * @retval VINF_SUCCESS on success.
|
---|
539 | * @retval VERR_BUFFER_OVERFLOW if the result is too big to fit within
|
---|
540 | * cbPathDst bytes.
|
---|
541 | * @retval VERR_INVALID_PARAMETER if the string pointed to by pszPath is longer
|
---|
542 | * than cbPathDst-1 bytes (failed to find terminator). Asserted.
|
---|
543 | *
|
---|
544 | * @param pszPathDst Where to store the resulting path.
|
---|
545 | * @param cbPathDst The size of the buffer pszPathDst points to,
|
---|
546 | * terminator included.
|
---|
547 | * @param pszPathSrc The base path to copy into @a pszPathDst before
|
---|
548 | * appending @a pszAppend.
|
---|
549 | * @param cchPathSrcMax The maximum number of bytes to copy from @a
|
---|
550 | * pszPathSrc. RTSTR_MAX is find.
|
---|
551 | * @param pszAppend The partial path to append to pszPathSrc. This can
|
---|
552 | * be NULL, in which case nothing is done.
|
---|
553 | * @param cchAppendMax The maximum number of bytes to copy from @a
|
---|
554 | * pszAppend. RTSTR_MAX is find.
|
---|
555 | *
|
---|
556 | */
|
---|
557 | RTDECL(int) RTPathJoinEx(char *pszPathDst, size_t cbPathDst,
|
---|
558 | const char *pszPathSrc, size_t cchPathSrcMax,
|
---|
559 | const char *pszAppend, size_t cchAppendMax);
|
---|
560 |
|
---|
561 | /**
|
---|
562 | * Callback for RTPathTraverseList that's called for each element.
|
---|
563 | *
|
---|
564 | * @returns IPRT style status code. Return VERR_TRY_AGAIN to continue, any other
|
---|
565 | * value will abort the traversing and be returned to the caller.
|
---|
566 | *
|
---|
567 | * @param pchPath Pointer to the start of the current path. This is
|
---|
568 | * not null terminated.
|
---|
569 | * @param cchPath The length of the path.
|
---|
570 | * @param pvUser1 The first user parameter.
|
---|
571 | * @param pvUser2 The second user parameter.
|
---|
572 | */
|
---|
573 | typedef DECLCALLBACK(int) FNRTPATHTRAVERSER(char const *pchPath, size_t cchPath, void *pvUser1, void *pvUser2);
|
---|
574 | /** Pointer to a FNRTPATHTRAVERSER. */
|
---|
575 | typedef FNRTPATHTRAVERSER *PFNRTPATHTRAVERSER;
|
---|
576 |
|
---|
577 | /**
|
---|
578 | * Traverses a string that can contain multiple paths separated by a special
|
---|
579 | * character.
|
---|
580 | *
|
---|
581 | * @returns IPRT style status code from the callback or VERR_END_OF_STRING if
|
---|
582 | * the callback returned VERR_TRY_AGAIN for all paths in the string.
|
---|
583 | *
|
---|
584 | * @param pszPathList The string to traverse.
|
---|
585 | * @param chSep The separator character. Using the null terminator
|
---|
586 | * is fine, but the result will simply be that there
|
---|
587 | * will only be one callback for the entire string
|
---|
588 | * (save any leading white space).
|
---|
589 | * @param pfnCallback The callback.
|
---|
590 | * @param pvUser1 First user argument for the callback.
|
---|
591 | * @param pvUser2 Second user argument for the callback.
|
---|
592 | */
|
---|
593 | RTDECL(int) RTPathTraverseList(const char *pszPathList, char chSep, PFNRTPATHTRAVERSER pfnCallback, void *pvUser1, void *pvUser2);
|
---|
594 |
|
---|
595 |
|
---|
596 | /**
|
---|
597 | * Calculate a relative path between the two given paths.
|
---|
598 | *
|
---|
599 | * @returns IPRT status code.
|
---|
600 | * @retval VINF_SUCCESS on success.
|
---|
601 | * @retval VERR_BUFFER_OVERFLOW if the result is too big to fit within
|
---|
602 | * cbPathDst bytes.
|
---|
603 | * @retval VERR_NOT_SUPPORTED if both paths start with different volume specifiers.
|
---|
604 | * @param pszPathDst Where to store the resulting path.
|
---|
605 | * @param cbPathDst The size of the buffer pszPathDst points to,
|
---|
606 | * terminator included.
|
---|
607 | * @param pszPathFrom The path to start from creating the relative path.
|
---|
608 | * @param pszPathTo The path to reach with the created relative path.
|
---|
609 | */
|
---|
610 | RTDECL(int) RTPathCalcRelative(char *pszPathDst, size_t cbPathDst,
|
---|
611 | const char *pszPathFrom,
|
---|
612 | const char *pszPathTo);
|
---|
613 |
|
---|
614 | #ifdef IN_RING3
|
---|
615 |
|
---|
616 | /**
|
---|
617 | * Gets the path to the directory containing the executable.
|
---|
618 | *
|
---|
619 | * @returns iprt status code.
|
---|
620 | * @param pszPath Buffer where to store the path.
|
---|
621 | * @param cchPath Buffer size in bytes.
|
---|
622 | */
|
---|
623 | RTDECL(int) RTPathExecDir(char *pszPath, size_t cchPath);
|
---|
624 |
|
---|
625 | /**
|
---|
626 | * Gets the user home directory.
|
---|
627 | *
|
---|
628 | * @returns iprt status code.
|
---|
629 | * @param pszPath Buffer where to store the path.
|
---|
630 | * @param cchPath Buffer size in bytes.
|
---|
631 | */
|
---|
632 | RTDECL(int) RTPathUserHome(char *pszPath, size_t cchPath);
|
---|
633 |
|
---|
634 | /**
|
---|
635 | * Gets the user documents directory.
|
---|
636 | *
|
---|
637 | * The returned path isn't guaranteed to exist.
|
---|
638 | *
|
---|
639 | * @returns iprt status code.
|
---|
640 | * @param pszPath Buffer where to store the path.
|
---|
641 | * @param cchPath Buffer size in bytes.
|
---|
642 | */
|
---|
643 | RTDECL(int) RTPathUserDocuments(char *pszPath, size_t cchPath);
|
---|
644 |
|
---|
645 | /**
|
---|
646 | * Gets the directory of shared libraries.
|
---|
647 | *
|
---|
648 | * This is not the same as RTPathAppPrivateArch() as Linux depends all shared
|
---|
649 | * libraries in a common global directory where ld.so can find them.
|
---|
650 | *
|
---|
651 | * Linux: /usr/lib
|
---|
652 | * Solaris: /opt/@<application@>/@<arch>@ or something
|
---|
653 | * Windows: @<program files directory@>/@<application@>
|
---|
654 | * Old path: same as RTPathExecDir()
|
---|
655 | *
|
---|
656 | * @returns iprt status code.
|
---|
657 | * @param pszPath Buffer where to store the path.
|
---|
658 | * @param cchPath Buffer size in bytes.
|
---|
659 | */
|
---|
660 | RTDECL(int) RTPathSharedLibs(char *pszPath, size_t cchPath);
|
---|
661 |
|
---|
662 | /**
|
---|
663 | * Gets the directory for architecture-independent application data, for
|
---|
664 | * example NLS files, module sources, ...
|
---|
665 | *
|
---|
666 | * Linux: /usr/shared/@<application@>
|
---|
667 | * Solaris: /opt/@<application@>
|
---|
668 | * Windows: @<program files directory@>/@<application@>
|
---|
669 | * Old path: same as RTPathExecDir()
|
---|
670 | *
|
---|
671 | * @returns iprt status code.
|
---|
672 | * @param pszPath Buffer where to store the path.
|
---|
673 | * @param cchPath Buffer size in bytes.
|
---|
674 | */
|
---|
675 | RTDECL(int) RTPathAppPrivateNoArch(char *pszPath, size_t cchPath);
|
---|
676 |
|
---|
677 | /**
|
---|
678 | * Gets the directory for architecture-dependent application data, for
|
---|
679 | * example modules which can be loaded at runtime.
|
---|
680 | *
|
---|
681 | * Linux: /usr/lib/@<application@>
|
---|
682 | * Solaris: /opt/@<application@>/@<arch>@ or something
|
---|
683 | * Windows: @<program files directory@>/@<application@>
|
---|
684 | * Old path: same as RTPathExecDir()
|
---|
685 | *
|
---|
686 | * @returns iprt status code.
|
---|
687 | * @param pszPath Buffer where to store the path.
|
---|
688 | * @param cchPath Buffer size in bytes.
|
---|
689 | */
|
---|
690 | RTDECL(int) RTPathAppPrivateArch(char *pszPath, size_t cchPath);
|
---|
691 |
|
---|
692 | /**
|
---|
693 | * Gets the toplevel directory for architecture-dependent application data.
|
---|
694 | *
|
---|
695 | * This differs from RTPathAppPrivateArch on Solaris only where it will work
|
---|
696 | * around the /opt/@<application@>/amd64 and /opt/@<application@>/i386 multi
|
---|
697 | * architecture installation style.
|
---|
698 | *
|
---|
699 | * Linux: /usr/lib/@<application@>
|
---|
700 | * Solaris: /opt/@<application@>
|
---|
701 | * Windows: @<program files directory@>/@<application@>
|
---|
702 | * Old path: same as RTPathExecDir()
|
---|
703 | *
|
---|
704 | * @returns iprt status code.
|
---|
705 | * @param pszPath Buffer where to store the path.
|
---|
706 | * @param cchPath Buffer size in bytes.
|
---|
707 | */
|
---|
708 | RTDECL(int) RTPathAppPrivateArchTop(char *pszPath, size_t cchPath);
|
---|
709 |
|
---|
710 | /**
|
---|
711 | * Gets the directory for documentation.
|
---|
712 | *
|
---|
713 | * Linux: /usr/share/doc/@<application@>
|
---|
714 | * Solaris: /opt/@<application@>
|
---|
715 | * Windows: @<program files directory@>/@<application@>
|
---|
716 | * Old path: same as RTPathExecDir()
|
---|
717 | *
|
---|
718 | * @returns iprt status code.
|
---|
719 | * @param pszPath Buffer where to store the path.
|
---|
720 | * @param cchPath Buffer size in bytes.
|
---|
721 | */
|
---|
722 | RTDECL(int) RTPathAppDocs(char *pszPath, size_t cchPath);
|
---|
723 |
|
---|
724 | /**
|
---|
725 | * Gets the temporary directory path.
|
---|
726 | *
|
---|
727 | * @returns iprt status code.
|
---|
728 | * @param pszPath Buffer where to store the path.
|
---|
729 | * @param cchPath Buffer size in bytes.
|
---|
730 | */
|
---|
731 | RTDECL(int) RTPathTemp(char *pszPath, size_t cchPath);
|
---|
732 |
|
---|
733 | /**
|
---|
734 | * Query information about a file system object.
|
---|
735 | *
|
---|
736 | * This API will resolve NOT symbolic links in the last component (just like
|
---|
737 | * unix lstat()).
|
---|
738 | *
|
---|
739 | * @returns IPRT status code.
|
---|
740 | * @retval VINF_SUCCESS if the object exists, information returned.
|
---|
741 | * @retval VERR_PATH_NOT_FOUND if any but the last component in the specified
|
---|
742 | * path was not found or was not a directory.
|
---|
743 | * @retval VERR_FILE_NOT_FOUND if the object does not exist (but path to the
|
---|
744 | * parent directory exists).
|
---|
745 | *
|
---|
746 | * @param pszPath Path to the file system object.
|
---|
747 | * @param pObjInfo Object information structure to be filled on successful
|
---|
748 | * return.
|
---|
749 | * @param enmAdditionalAttribs
|
---|
750 | * Which set of additional attributes to request.
|
---|
751 | * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
|
---|
752 | */
|
---|
753 | RTR3DECL(int) RTPathQueryInfo(const char *pszPath, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs);
|
---|
754 |
|
---|
755 | /**
|
---|
756 | * Query information about a file system object.
|
---|
757 | *
|
---|
758 | * @returns IPRT status code.
|
---|
759 | * @retval VINF_SUCCESS if the object exists, information returned.
|
---|
760 | * @retval VERR_PATH_NOT_FOUND if any but the last component in the specified
|
---|
761 | * path was not found or was not a directory.
|
---|
762 | * @retval VERR_FILE_NOT_FOUND if the object does not exist (but path to the
|
---|
763 | * parent directory exists).
|
---|
764 | *
|
---|
765 | * @param pszPath Path to the file system object.
|
---|
766 | * @param pObjInfo Object information structure to be filled on successful return.
|
---|
767 | * @param enmAdditionalAttribs
|
---|
768 | * Which set of additional attributes to request.
|
---|
769 | * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
|
---|
770 | * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
|
---|
771 | */
|
---|
772 | RTR3DECL(int) RTPathQueryInfoEx(const char *pszPath, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags);
|
---|
773 |
|
---|
774 | /**
|
---|
775 | * Changes the mode flags of a file system object.
|
---|
776 | *
|
---|
777 | * The API requires at least one of the mode flag sets (Unix/Dos) to
|
---|
778 | * be set. The type is ignored.
|
---|
779 | *
|
---|
780 | * This API will resolve symbolic links in the last component since
|
---|
781 | * mode isn't important for symbolic links.
|
---|
782 | *
|
---|
783 | * @returns iprt status code.
|
---|
784 | * @param pszPath Path to the file system object.
|
---|
785 | * @param fMode The new file mode, see @ref grp_rt_fs for details.
|
---|
786 | */
|
---|
787 | RTR3DECL(int) RTPathSetMode(const char *pszPath, RTFMODE fMode);
|
---|
788 |
|
---|
789 | /**
|
---|
790 | * Gets the mode flags of a file system object.
|
---|
791 | *
|
---|
792 | * @returns iprt status code.
|
---|
793 | * @param pszPath Path to the file system object.
|
---|
794 | * @param pfMode Where to store the file mode, see @ref grp_rt_fs for details.
|
---|
795 | *
|
---|
796 | * @remark This is wrapper around RTPathQueryInfoEx(RTPATH_F_FOLLOW_LINK) and
|
---|
797 | * exists to complement RTPathSetMode().
|
---|
798 | */
|
---|
799 | RTR3DECL(int) RTPathGetMode(const char *pszPath, PRTFMODE pfMode);
|
---|
800 |
|
---|
801 | /**
|
---|
802 | * Changes one or more of the timestamps associated of file system object.
|
---|
803 | *
|
---|
804 | * This API will not resolve symbolic links in the last component (just
|
---|
805 | * like unix lutimes()).
|
---|
806 | *
|
---|
807 | * @returns iprt status code.
|
---|
808 | * @param pszPath Path to the file system object.
|
---|
809 | * @param pAccessTime Pointer to the new access time.
|
---|
810 | * @param pModificationTime Pointer to the new modification time.
|
---|
811 | * @param pChangeTime Pointer to the new change time. NULL if not to be changed.
|
---|
812 | * @param pBirthTime Pointer to the new time of birth. NULL if not to be changed.
|
---|
813 | *
|
---|
814 | * @remark The file system might not implement all these time attributes,
|
---|
815 | * the API will ignore the ones which aren't supported.
|
---|
816 | *
|
---|
817 | * @remark The file system might not implement the time resolution
|
---|
818 | * employed by this interface, the time will be chopped to fit.
|
---|
819 | *
|
---|
820 | * @remark The file system may update the change time even if it's
|
---|
821 | * not specified.
|
---|
822 | *
|
---|
823 | * @remark POSIX can only set Access & Modification and will always set both.
|
---|
824 | */
|
---|
825 | RTR3DECL(int) RTPathSetTimes(const char *pszPath, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
|
---|
826 | PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime);
|
---|
827 |
|
---|
828 | /**
|
---|
829 | * Changes one or more of the timestamps associated of file system object.
|
---|
830 | *
|
---|
831 | * @returns iprt status code.
|
---|
832 | * @param pszPath Path to the file system object.
|
---|
833 | * @param pAccessTime Pointer to the new access time.
|
---|
834 | * @param pModificationTime Pointer to the new modification time.
|
---|
835 | * @param pChangeTime Pointer to the new change time. NULL if not to be changed.
|
---|
836 | * @param pBirthTime Pointer to the new time of birth. NULL if not to be changed.
|
---|
837 | * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
|
---|
838 | *
|
---|
839 | * @remark The file system might not implement all these time attributes,
|
---|
840 | * the API will ignore the ones which aren't supported.
|
---|
841 | *
|
---|
842 | * @remark The file system might not implement the time resolution
|
---|
843 | * employed by this interface, the time will be chopped to fit.
|
---|
844 | *
|
---|
845 | * @remark The file system may update the change time even if it's
|
---|
846 | * not specified.
|
---|
847 | *
|
---|
848 | * @remark POSIX can only set Access & Modification and will always set both.
|
---|
849 | */
|
---|
850 | RTR3DECL(int) RTPathSetTimesEx(const char *pszPath, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
|
---|
851 | PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime, uint32_t fFlags);
|
---|
852 |
|
---|
853 | /**
|
---|
854 | * Gets one or more of the timestamps associated of file system object.
|
---|
855 | *
|
---|
856 | * @returns iprt status code.
|
---|
857 | * @param pszPath Path to the file system object.
|
---|
858 | * @param pAccessTime Where to store the access time. NULL is ok.
|
---|
859 | * @param pModificationTime Where to store the modification time. NULL is ok.
|
---|
860 | * @param pChangeTime Where to store the change time. NULL is ok.
|
---|
861 | * @param pBirthTime Where to store the creation time. NULL is ok.
|
---|
862 | *
|
---|
863 | * @remark This is wrapper around RTPathQueryInfo() and exists to complement
|
---|
864 | * RTPathSetTimes(). If the last component is a symbolic link, it will
|
---|
865 | * not be resolved.
|
---|
866 | */
|
---|
867 | RTR3DECL(int) RTPathGetTimes(const char *pszPath, PRTTIMESPEC pAccessTime, PRTTIMESPEC pModificationTime,
|
---|
868 | PRTTIMESPEC pChangeTime, PRTTIMESPEC pBirthTime);
|
---|
869 |
|
---|
870 | /**
|
---|
871 | * Changes the owner and/or group of a file system object.
|
---|
872 | *
|
---|
873 | * This API will not resolve symbolic links in the last component (just
|
---|
874 | * like unix lchown()).
|
---|
875 | *
|
---|
876 | * @returns iprt status code.
|
---|
877 | * @param pszPath Path to the file system object.
|
---|
878 | * @param uid The new file owner user id. Pass NIL_RTUID to leave
|
---|
879 | * this unchanged.
|
---|
880 | * @param gid The new group id. Pass NIL_RTGUID to leave this
|
---|
881 | * unchanged.
|
---|
882 | */
|
---|
883 | RTR3DECL(int) RTPathSetOwner(const char *pszPath, uint32_t uid, uint32_t gid);
|
---|
884 |
|
---|
885 | /**
|
---|
886 | * Changes the owner and/or group of a file system object.
|
---|
887 | *
|
---|
888 | * @returns iprt status code.
|
---|
889 | * @param pszPath Path to the file system object.
|
---|
890 | * @param uid The new file owner user id. Pass NIL_RTUID to leave
|
---|
891 | * this unchanged.
|
---|
892 | * @param gid The new group id. Pass NIL_RTGID to leave this
|
---|
893 | * unchanged.
|
---|
894 | * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
|
---|
895 | */
|
---|
896 | RTR3DECL(int) RTPathSetOwnerEx(const char *pszPath, uint32_t uid, uint32_t gid, uint32_t fFlags);
|
---|
897 |
|
---|
898 | /**
|
---|
899 | * Gets the owner and/or group of a file system object.
|
---|
900 | *
|
---|
901 | * @returns iprt status code.
|
---|
902 | * @param pszPath Path to the file system object.
|
---|
903 | * @param pUid Where to store the owner user id. NULL is ok.
|
---|
904 | * @param pGid Where to store the group id. NULL is ok.
|
---|
905 | *
|
---|
906 | * @remark This is wrapper around RTPathQueryInfo() and exists to complement
|
---|
907 | * RTPathGetOwner(). If the last component is a symbolic link, it will
|
---|
908 | * not be resolved.
|
---|
909 | */
|
---|
910 | RTR3DECL(int) RTPathGetOwner(const char *pszPath, uint32_t *pUid, uint32_t *pGid);
|
---|
911 |
|
---|
912 |
|
---|
913 | /** @name RTPathRename, RTDirRename & RTFileRename flags.
|
---|
914 | * @{ */
|
---|
915 | /** Do not replace anything. */
|
---|
916 | #define RTPATHRENAME_FLAGS_NO_REPLACE UINT32_C(0)
|
---|
917 | /** This will replace attempt any target which isn't a directory. */
|
---|
918 | #define RTPATHRENAME_FLAGS_REPLACE RT_BIT(0)
|
---|
919 | /** Don't allow symbolic links as part of the path.
|
---|
920 | * @remarks this flag is currently not implemented and will be ignored. */
|
---|
921 | #define RTPATHRENAME_FLAGS_NO_SYMLINKS RT_BIT(1)
|
---|
922 | /** @} */
|
---|
923 |
|
---|
924 | /**
|
---|
925 | * Renames a path within a filesystem.
|
---|
926 | *
|
---|
927 | * This will rename symbolic links. If RTPATHRENAME_FLAGS_REPLACE is used and
|
---|
928 | * pszDst is a symbolic link, it will be replaced and not its target.
|
---|
929 | *
|
---|
930 | * @returns IPRT status code.
|
---|
931 | * @param pszSrc The source path.
|
---|
932 | * @param pszDst The destination path.
|
---|
933 | * @param fRename Rename flags, RTPATHRENAME_FLAGS_*.
|
---|
934 | */
|
---|
935 | RTR3DECL(int) RTPathRename(const char *pszSrc, const char *pszDst, unsigned fRename);
|
---|
936 |
|
---|
937 | /** @name RTPathUnlink flags.
|
---|
938 | * @{ */
|
---|
939 | /** Don't allow symbolic links as part of the path.
|
---|
940 | * @remarks this flag is currently not implemented and will be ignored. */
|
---|
941 | #define RTPATHUNLINK_FLAGS_NO_SYMLINKS RT_BIT(0)
|
---|
942 | /** @} */
|
---|
943 |
|
---|
944 | /**
|
---|
945 | * Removes the last component of the path.
|
---|
946 | *
|
---|
947 | * @returns IPRT status code.
|
---|
948 | * @param pszPath The path.
|
---|
949 | * @param fUnlink Unlink flags, RTPATHUNLINK_FLAGS_*.
|
---|
950 | */
|
---|
951 | RTR3DECL(int) RTPathUnlink(const char *pszPath, uint32_t fUnlink);
|
---|
952 |
|
---|
953 | /**
|
---|
954 | * A /bin/rm tool.
|
---|
955 | *
|
---|
956 | * @returns Program exit code.
|
---|
957 | *
|
---|
958 | * @param cArgs The number of arguments.
|
---|
959 | * @param papszArgs The argument vector. (Note that this may be
|
---|
960 | * reordered, so the memory must be writable.)
|
---|
961 | */
|
---|
962 | RTDECL(RTEXITCODE) RTPathRmCmd(unsigned cArgs, char **papszArgs);
|
---|
963 |
|
---|
964 | #endif /* IN_RING3 */
|
---|
965 |
|
---|
966 | /** @} */
|
---|
967 |
|
---|
968 | RT_C_DECLS_END
|
---|
969 |
|
---|
970 | #endif
|
---|
971 |
|
---|