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