dir.h revision d24f992f436d923102a7cc78a7748c4ae2c63da2
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * IPRT - Directory Manipulation.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Copyright (C) 2006-2012 Oracle Corporation
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * available from http://www.virtualbox.org. This file is free software;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * you can redistribute it and/or modify it under the terms of the GNU
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * General Public License (GPL) as published by the Free Software
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * The contents of this file may alternatively be used under the terms
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * of the Common Development and Distribution License Version 1.0
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * VirtualBox OSE distribution, in which case the provisions of the
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * CDDL are applicable instead of those of the GPL.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * You may elect to license modified versions of this file under the
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * terms and conditions of either the GPL or the CDDL or both.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/** @defgroup grp_rt_dir RTDir - Directory Manipulation
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @ingroup grp_rt
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Check for the existence of a directory.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * All symbolic links will be attemped resolved. If that is undesirable, please
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * use RTPathQueryInfo instead.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @returns true if exist and is a directory.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @returns false if not exists or isn't a directory.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @param pszPath Path to the directory.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/** @name RTDirCreate flags.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/** Don't allow symbolic links as part of the path.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @remarks this flag is currently not implemented and will be ignored. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/** Set the not-content-indexed flag (default). Windows only atm. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync#define RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_DONT_SET RT_BIT(1)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/** Do not set the not-content-indexed flag. Windows only atm. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync#define RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_DONT_SET RT_BIT(1)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/** Ignore errors setting the not-content-indexed flag. Windows only atm. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync#define RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_NOT_CRITICAL RT_BIT(2)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Creates a directory.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @returns iprt status code.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @param pszPath Path to the directory to create.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @param fMode The mode of the new directory.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @param fCreate Create flags, RTDIRCREATE_FLAGS_*.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTDirCreate(const char *pszPath, RTFMODE fMode, uint32_t fCreate);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Creates a directory including all parent directories in the path
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * if they don't exist.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @returns iprt status code.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @param pszPath Path to the directory to create.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @param fMode The mode of the new directories.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTDirCreateFullPath(const char *pszPath, RTFMODE fMode);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Creates a new directory with a unique name using the given template.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * One or more trailing X'es in the template will be replaced by random alpha
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * numeric characters until a RTDirCreate succeeds or we run out of patience.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * For instance:
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * As an alternative to trailing X'es, it
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * is possible to put 3 or more X'es somewhere inside the directory name. In
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * the following string only the last bunch of X'es will be modified:
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @returns iprt status code.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @param pszTemplate The directory name template on input. The actual
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * directory name on success. Empty string on failure.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @param fMode The mode to create the directory with. Use 0700
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * unless you have reason not to.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTDirCreateTemp(char *pszTemplate, RTFMODE fMode);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Secure version of @a RTDirCreateTemp with a fixed mode of 0700.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * This function behaves in the same way as @a RTDirCreateTemp with two
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * additional points. Firstly the mode is fixed to 0700. Secondly it will
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * fail if it is not possible to perform the operation securely. Possible
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * reasons include that the directory could be removed by another unprivileged
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * user before it is used (e.g. if is created in a non-sticky /tmp directory)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * or that the path contains symbolic links which another unprivileged user
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * could manipulate; however the exact criteria will be specified on a
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * platform-by-platform basis as platform support is added.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @see RTPathIsSecure for the current list of criteria.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @returns iprt status code.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @returns VERR_NOT_SUPPORTED if the interface can not be supported on the
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * current platform at this time.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @returns VERR_INSECURE if the directory could not be created securely.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * @param pszTemplate The directory name template on input. The
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * actual directory name on success. Empty string
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * on failure.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTDirCreateTempSecure(char *pszTemplate);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Creates a new directory with a unique name by appending a number.
RTDECL(int) RTDirCreateUniqueNumbered(char *pszPath, size_t cbSize, RTFMODE fMode, signed int cchDigits, char chSep);
typedef enum RTDIRFILTER
RTDIRFILTER_INVALID = 0,
} RTDIRFILTER;
typedef enum RTDIRENTRYTYPE
typedef struct RTDIRENTRY
} RTDIRENTRY;
#pragma pack()
typedef struct RTDIRENTRYEX
} RTDIRENTRYEX;
#pragma pack()
RTDECL(int) RTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fOpen);
RTDECL(int) RTDirReadEx(PRTDIR pDir, PRTDIRENTRYEX pDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags);
RTDECL(int) RTDirQueryUnknownType(const char *pszComposedName, bool fFollowSymlinks, RTDIRENTRYTYPE *penmType);
RTDECL(int) RTDirQueryUnknownTypeEx(const char *pszComposedName, bool fFollowSymlinks, RTDIRENTRYTYPE *penmType, PRTFSOBJINFO pObjInfo);