1 | /** @file
|
---|
2 | * IPRT - Directory Manipulation.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2020 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_INCLUDED_dir_h
|
---|
27 | #define IPRT_INCLUDED_dir_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include <iprt/cdefs.h>
|
---|
33 | #include <iprt/types.h>
|
---|
34 | #include <iprt/fs.h>
|
---|
35 | #include <iprt/symlink.h>
|
---|
36 |
|
---|
37 |
|
---|
38 | RT_C_DECLS_BEGIN
|
---|
39 |
|
---|
40 | /** @defgroup grp_rt_dir RTDir - Directory Manipulation
|
---|
41 | * @ingroup grp_rt
|
---|
42 | * @{
|
---|
43 | */
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Check for the existence of a directory.
|
---|
47 | *
|
---|
48 | * All symbolic links will be attemped resolved. If that is undesirable, please
|
---|
49 | * use RTPathQueryInfo instead.
|
---|
50 | *
|
---|
51 | * @returns true if exist and is a directory.
|
---|
52 | * @returns false if not exists or isn't a directory.
|
---|
53 | * @param pszPath Path to the directory.
|
---|
54 | */
|
---|
55 | RTDECL(bool) RTDirExists(const char *pszPath);
|
---|
56 |
|
---|
57 | /** @name RTDirCreate flags.
|
---|
58 | * @{ */
|
---|
59 | /** Don't allow symbolic links as part of the path.
|
---|
60 | * @remarks this flag is currently not implemented and will be ignored. */
|
---|
61 | #define RTDIRCREATE_FLAGS_NO_SYMLINKS RT_BIT(0)
|
---|
62 | /** Set the not-content-indexed flag (default). Windows only atm. */
|
---|
63 | #define RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_DONT_SET RT_BIT(1)
|
---|
64 | /** Do not set the not-content-indexed flag. Windows only atm. */
|
---|
65 | #define RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_SET UINT32_C(0)
|
---|
66 | /** Ignore errors setting the not-content-indexed flag. Windows only atm. */
|
---|
67 | #define RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_NOT_CRITICAL RT_BIT(2)
|
---|
68 | /** Ignore umask when applying the mode. */
|
---|
69 | #define RTDIRCREATE_FLAGS_IGNORE_UMASK RT_BIT(3)
|
---|
70 | /** Valid mask. */
|
---|
71 | #define RTDIRCREATE_FLAGS_VALID_MASK UINT32_C(0x0000000f)
|
---|
72 | /** @} */
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Creates a directory.
|
---|
76 | *
|
---|
77 | * @returns iprt status code.
|
---|
78 | * @param pszPath Path to the directory to create.
|
---|
79 | * @param fMode The mode of the new directory.
|
---|
80 | * @param fCreate Create flags, RTDIRCREATE_FLAGS_*.
|
---|
81 | */
|
---|
82 | RTDECL(int) RTDirCreate(const char *pszPath, RTFMODE fMode, uint32_t fCreate);
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Creates a directory including all non-existing parent directories.
|
---|
86 | *
|
---|
87 | * @returns iprt status code.
|
---|
88 | * @param pszPath Path to the directory to create.
|
---|
89 | * @param fMode The mode of the new directories.
|
---|
90 | */
|
---|
91 | RTDECL(int) RTDirCreateFullPath(const char *pszPath, RTFMODE fMode);
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Creates a directory including all non-existing parent directories.
|
---|
95 | *
|
---|
96 | * @returns iprt status code.
|
---|
97 | * @param pszPath Path to the directory to create.
|
---|
98 | * @param fMode The mode of the new directories.
|
---|
99 | * @param fFlags Create flags, RTDIRCREATE_FLAGS_*.
|
---|
100 | */
|
---|
101 | RTDECL(int) RTDirCreateFullPathEx(const char *pszPath, RTFMODE fMode, uint32_t fFlags);
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * Creates a new directory with a unique name using the given template.
|
---|
105 | *
|
---|
106 | * One or more trailing X'es in the template will be replaced by random alpha
|
---|
107 | * numeric characters until a RTDirCreate succeeds or we run out of patience.
|
---|
108 | * For instance:
|
---|
109 | * "/tmp/myprog-XXXXXX"
|
---|
110 | *
|
---|
111 | * As an alternative to trailing X'es, it
|
---|
112 | * is possible to put 3 or more X'es somewhere inside the directory name. In
|
---|
113 | * the following string only the last bunch of X'es will be modified:
|
---|
114 | * "/tmp/myprog-XXX-XXX.tmp"
|
---|
115 | *
|
---|
116 | * @returns iprt status code.
|
---|
117 | * @param pszTemplate The directory name template on input. The actual
|
---|
118 | * directory name on success. Empty string on failure.
|
---|
119 | * @param fMode The mode to create the directory with. Use 0700
|
---|
120 | * unless you have reason not to.
|
---|
121 | */
|
---|
122 | RTDECL(int) RTDirCreateTemp(char *pszTemplate, RTFMODE fMode);
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * Secure version of @a RTDirCreateTemp with a fixed mode of 0700.
|
---|
126 | *
|
---|
127 | * This function behaves in the same way as @a RTDirCreateTemp with two
|
---|
128 | * additional points. Firstly the mode is fixed to 0700. Secondly it will
|
---|
129 | * fail if it is not possible to perform the operation securely. Possible
|
---|
130 | * reasons include that the directory could be removed by another unprivileged
|
---|
131 | * user before it is used (e.g. if is created in a non-sticky /tmp directory)
|
---|
132 | * or that the path contains symbolic links which another unprivileged user
|
---|
133 | * could manipulate; however the exact criteria will be specified on a
|
---|
134 | * platform-by-platform basis as platform support is added.
|
---|
135 | * @see RTPathIsSecure for the current list of criteria.
|
---|
136 | * @returns iprt status code.
|
---|
137 | * @returns VERR_NOT_SUPPORTED if the interface can not be supported on the
|
---|
138 | * current platform at this time.
|
---|
139 | * @returns VERR_INSECURE if the directory could not be created securely.
|
---|
140 | * @param pszTemplate The directory name template on input. The
|
---|
141 | * actual directory name on success. Empty string
|
---|
142 | * on failure.
|
---|
143 | */
|
---|
144 | RTDECL(int) RTDirCreateTempSecure(char *pszTemplate);
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Creates a new directory with a unique name by appending a number.
|
---|
148 | *
|
---|
149 | * This API differs from RTDirCreateTemp & RTDirCreateTempSecure in that it
|
---|
150 | * first tries to create the directory without any random bits, thus the best
|
---|
151 | * case result will be prettier. It also differs in that it does not take a
|
---|
152 | * template, but is instead given a template description, and will only use
|
---|
153 | * digits for the filling.
|
---|
154 | *
|
---|
155 | * For sake of convenience and debugging , the current implementation
|
---|
156 | * starts at 0 and will increment sequentally for a while before switching to
|
---|
157 | * random numbers.
|
---|
158 | *
|
---|
159 | * On success @a pszPath contains the path created.
|
---|
160 | *
|
---|
161 | * @returns iprt status code.
|
---|
162 | * @param pszPath The path to the directory. On input the base template
|
---|
163 | * name. On successful return, the unique directory we
|
---|
164 | * created.
|
---|
165 | * @param cbSize The size of the pszPath buffer. Needs enough space for
|
---|
166 | * holding the digits and the optional separator.
|
---|
167 | * @param fMode The mode of the new directory.
|
---|
168 | * @param cchDigits How many digits should the number have (zero padded).
|
---|
169 | * @param chSep The separator used between the path and the number. Can
|
---|
170 | * be zero. (optional)
|
---|
171 | */
|
---|
172 | RTDECL(int) RTDirCreateUniqueNumbered(char *pszPath, size_t cbSize, RTFMODE fMode, size_t cchDigits, char chSep);
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Removes a directory if empty.
|
---|
176 | *
|
---|
177 | * @returns iprt status code.
|
---|
178 | * @param pszPath Path to the directory to remove.
|
---|
179 | */
|
---|
180 | RTDECL(int) RTDirRemove(const char *pszPath);
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * Removes a directory tree recursively.
|
---|
184 | *
|
---|
185 | * @returns iprt status code.
|
---|
186 | * @param pszPath Path to the directory to remove recursively.
|
---|
187 | * @param fFlags Flags, see RTDIRRMREC_F_XXX.
|
---|
188 | *
|
---|
189 | * @remarks This will not work on a root directory.
|
---|
190 | */
|
---|
191 | RTDECL(int) RTDirRemoveRecursive(const char *pszPath, uint32_t fFlags);
|
---|
192 |
|
---|
193 | /** @name RTDirRemoveRecursive flags.
|
---|
194 | * @{ */
|
---|
195 | /** Delete the content of the directory and the directory itself. */
|
---|
196 | #define RTDIRRMREC_F_CONTENT_AND_DIR UINT32_C(0)
|
---|
197 | /** Only delete the content of the directory, omit the directory it self. */
|
---|
198 | #define RTDIRRMREC_F_CONTENT_ONLY RT_BIT_32(0)
|
---|
199 | /** Long path hack: Don't apply RTPathAbs to the path. */
|
---|
200 | #define RTDIRRMREC_F_NO_ABS_PATH RT_BIT_32(1)
|
---|
201 | /** Mask of valid flags. */
|
---|
202 | #define RTDIRRMREC_F_VALID_MASK UINT32_C(0x00000003)
|
---|
203 | /** @} */
|
---|
204 |
|
---|
205 | /**
|
---|
206 | * Flushes the specified directory.
|
---|
207 | *
|
---|
208 | * This API is not implemented on all systems. On some systems it may be
|
---|
209 | * unnecessary if you've already flushed the file. If you really care for your
|
---|
210 | * data and is entering dangerous territories, it doesn't hurt calling it after
|
---|
211 | * flushing and closing the file.
|
---|
212 | *
|
---|
213 | * @returns IPRT status code.
|
---|
214 | * @retval VERR_NOT_IMPLEMENTED must be expected.
|
---|
215 | * @retval VERR_NOT_SUPPORTED must be expected.
|
---|
216 | * @param pszPath Path to the directory.
|
---|
217 | */
|
---|
218 | RTDECL(int) RTDirFlush(const char *pszPath);
|
---|
219 |
|
---|
220 | /**
|
---|
221 | * Flushes the parent directory of the specified file.
|
---|
222 | *
|
---|
223 | * This is just a wrapper around RTDirFlush.
|
---|
224 | *
|
---|
225 | * @returns IPRT status code, see RTDirFlush for details.
|
---|
226 | * @param pszChild Path to the file which parent should be flushed.
|
---|
227 | */
|
---|
228 | RTDECL(int) RTDirFlushParent(const char *pszChild);
|
---|
229 |
|
---|
230 |
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * Filter option for RTDirOpenFiltered().
|
---|
234 | */
|
---|
235 | typedef enum RTDIRFILTER
|
---|
236 | {
|
---|
237 | /** The usual invalid 0 entry. */
|
---|
238 | RTDIRFILTER_INVALID = 0,
|
---|
239 | /** No filter should be applied (and none was specified). */
|
---|
240 | RTDIRFILTER_NONE,
|
---|
241 | /** The Windows NT filter.
|
---|
242 | * The following wildcard chars: *, ?, <, > and "
|
---|
243 | * The matching is done on the uppercased strings. */
|
---|
244 | RTDIRFILTER_WINNT,
|
---|
245 | /** The UNIX filter.
|
---|
246 | * The following wildcard chars: *, ?, [..]
|
---|
247 | * The matching is done on exact case. */
|
---|
248 | RTDIRFILTER_UNIX,
|
---|
249 | /** The UNIX filter, uppercased matching.
|
---|
250 | * Same as RTDIRFILTER_UNIX except that the strings are uppercased before comparing. */
|
---|
251 | RTDIRFILTER_UNIX_UPCASED,
|
---|
252 |
|
---|
253 | /** The usual full 32-bit value. */
|
---|
254 | RTDIRFILTER_32BIT_HACK = 0x7fffffff
|
---|
255 | } RTDIRFILTER;
|
---|
256 |
|
---|
257 |
|
---|
258 | /**
|
---|
259 | * Directory entry type.
|
---|
260 | *
|
---|
261 | * This is the RTFS_TYPE_MASK stuff shifted down 12 bits and
|
---|
262 | * identical to the BSD/LINUX ABI. See RTFS_TYPE_DIRENTRYTYPE_SHIFT.
|
---|
263 | */
|
---|
264 | typedef enum RTDIRENTRYTYPE
|
---|
265 | {
|
---|
266 | /** Unknown type (DT_UNKNOWN). */
|
---|
267 | RTDIRENTRYTYPE_UNKNOWN = 0,
|
---|
268 | /** Named pipe (fifo) (DT_FIFO). */
|
---|
269 | RTDIRENTRYTYPE_FIFO = 001,
|
---|
270 | /** Character device (DT_CHR). */
|
---|
271 | RTDIRENTRYTYPE_DEV_CHAR = 002,
|
---|
272 | /** Directory (DT_DIR). */
|
---|
273 | RTDIRENTRYTYPE_DIRECTORY = 004,
|
---|
274 | /** Block device (DT_BLK). */
|
---|
275 | RTDIRENTRYTYPE_DEV_BLOCK = 006,
|
---|
276 | /** Regular file (DT_REG). */
|
---|
277 | RTDIRENTRYTYPE_FILE = 010,
|
---|
278 | /** Symbolic link (DT_LNK). */
|
---|
279 | RTDIRENTRYTYPE_SYMLINK = 012,
|
---|
280 | /** Socket (DT_SOCK). */
|
---|
281 | RTDIRENTRYTYPE_SOCKET = 014,
|
---|
282 | /** Whiteout (DT_WHT). */
|
---|
283 | RTDIRENTRYTYPE_WHITEOUT = 016
|
---|
284 | } RTDIRENTRYTYPE;
|
---|
285 |
|
---|
286 |
|
---|
287 | /**
|
---|
288 | * Directory entry.
|
---|
289 | *
|
---|
290 | * This is inspired by the POSIX interfaces.
|
---|
291 | */
|
---|
292 | #pragma pack(1)
|
---|
293 | typedef struct RTDIRENTRY
|
---|
294 | {
|
---|
295 | /** The unique identifier (within the file system) of this file system object (d_ino).
|
---|
296 | *
|
---|
297 | * Together with INodeIdDevice, this field can be used as a OS wide unique id
|
---|
298 | * when both their values are not 0. This field is 0 if the information is not
|
---|
299 | * available. */
|
---|
300 | RTINODE INodeId;
|
---|
301 | /** The entry type. (d_type)
|
---|
302 | *
|
---|
303 | * @warning RTDIRENTRYTYPE_UNKNOWN is a common return value here since not all
|
---|
304 | * file systems (or Unixes) stores the type of a directory entry and
|
---|
305 | * instead expects the user to use stat() to get it. So, when you see
|
---|
306 | * this you should use RTDirQueryUnknownType or RTDirQueryUnknownTypeEx
|
---|
307 | * to get the type, or if if you're lazy, use RTDirReadEx.
|
---|
308 | */
|
---|
309 | RTDIRENTRYTYPE enmType;
|
---|
310 | /** The length of the filename, excluding the terminating nul character. */
|
---|
311 | uint16_t cbName;
|
---|
312 | /** The filename. (no path)
|
---|
313 | * Using the pcbDirEntry parameter of RTDirRead makes this field variable in size. */
|
---|
314 | char szName[260];
|
---|
315 | } RTDIRENTRY;
|
---|
316 | #pragma pack()
|
---|
317 | /** Pointer to a directory entry. */
|
---|
318 | typedef RTDIRENTRY *PRTDIRENTRY;
|
---|
319 | /** Pointer to a const directory entry. */
|
---|
320 | typedef RTDIRENTRY const *PCRTDIRENTRY;
|
---|
321 |
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * Directory entry with extended information.
|
---|
325 | *
|
---|
326 | * This is inspired by the PC interfaces.
|
---|
327 | */
|
---|
328 | #pragma pack(1)
|
---|
329 | typedef struct RTDIRENTRYEX
|
---|
330 | {
|
---|
331 | /** Full information about the object. */
|
---|
332 | RTFSOBJINFO Info;
|
---|
333 | /** The length of the short field (number of RTUTF16 entries (not chars)).
|
---|
334 | * It is 16-bit for reasons of alignment. */
|
---|
335 | uint16_t cwcShortName;
|
---|
336 | /** The short name for 8.3 compatibility.
|
---|
337 | * Empty string if not available.
|
---|
338 | * Since the length is a bit tricky for a UTF-8 encoded name, and since this
|
---|
339 | * is practically speaking only a windows thing, it is encoded as UCS-2. */
|
---|
340 | RTUTF16 wszShortName[14];
|
---|
341 | /** The length of the filename. */
|
---|
342 | uint16_t cbName;
|
---|
343 | /** The filename. (no path)
|
---|
344 | * Using the pcbDirEntry parameter of RTDirReadEx makes this field variable in size. */
|
---|
345 | char szName[260];
|
---|
346 | } RTDIRENTRYEX;
|
---|
347 | #pragma pack()
|
---|
348 | /** Pointer to a directory entry. */
|
---|
349 | typedef RTDIRENTRYEX *PRTDIRENTRYEX;
|
---|
350 | /** Pointer to a const directory entry. */
|
---|
351 | typedef RTDIRENTRYEX const *PCRTDIRENTRYEX;
|
---|
352 |
|
---|
353 |
|
---|
354 | /**
|
---|
355 | * Opens a directory.
|
---|
356 | *
|
---|
357 | * @returns iprt status code.
|
---|
358 | * @param phDir Where to store the open directory handle.
|
---|
359 | * @param pszPath Path to the directory to open.
|
---|
360 | */
|
---|
361 | RTDECL(int) RTDirOpen(RTDIR *phDir, const char *pszPath);
|
---|
362 |
|
---|
363 | /** @name RTDIR_F_XXX - RTDirOpenFiltered flags.
|
---|
364 | * @{ */
|
---|
365 | /** Don't allow symbolic links as part of the path.
|
---|
366 | * @remarks this flag is currently not implemented and will be ignored. */
|
---|
367 | #define RTDIR_F_NO_SYMLINKS RT_BIT_32(0)
|
---|
368 | /** Deny relative opening of anything above this directory. */
|
---|
369 | #define RTDIR_F_DENY_ASCENT RT_BIT_32(1)
|
---|
370 | /** Don't follow symbolic links in the final component. */
|
---|
371 | #define RTDIR_F_NO_FOLLOW RT_BIT_32(2)
|
---|
372 | /** Long path hack: Don't apply RTPathAbs to the path. */
|
---|
373 | #define RTDIR_F_NO_ABS_PATH RT_BIT_32(3)
|
---|
374 | /** Valid flag mask. */
|
---|
375 | #define RTDIR_F_VALID_MASK UINT32_C(0x0000000f)
|
---|
376 | /** @} */
|
---|
377 |
|
---|
378 | /**
|
---|
379 | * Opens a directory with flags and optional filtering.
|
---|
380 | *
|
---|
381 | * @returns IPRT status code.
|
---|
382 | * @retval VERR_IS_A_SYMLINK if RTDIR_F_NO_FOLLOW is set, @a enmFilter is
|
---|
383 | * RTDIRFILTER_NONE and @a pszPath points to a symbolic link and does
|
---|
384 | * not end with a slash. Note that on Windows this does not apply to
|
---|
385 | * file symlinks, only directory symlinks, for the file variant
|
---|
386 | * VERR_NOT_A_DIRECTORY will be returned.
|
---|
387 | *
|
---|
388 | * @param phDir Where to store the open directory handle.
|
---|
389 | * @param pszPath Path to the directory to search, this must include wildcards.
|
---|
390 | * @param enmFilter The kind of filter to apply. Setting this to RTDIRFILTER_NONE makes
|
---|
391 | * this function behave like RTDirOpen.
|
---|
392 | * @param fFlags Open flags, RTDIR_F_XXX.
|
---|
393 | *
|
---|
394 | */
|
---|
395 | RTDECL(int) RTDirOpenFiltered(RTDIR *phDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fFlags);
|
---|
396 |
|
---|
397 | /**
|
---|
398 | * Closes a directory.
|
---|
399 | *
|
---|
400 | * @returns iprt status code.
|
---|
401 | * @param hDir Handle to open directory returned by RTDirOpen() or
|
---|
402 | * RTDirOpenFiltered().
|
---|
403 | */
|
---|
404 | RTDECL(int) RTDirClose(RTDIR hDir);
|
---|
405 |
|
---|
406 | /**
|
---|
407 | * Checks if the supplied directory handle is valid.
|
---|
408 | *
|
---|
409 | * @returns true if valid.
|
---|
410 | * @returns false if invalid.
|
---|
411 | * @param hDir The directory handle.
|
---|
412 | */
|
---|
413 | RTDECL(bool) RTDirIsValid(RTDIR hDir);
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * Reads the next entry in the directory.
|
---|
417 | *
|
---|
418 | * @returns VINF_SUCCESS and data in pDirEntry on success.
|
---|
419 | * @returns VERR_NO_MORE_FILES when the end of the directory has been reached.
|
---|
420 | * @returns VERR_BUFFER_OVERFLOW if the buffer is too small to contain the filename. If
|
---|
421 | * pcbDirEntry is specified it will be updated with the required buffer size.
|
---|
422 | * @returns suitable iprt status code on other errors.
|
---|
423 | *
|
---|
424 | * @param hDir Handle to the open directory.
|
---|
425 | * @param pDirEntry Where to store the information about the next
|
---|
426 | * directory entry on success.
|
---|
427 | * @param pcbDirEntry Optional parameter used for variable buffer size.
|
---|
428 | *
|
---|
429 | * On input the variable pointed to contains the size of the pDirEntry
|
---|
430 | * structure. This must be at least OFFSET(RTDIRENTRY, szName[2]) bytes.
|
---|
431 | *
|
---|
432 | * On successful output the field is updated to
|
---|
433 | * OFFSET(RTDIRENTRY, szName[pDirEntry->cbName + 1]).
|
---|
434 | *
|
---|
435 | * When the data doesn't fit in the buffer and VERR_BUFFER_OVERFLOW is
|
---|
436 | * returned, this field contains the required buffer size.
|
---|
437 | *
|
---|
438 | * The value is unchanged in all other cases.
|
---|
439 | */
|
---|
440 | RTDECL(int) RTDirRead(RTDIR hDir, PRTDIRENTRY pDirEntry, size_t *pcbDirEntry);
|
---|
441 |
|
---|
442 | /**
|
---|
443 | * Reads the next entry in the directory returning extended information.
|
---|
444 | *
|
---|
445 | * @returns VINF_SUCCESS and data in pDirEntry on success.
|
---|
446 | * @returns VERR_NO_MORE_FILES when the end of the directory has been reached.
|
---|
447 | * @returns VERR_BUFFER_OVERFLOW if the buffer is too small to contain the filename. If
|
---|
448 | * pcbDirEntry is specified it will be updated with the required buffer size.
|
---|
449 | * @returns suitable iprt status code on other errors.
|
---|
450 | *
|
---|
451 | * @param hDir Handle to the open directory.
|
---|
452 | * @param pDirEntry Where to store the information about the next
|
---|
453 | * directory entry on success.
|
---|
454 | * @param pcbDirEntry Optional parameter used for variable buffer size.
|
---|
455 | *
|
---|
456 | * On input the variable pointed to contains the size of the pDirEntry
|
---|
457 | * structure. This must be at least OFFSET(RTDIRENTRYEX, szName[2]) bytes.
|
---|
458 | *
|
---|
459 | * On successful output the field is updated to
|
---|
460 | * OFFSET(RTDIRENTRYEX, szName[pDirEntry->cbName + 1]).
|
---|
461 | *
|
---|
462 | * When the data doesn't fit in the buffer and VERR_BUFFER_OVERFLOW is
|
---|
463 | * returned, this field contains the required buffer size.
|
---|
464 | *
|
---|
465 | * The value is unchanged in all other cases.
|
---|
466 | * @param enmAdditionalAttribs
|
---|
467 | * Which set of additional attributes to request.
|
---|
468 | * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
|
---|
469 | * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
|
---|
470 | */
|
---|
471 | RTDECL(int) RTDirReadEx(RTDIR hDir, PRTDIRENTRYEX pDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags);
|
---|
472 |
|
---|
473 | /**
|
---|
474 | * Wrapper around RTDirReadEx that does the directory entry buffer handling.
|
---|
475 | *
|
---|
476 | * Call RTDirReadExAFree to free the buffers allocated by this function.
|
---|
477 | *
|
---|
478 | * @returns IPRT status code, see RTDirReadEx() for details.
|
---|
479 | *
|
---|
480 | * @param hDir Handle to the open directory.
|
---|
481 | * @param ppDirEntry Pointer to the directory entry pointer. Initialize this
|
---|
482 | * to NULL before the first call.
|
---|
483 | * @param pcbDirEntry Where the API caches the allocation size. Set this to
|
---|
484 | * zero before the first call.
|
---|
485 | * @param enmAddAttr See RTDirReadEx.
|
---|
486 | * @param fFlags See RTDirReadEx.
|
---|
487 | */
|
---|
488 | RTDECL(int) RTDirReadExA(RTDIR hDir, PRTDIRENTRYEX *ppDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAddAttr, uint32_t fFlags);
|
---|
489 |
|
---|
490 | /**
|
---|
491 | * Frees the buffer allocated by RTDirReadExA.
|
---|
492 | *
|
---|
493 | * @param ppDirEntry Pointer to the directory entry pointer.
|
---|
494 | * @param pcbDirEntry Where the API caches the allocation size.
|
---|
495 | */
|
---|
496 | RTDECL(void) RTDirReadExAFree(PRTDIRENTRYEX *ppDirEntry, size_t *pcbDirEntry);
|
---|
497 |
|
---|
498 | /**
|
---|
499 | * Resolves RTDIRENTRYTYPE_UNKNOWN values returned by RTDirRead.
|
---|
500 | *
|
---|
501 | * @returns IPRT status code (see RTPathQueryInfo).
|
---|
502 | * @param pszComposedName The path to the directory entry. The caller must
|
---|
503 | * compose this, it's NOT sufficient to pass
|
---|
504 | * RTDIRENTRY::szName!
|
---|
505 | * @param fFollowSymlinks Whether to follow symbolic links or not.
|
---|
506 | * @param penmType Pointer to the RTDIRENTRY::enmType member. If this
|
---|
507 | * is not RTDIRENTRYTYPE_UNKNOWN and, if
|
---|
508 | * @a fFollowSymlinks is false, not
|
---|
509 | * RTDIRENTRYTYPE_SYMLINK, the function will return
|
---|
510 | * immediately without doing anything. Otherwise it
|
---|
511 | * will use RTPathQueryInfo to try figure out the
|
---|
512 | * correct value. On failure, this will be unchanged.
|
---|
513 | */
|
---|
514 | RTDECL(int) RTDirQueryUnknownType(const char *pszComposedName, bool fFollowSymlinks, RTDIRENTRYTYPE *penmType);
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Resolves RTDIRENTRYTYPE_UNKNOWN values returned by RTDirRead, extended
|
---|
518 | * version.
|
---|
519 | *
|
---|
520 | * @returns IPRT status code (see RTPathQueryInfo).
|
---|
521 | * @param pszComposedName The path to the directory entry. The caller must
|
---|
522 | * compose this, it's NOT sufficient to pass
|
---|
523 | * RTDIRENTRY::szName!
|
---|
524 | * @param fFollowSymlinks Whether to follow symbolic links or not.
|
---|
525 | * @param penmType Pointer to the RTDIRENTRY::enmType member or
|
---|
526 | * similar. Will NOT be checked on input.
|
---|
527 | * @param pObjInfo The object info buffer to use with RTPathQueryInfo.
|
---|
528 | */
|
---|
529 | RTDECL(int) RTDirQueryUnknownTypeEx(const char *pszComposedName, bool fFollowSymlinks, RTDIRENTRYTYPE *penmType, PRTFSOBJINFO pObjInfo);
|
---|
530 |
|
---|
531 | /**
|
---|
532 | * Checks if the directory entry returned by RTDirRead is '.', '..' or similar.
|
---|
533 | *
|
---|
534 | * @returns true / false.
|
---|
535 | * @param pDirEntry The directory entry to check.
|
---|
536 | */
|
---|
537 | RTDECL(bool) RTDirEntryIsStdDotLink(PRTDIRENTRY pDirEntry);
|
---|
538 |
|
---|
539 | /**
|
---|
540 | * Checks if the directory entry returned by RTDirReadEx is '.', '..' or
|
---|
541 | * similar.
|
---|
542 | *
|
---|
543 | * @returns true / false.
|
---|
544 | * @param pDirEntryEx The extended directory entry to check.
|
---|
545 | */
|
---|
546 | RTDECL(bool) RTDirEntryExIsStdDotLink(PCRTDIRENTRYEX pDirEntryEx);
|
---|
547 |
|
---|
548 | /**
|
---|
549 | * Rewind and restart the directory reading.
|
---|
550 | *
|
---|
551 | * @returns IRPT status code.
|
---|
552 | * @param hDir The directory handle to rewind.
|
---|
553 | */
|
---|
554 | RTDECL(int) RTDirRewind(RTDIR hDir);
|
---|
555 |
|
---|
556 | /**
|
---|
557 | * Renames a file.
|
---|
558 | *
|
---|
559 | * Identical to RTPathRename except that it will ensure that the source is a directory.
|
---|
560 | *
|
---|
561 | * @returns IPRT status code.
|
---|
562 | * @returns VERR_ALREADY_EXISTS if the destination file exists.
|
---|
563 | *
|
---|
564 | * @param pszSrc The path to the source file.
|
---|
565 | * @param pszDst The path to the destination file.
|
---|
566 | * This file will be created.
|
---|
567 | * @param fRename See RTPathRename.
|
---|
568 | */
|
---|
569 | RTDECL(int) RTDirRename(const char *pszSrc, const char *pszDst, unsigned fRename);
|
---|
570 |
|
---|
571 |
|
---|
572 | /**
|
---|
573 | * Query information about an open directory.
|
---|
574 | *
|
---|
575 | * @returns iprt status code.
|
---|
576 | *
|
---|
577 | * @param hDir Handle to the open directory.
|
---|
578 | * @param pObjInfo Object information structure to be filled on successful return.
|
---|
579 | * @param enmAdditionalAttribs Which set of additional attributes to request.
|
---|
580 | * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
|
---|
581 | */
|
---|
582 | RTR3DECL(int) RTDirQueryInfo(RTDIR hDir, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs);
|
---|
583 |
|
---|
584 |
|
---|
585 | /**
|
---|
586 | * Changes one or more of the timestamps associated of file system object.
|
---|
587 | *
|
---|
588 | * @returns iprt status code.
|
---|
589 | * @returns VERR_NOT_SUPPORTED is returned if the operation isn't supported by the OS.
|
---|
590 | *
|
---|
591 | * @param hDir Handle to the open directory.
|
---|
592 | * @param pAccessTime Pointer to the new access time. NULL if not to be changed.
|
---|
593 | * @param pModificationTime Pointer to the new modifcation time. NULL if not to be changed.
|
---|
594 | * @param pChangeTime Pointer to the new change time. NULL if not to be changed.
|
---|
595 | * @param pBirthTime Pointer to the new time of birth. NULL if not to be changed.
|
---|
596 | *
|
---|
597 | * @remark The file system might not implement all these time attributes,
|
---|
598 | * the API will ignore the ones which aren't supported.
|
---|
599 | *
|
---|
600 | * @remark The file system might not implement the time resolution
|
---|
601 | * employed by this interface, the time will be chopped to fit.
|
---|
602 | *
|
---|
603 | * @remark The file system may update the change time even if it's
|
---|
604 | * not specified.
|
---|
605 | *
|
---|
606 | * @remark POSIX can only set Access & Modification and will always set both.
|
---|
607 | */
|
---|
608 | RTR3DECL(int) RTDirSetTimes(RTDIR hDir, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
|
---|
609 | PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime);
|
---|
610 |
|
---|
611 |
|
---|
612 | /**
|
---|
613 | * Changes the mode flags of an open directory.
|
---|
614 | *
|
---|
615 | * The API requires at least one of the mode flag sets (Unix/Dos) to
|
---|
616 | * be set. The type is ignored.
|
---|
617 | *
|
---|
618 | * @returns iprt status code.
|
---|
619 | * @param hDir Handle to the open directory.
|
---|
620 | * @param fMode The new file mode, see @ref grp_rt_fs for details.
|
---|
621 | */
|
---|
622 | RTDECL(int) RTDirSetMode(RTDIR hDir, RTFMODE fMode);
|
---|
623 |
|
---|
624 |
|
---|
625 | /** @defgroup grp_rt_dir_rel Directory relative APIs
|
---|
626 | *
|
---|
627 | * This group of APIs allows working with paths that are relative to an open
|
---|
628 | * directory, therebye eliminating some classic path related race conditions on
|
---|
629 | * systems with native support for these kinds of operations.
|
---|
630 | *
|
---|
631 | * On NT (Windows) there is native support for addressing files, directories and
|
---|
632 | * stuff _below_ the open directory. It is not possible to go upwards
|
---|
633 | * (hDir:../../grandparent), at least not with NTFS, forcing us to use the
|
---|
634 | * directory path as a fallback and opening us to potential races.
|
---|
635 | *
|
---|
636 | * On most unix-like systems here is now native support for all of this.
|
---|
637 | *
|
---|
638 | * @{ */
|
---|
639 |
|
---|
640 | /**
|
---|
641 | * Open a file relative to @a hDir.
|
---|
642 | *
|
---|
643 | * @returns IPRT status code.
|
---|
644 | * @param hDir The directory to open relative to.
|
---|
645 | * @param pszRelFilename The relative path to the file.
|
---|
646 | * @param fOpen Open flags, i.e a combination of the RTFILE_O_XXX
|
---|
647 | * defines. The ACCESS, ACTION and DENY flags are
|
---|
648 | * mandatory!
|
---|
649 | * @param phFile Where to store the handle to the opened file.
|
---|
650 | *
|
---|
651 | * @sa RTFileOpen
|
---|
652 | */
|
---|
653 | RTDECL(int) RTDirRelFileOpen(RTDIR hDir, const char *pszRelFilename, uint64_t fOpen, PRTFILE phFile);
|
---|
654 |
|
---|
655 |
|
---|
656 |
|
---|
657 | /**
|
---|
658 | * Opens a directory relative to @a hDir.
|
---|
659 | *
|
---|
660 | * @returns IPRT status code.
|
---|
661 | * @param hDir The directory to open relative to.
|
---|
662 | * @param pszDir The relative path to the directory to open.
|
---|
663 | * @param phDir Where to store the directory handle.
|
---|
664 | *
|
---|
665 | * @sa RTDirOpen
|
---|
666 | */
|
---|
667 | RTDECL(int) RTDirRelDirOpen(RTDIR hDir, const char *pszDir, RTDIR *phDir);
|
---|
668 |
|
---|
669 | /**
|
---|
670 | * Opens a directory relative to @a hDir, with flags and optional filtering.
|
---|
671 | *
|
---|
672 | * @returns IPRT status code.
|
---|
673 | * @retval VERR_IS_A_SYMLINK if RTDIR_F_NO_FOLLOW is set, @a enmFilter is
|
---|
674 | * RTDIRFILTER_NONE and @a pszPath points to a symbolic link and does
|
---|
675 | * not end with a slash. Note that on Windows this does not apply to
|
---|
676 | * file symlinks, only directory symlinks, for the file variant
|
---|
677 | * VERR_NOT_A_DIRECTORY will be returned.
|
---|
678 | *
|
---|
679 | * @param hDir The directory to open relative to.
|
---|
680 | * @param pszDirAndFilter The relative path to the directory to search, this
|
---|
681 | * must include wildcards.
|
---|
682 | * @param enmFilter The kind of filter to apply. Setting this to
|
---|
683 | * RTDIRFILTER_NONE makes this function behave like
|
---|
684 | * RTDirOpen.
|
---|
685 | * @param fFlags Open flags, RTDIR_F_XXX.
|
---|
686 | * @param phDir Where to store the directory handle.
|
---|
687 | *
|
---|
688 | * @sa RTDirOpenFiltered
|
---|
689 | */
|
---|
690 | RTDECL(int) RTDirRelDirOpenFiltered(RTDIR hDir, const char *pszDirAndFilter, RTDIRFILTER enmFilter,
|
---|
691 | uint32_t fFlags, RTDIR *phDir);
|
---|
692 |
|
---|
693 | /**
|
---|
694 | * Creates a directory relative to @a hDir.
|
---|
695 | *
|
---|
696 | * @returns IPRT status code.
|
---|
697 | * @param hDir The directory @a pszRelPath is relative to.
|
---|
698 | * @param pszRelPath The relative path to the directory to create.
|
---|
699 | * @param fMode The mode of the new directory.
|
---|
700 | * @param fCreate Create flags, RTDIRCREATE_FLAGS_XXX.
|
---|
701 | * @param phSubDir Where to return the handle of the created directory.
|
---|
702 | * Optional.
|
---|
703 | *
|
---|
704 | * @sa RTDirCreate
|
---|
705 | */
|
---|
706 | RTDECL(int) RTDirRelDirCreate(RTDIR hDir, const char *pszRelPath, RTFMODE fMode, uint32_t fCreate, RTDIR *phSubDir);
|
---|
707 |
|
---|
708 | /**
|
---|
709 | * Removes a directory relative to @a hDir if empty.
|
---|
710 | *
|
---|
711 | * @returns IPRT status code.
|
---|
712 | * @param hDir The directory @a pszRelPath is relative to.
|
---|
713 | * @param pszRelPath The relative path to the directory to remove.
|
---|
714 | *
|
---|
715 | * @sa RTDirRemove
|
---|
716 | */
|
---|
717 | RTDECL(int) RTDirRelDirRemove(RTDIR hDir, const char *pszRelPath);
|
---|
718 |
|
---|
719 |
|
---|
720 | /**
|
---|
721 | * Query information about a file system object relative to @a hDir.
|
---|
722 | *
|
---|
723 | * @returns IPRT status code.
|
---|
724 | * @retval VINF_SUCCESS if the object exists, information returned.
|
---|
725 | * @retval VERR_PATH_NOT_FOUND if any but the last component in the specified
|
---|
726 | * path was not found or was not a directory.
|
---|
727 | * @retval VERR_FILE_NOT_FOUND if the object does not exist (but path to the
|
---|
728 | * parent directory exists).
|
---|
729 | *
|
---|
730 | * @param hDir The directory @a pszRelPath is relative to.
|
---|
731 | * @param pszRelPath The relative path to the file system object.
|
---|
732 | * @param pObjInfo Object information structure to be filled on successful
|
---|
733 | * return.
|
---|
734 | * @param enmAddAttr Which set of additional attributes to request.
|
---|
735 | * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
|
---|
736 | * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
|
---|
737 | *
|
---|
738 | * @sa RTPathQueryInfoEx
|
---|
739 | */
|
---|
740 | RTDECL(int) RTDirRelPathQueryInfo(RTDIR hDir, const char *pszRelPath, PRTFSOBJINFO pObjInfo,
|
---|
741 | RTFSOBJATTRADD enmAddAttr, uint32_t fFlags);
|
---|
742 |
|
---|
743 | /**
|
---|
744 | * Changes the mode flags of a file system object relative to @a hDir.
|
---|
745 | *
|
---|
746 | * The API requires at least one of the mode flag sets (Unix/Dos) to
|
---|
747 | * be set. The type is ignored.
|
---|
748 | *
|
---|
749 | * @returns IPRT status code.
|
---|
750 | * @param hDir The directory @a pszRelPath is relative to.
|
---|
751 | * @param pszRelPath The relative path to the file system object.
|
---|
752 | * @param fMode The new file mode, see @ref grp_rt_fs for details.
|
---|
753 | * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
|
---|
754 | *
|
---|
755 | * @sa RTPathSetMode
|
---|
756 | */
|
---|
757 | RTDECL(int) RTDirRelPathSetMode(RTDIR hDir, const char *pszRelPath, RTFMODE fMode, uint32_t fFlags);
|
---|
758 |
|
---|
759 | /**
|
---|
760 | * Changes one or more of the timestamps associated of file system object
|
---|
761 | * relative to @a hDir.
|
---|
762 | *
|
---|
763 | * @returns IPRT status code.
|
---|
764 | * @param hDir The directory @a pszRelPath is relative to.
|
---|
765 | * @param pszRelPath The relative path to the file system object.
|
---|
766 | * @param pAccessTime Pointer to the new access time.
|
---|
767 | * @param pModificationTime Pointer to the new modification time.
|
---|
768 | * @param pChangeTime Pointer to the new change time. NULL if not to be changed.
|
---|
769 | * @param pBirthTime Pointer to the new time of birth. NULL if not to be changed.
|
---|
770 | * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
|
---|
771 | *
|
---|
772 | * @remark The file system might not implement all these time attributes,
|
---|
773 | * the API will ignore the ones which aren't supported.
|
---|
774 | *
|
---|
775 | * @remark The file system might not implement the time resolution
|
---|
776 | * employed by this interface, the time will be chopped to fit.
|
---|
777 | *
|
---|
778 | * @remark The file system may update the change time even if it's
|
---|
779 | * not specified.
|
---|
780 | *
|
---|
781 | * @remark POSIX can only set Access & Modification and will always set both.
|
---|
782 | *
|
---|
783 | * @sa RTPathSetTimesEx
|
---|
784 | */
|
---|
785 | RTDECL(int) RTDirRelPathSetTimes(RTDIR hDir, const char *pszRelPath, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
|
---|
786 | PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime, uint32_t fFlags);
|
---|
787 |
|
---|
788 | /**
|
---|
789 | * Changes the owner and/or group of a file system object relative to @a hDir.
|
---|
790 | *
|
---|
791 | * @returns IPRT status code.
|
---|
792 | * @param hDir The directory @a pszRelPath is relative to.
|
---|
793 | * @param pszRelPath The relative path to the file system object.
|
---|
794 | * @param uid The new file owner user id. Pass NIL_RTUID to leave
|
---|
795 | * this unchanged.
|
---|
796 | * @param gid The new group id. Pass NIL_RTGID to leave this
|
---|
797 | * unchanged.
|
---|
798 | * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
|
---|
799 | *
|
---|
800 | * @sa RTPathSetOwnerEx
|
---|
801 | */
|
---|
802 | RTDECL(int) RTDirRelPathSetOwner(RTDIR hDir, const char *pszRelPath, uint32_t uid, uint32_t gid, uint32_t fFlags);
|
---|
803 |
|
---|
804 | /**
|
---|
805 | * Renames a directory relative path within a filesystem.
|
---|
806 | *
|
---|
807 | * This will rename symbolic links. If RTPATHRENAME_FLAGS_REPLACE is used and
|
---|
808 | * pszDst is a symbolic link, it will be replaced and not its target.
|
---|
809 | *
|
---|
810 | * @returns IPRT status code.
|
---|
811 | * @param hDirSrc The directory the source path is relative to.
|
---|
812 | * @param pszSrc The source path, relative to @a hDirSrc.
|
---|
813 | * @param hDirDst The directory the destination path is relative to.
|
---|
814 | * @param pszDst The destination path, relative to @a hDirDst.
|
---|
815 | * @param fRename Rename flags, RTPATHRENAME_FLAGS_XXX.
|
---|
816 | *
|
---|
817 | * @sa RTPathRename
|
---|
818 | */
|
---|
819 | RTDECL(int) RTDirRelPathRename(RTDIR hDirSrc, const char *pszSrc, RTDIR hDirDst, const char *pszDst, unsigned fRename);
|
---|
820 |
|
---|
821 | /**
|
---|
822 | * Removes the last component of the directory relative path.
|
---|
823 | *
|
---|
824 | * @returns IPRT status code.
|
---|
825 | * @param hDir The directory @a pszRelPath is relative to.
|
---|
826 | * @param pszRelPath The relative path to the file system object.
|
---|
827 | * @param fUnlink Unlink flags, RTPATHUNLINK_FLAGS_XXX.
|
---|
828 | *
|
---|
829 | * @sa RTPathUnlink
|
---|
830 | */
|
---|
831 | RTDECL(int) RTDirRelPathUnlink(RTDIR hDir, const char *pszRelPath, uint32_t fUnlink);
|
---|
832 |
|
---|
833 |
|
---|
834 |
|
---|
835 | /**
|
---|
836 | * Creates a symbolic link (@a pszSymlink) relative to @a hDir targeting @a
|
---|
837 | * pszTarget.
|
---|
838 | *
|
---|
839 | * @returns IPRT status code.
|
---|
840 | * @param hDir The directory @a pszSymlink is relative to.
|
---|
841 | * @param pszSymlink The relative path of the symbolic link.
|
---|
842 | * @param pszTarget The path to the symbolic link target. This is
|
---|
843 | * relative to @a pszSymlink or an absolute path.
|
---|
844 | * @param enmType The symbolic link type. For Windows compatability
|
---|
845 | * it is very important to set this correctly. When
|
---|
846 | * RTSYMLINKTYPE_UNKNOWN is used, the API will try
|
---|
847 | * make a guess and may attempt query information
|
---|
848 | * about @a pszTarget in the process.
|
---|
849 | * @param fCreate Create flags, RTSYMLINKCREATE_FLAGS_XXX.
|
---|
850 | *
|
---|
851 | * @sa RTSymlinkCreate
|
---|
852 | */
|
---|
853 | RTDECL(int) RTDirRelSymlinkCreate(RTDIR hDir, const char *pszSymlink, const char *pszTarget,
|
---|
854 | RTSYMLINKTYPE enmType, uint32_t fCreate);
|
---|
855 |
|
---|
856 | /**
|
---|
857 | * Read the symlink target relative to @a hDir.
|
---|
858 | *
|
---|
859 | * @returns IPRT status code.
|
---|
860 | * @retval VERR_NOT_SYMLINK if @a pszSymlink does not specify a symbolic link.
|
---|
861 | * @retval VERR_BUFFER_OVERFLOW if the link is larger than @a cbTarget. The
|
---|
862 | * buffer will contain what all we managed to read, fully terminated
|
---|
863 | * if @a cbTarget > 0.
|
---|
864 | *
|
---|
865 | * @param hDir The directory @a pszSymlink is relative to.
|
---|
866 | * @param pszSymlink The relative path to the symbolic link that should
|
---|
867 | * be read.
|
---|
868 | * @param pszTarget The target buffer.
|
---|
869 | * @param cbTarget The size of the target buffer.
|
---|
870 | * @param fRead Read flags, RTSYMLINKREAD_FLAGS_XXX.
|
---|
871 | *
|
---|
872 | * @sa RTSymlinkRead
|
---|
873 | */
|
---|
874 | RTDECL(int) RTDirRelSymlinkRead(RTDIR hDir, const char *pszSymlink, char *pszTarget, size_t cbTarget, uint32_t fRead);
|
---|
875 |
|
---|
876 | /** @} */
|
---|
877 |
|
---|
878 |
|
---|
879 | /** @} */
|
---|
880 |
|
---|
881 | RT_C_DECLS_END
|
---|
882 |
|
---|
883 | #endif /* !IPRT_INCLUDED_dir_h */
|
---|
884 |
|
---|