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