dir.h revision c4d14c17e737e0456e9db8d937a9a6475fffd0a3
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/** @file
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * IPRT - Directory Manipulation.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/*
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
010ad423d45c61ef874fa1602d46459a798b54d2vboxsync * available from http://www.virtualbox.org. This file is free software;
010ad423d45c61ef874fa1602d46459a798b54d2vboxsync * you can redistribute it and/or modify it under the terms of the GNU
010ad423d45c61ef874fa1602d46459a798b54d2vboxsync * General Public License (GPL) as published by the Free Software
010ad423d45c61ef874fa1602d46459a798b54d2vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
010ad423d45c61ef874fa1602d46459a798b54d2vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
010ad423d45c61ef874fa1602d46459a798b54d2vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
010ad423d45c61ef874fa1602d46459a798b54d2vboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * The contents of this file may alternatively be used under the terms
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * of the Common Development and Distribution License Version 1.0
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * VirtualBox OSE distribution, in which case the provisions of the
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * CDDL are applicable instead of those of the GPL.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * You may elect to license modified versions of this file under the
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * terms and conditions of either the GPL or the CDDL or both.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * additional information or have any questions.
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync#ifndef ___iprt_dir_h
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync#define ___iprt_dir_h
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync#include <iprt/cdefs.h>
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync#include <iprt/types.h>
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync#ifdef IN_RING3
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync# include <iprt/fs.h>
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync#endif
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsyncRT_C_DECLS_BEGIN
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync/** @defgroup grp_rt_dir RTDir - Directory Manipulation
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @ingroup grp_rt
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @{
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync#ifdef IN_RING3
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync/**
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * Check for the existence of a directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * All symbolic links will be attemped resolved. If that is undesirable, please
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * use RTPathQueryInfo instead.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns true if exist and is a directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns false if not exists or isn't a directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pszPath Path to the directory.
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync */
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsyncRTDECL(bool) RTDirExists(const char *pszPath);
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync/**
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * Creates a directory.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync *
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @returns iprt status code.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @param pszPath Path to the directory to create.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @param fMode The mode of the new directory.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsyncRTDECL(int) RTDirCreate(const char *pszPath, RTFMODE fMode);
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync/**
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * Creates a directory including all parent directories in the path
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * if they don't exist.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync *
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @returns iprt status code.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @param pszPath Path to the directory to create.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @param fMode The mode of the new directories.
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync */
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsyncRTDECL(int) RTDirCreateFullPath(const char *pszPath, RTFMODE fMode);
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Creates a new directory with a unique name using the given template.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * One or more trailing X'es in the template will be replaced by random alpha
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * numeric characters until a RTDirCreate succeeds or we run out of patience.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * For instance:
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * "/tmp/myprog-XXXXXX"
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * As an alternative to trailing X'es, it
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * is possible to put 3 or more X'es somewhere inside the directory name. In
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * the following string only the last bunch of X'es will be modified:
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * "/tmp/myprog-XXX-XXX.tmp"
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * The directory is created with mode 0700.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync *
c83b72ede860a1be6bdd520f7d13619b0791c1advboxsync * @returns iprt status code.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @param pszTemplate The directory name template on input. The actual
c83b72ede860a1be6bdd520f7d13619b0791c1advboxsync * directory name on success. Empty string on failure.
c83b72ede860a1be6bdd520f7d13619b0791c1advboxsync */
c83b72ede860a1be6bdd520f7d13619b0791c1advboxsyncRTDECL(int) RTDirCreateTemp(char *pszTemplate);
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Removes a directory if empty.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns iprt status code.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pszPath Path to the directory to remove.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsyncRTDECL(int) RTDirRemove(const char *pszPath);
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Removes a directory tree recursively.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * @returns iprt status code.
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * @param pszPath Path to the directory to remove recursively.
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync */
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsyncRTDECL(int) RTDirRemoveRecursive(const char *pszPath);
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync/** Pointer to an open directory (sort of handle). */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsynctypedef struct RTDIR *PRTDIR;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Filter option for RTDirOpenFiltered().
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsynctypedef enum RTDIRFILTER
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync{
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync /** The usual invalid 0 entry. */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync RTDIRFILTER_INVALID = 0,
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync /** No filter should be applied (and none was specified). */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync RTDIRFILTER_NONE,
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** The Windows NT filter.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * The following wildcard chars: *, ?, <, > and "
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * The matching is done on the uppercased strings. */
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync RTDIRFILTER_WINNT,
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync /** The UNIX filter.
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * The following wildcard chars: *, ?, [..]
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * The matching is done on exact case. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTDIRFILTER_UNIX,
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** The UNIX filter, uppercased matching.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Same as RTDIRFILTER_UNIX except that the strings are uppercased before comparing. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTDIRFILTER_UNIX_UPCASED,
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** The usual full 32-bit value. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTDIRFILTER_32BIT_HACK = 0x7fffffff
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync} RTDIRFILTER;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * Directory entry type.
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync *
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * This is the RTFS_TYPE_MASK stuff shifted down 12 bits and
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * identical to the BSD/LINUX ABI.
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync */
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsynctypedef enum RTDIRENTRYTYPE
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync{
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync /** Unknown type (DT_UNKNOWN). */
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync RTDIRENTRYTYPE_UNKNOWN = 0,
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync /** Named pipe (fifo) (DT_FIFO). */
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync RTDIRENTRYTYPE_FIFO = 001,
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync /** Character device (DT_CHR). */
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync RTDIRENTRYTYPE_DEV_CHAR = 002,
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync /** Directory (DT_DIR). */
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync RTDIRENTRYTYPE_DIRECTORY = 004,
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync /** Block device (DT_BLK). */
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync RTDIRENTRYTYPE_DEV_BLOCK = 006,
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** Regular file (DT_REG). */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTDIRENTRYTYPE_FILE = 010,
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** Symbolic link (DT_LNK). */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTDIRENTRYTYPE_SYMLINK = 012,
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** Socket (DT_SOCK). */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTDIRENTRYTYPE_SOCKET = 014,
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** Whiteout (DT_WHT). */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTDIRENTRYTYPE_WHITEOUT = 016
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync} RTDIRENTRYTYPE;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Directory entry.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * This is inspired by the POSIX interfaces.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync#pragma pack(1)
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsynctypedef struct RTDIRENTRY
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync{
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync /** The unique identifier (within the file system) of this file system object (d_ino).
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * Together with INodeIdDevice, this field can be used as a OS wide unique id
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * when both their values are not 0.
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * This field is 0 if the information is not available. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTINODE INodeId;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** The entry type. (d_type)
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * RTDIRENTRYTYPE_UNKNOWN is a legal return value here and
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * should be expected by the user. */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync RTDIRENTRYTYPE enmType;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** The length of the filename. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync uint16_t cbName;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** The filename. (no path)
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Using the pcbDirEntry parameter of RTDirRead makes this field variable in size. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync char szName[260];
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync} RTDIRENTRY;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync#pragma pack()
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/** Pointer to a directory entry. */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsynctypedef RTDIRENTRY *PRTDIRENTRY;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * Directory entry with extended information.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * This is inspired by the PC interfaces.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync#pragma pack(1)
d0eec04539061d14a7e51f492aea90fa5394615fvboxsynctypedef struct RTDIRENTRYEX
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync{
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** Full information about the object. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTFSOBJINFO Info;
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync /** The length of the short field (number of RTUTF16 entries (not chars)).
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * It is 16-bit for reasons of alignment. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync uint16_t cwcShortName;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** The short name for 8.3 compatability.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Empty string if not available.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Since the length is a bit tricky for a UTF-8 encoded name, and since this
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * is practically speaking only a windows thing, it is encoded as UCS-2. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync RTUTF16 wszShortName[14];
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync /** The length of the filename. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync uint16_t cbName;
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync /** The filename. (no path)
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync * Using the pcbDirEntry parameter of RTDirReadEx makes this field variable in size. */
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync char szName[260];
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync} RTDIRENTRYEX;
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync#pragma pack()
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync/** Pointer to a directory entry. */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsynctypedef RTDIRENTRYEX *PRTDIRENTRYEX;
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Opens a directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns iprt status code.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param ppDir Where to store the open directory pointer.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pszPath Path to the directory to open.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsyncRTDECL(int) RTDirOpen(PRTDIR *ppDir, const char *pszPath);
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Opens a directory filtering the entries using dos style wildcards.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns iprt status code.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param ppDir Where to store the open directory pointer.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pszPath Path to the directory to search, this must include wildcards.
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * @param enmFilter The kind of filter to apply. Setting this to RTDIRFILTER_NONE makes
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * this function behave like RTDirOpen.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsyncRTDECL(int) RTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter);
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync/**
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * Closes a directory.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync *
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @returns iprt status code.
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @param pDir Pointer to open directory returned by RTDirOpen() or RTDirOpenFiltered().
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsyncRTDECL(int) RTDirClose(PRTDIR pDir);
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Reads the next entry in the directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync * @returns VINF_SUCCESS and data in pDirEntry on success.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns VERR_NO_MORE_FILES when the end of the directory has been reached.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns VERR_BUFFER_OVERFLOW if the buffer is too small to contain the filename. If
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * pcbDirEntry is specified it will be updated with the required buffer size.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns suitable iprt status code on other errors.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pDir Pointer to the open directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pDirEntry Where to store the information about the next
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * directory entry on success.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pcbDirEntry Optional parameter used for variable buffer size.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * On input the variable pointed to contains the size of the pDirEntry
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * structure. This must be at least OFFSET(RTDIRENTRY, szName[2]) bytes.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * On successful output the field is updated to
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * OFFSET(RTDIRENTRY, szName[pDirEntry->cbName + 1]).
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * When the data doesn't fit in the buffer and VERR_BUFFER_OVERFLOW is
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync * returned, this field contains the required buffer size.
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync *
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync * The value is unchanged in all other cases.
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync */
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsyncRTDECL(int) RTDirRead(PRTDIR pDir, PRTDIRENTRY pDirEntry, size_t *pcbDirEntry);
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync/**
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync * Reads the next entry in the directory returning extended information.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns VINF_SUCCESS and data in pDirEntry on success.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns VERR_NO_MORE_FILES when the end of the directory has been reached.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns VERR_BUFFER_OVERFLOW if the buffer is too small to contain the filename. If
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * pcbDirEntry is specified it will be updated with the required buffer size.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns suitable iprt status code on other errors.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pDir Pointer to the open directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pDirEntry Where to store the information about the next
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * directory entry on success.
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * @param pcbDirEntry Optional parameter used for variable buffer size.
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync *
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * On input the variable pointed to contains the size of the pDirEntry
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * structure. This must be at least OFFSET(RTDIRENTRYEX, szName[2]) bytes.
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync *
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * On successful output the field is updated to
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * OFFSET(RTDIRENTRYEX, szName[pDirEntry->cbName + 1]).
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync *
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * When the data doesn't fit in the buffer and VERR_BUFFER_OVERFLOW is
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * returned, this field contains the required buffer size.
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync *
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * The value is unchanged in all other cases.
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * @param enmAdditionalAttribs
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * Which set of additional attributes to request.
a05a2534a4aeaed368d626a462d856c0d352c97dvboxsync * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
a1e68eac9a1478fd1957826cb4bd631f808b7cc0vboxsync * @param fFlags RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsyncRTDECL(int) RTDirReadEx(PRTDIR pDir, PRTDIRENTRYEX pDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags);
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Renames a file.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Identical to RTPathRename except that it will ensure that the source is a directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns IPRT status code.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns VERR_ALREADY_EXISTS if the destination file exists.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pszSrc The path to the source file.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pszDst The path to the destination file.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * This file will be created.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param fRename See RTPathRename.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsyncRTDECL(int) RTDirRename(const char *pszSrc, const char *pszDst, unsigned fRename);
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Query information about an open directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns iprt status code.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pDir Pointer to the open directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pObjInfo Object information structure to be filled on successful return.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param enmAdditionalAttribs Which set of additional attributes to request.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync */
d0eec04539061d14a7e51f492aea90fa5394615fvboxsyncRTR3DECL(int) RTDirQueryInfo(PRTDIR pDir, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs);
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync/**
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * Changes one or more of the timestamps associated of file system object.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns iprt status code.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @returns VERR_NOT_SUPPORTED is returned if the operation isn't supported by the OS.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pDir Pointer to the open directory.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pAccessTime Pointer to the new access time. NULL if not to be changed.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pModificationTime Pointer to the new modifcation time. NULL if not to be changed.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pChangeTime Pointer to the new change time. NULL if not to be changed.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @param pBirthTime Pointer to the new time of birth. NULL if not to be changed.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @remark The file system might not implement all these time attributes,
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * the API will ignore the ones which aren't supported.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * @remark The file system might not implement the time resolution
1acf60ed9c490056043f7bfa524f2de1a431ab10vboxsync * employed by this interface, the time will be chopped to fit.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @remark The file system may update the change time even if it's
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * not specified.
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync *
d0eec04539061d14a7e51f492aea90fa5394615fvboxsync * @remark POSIX can only set Access & Modification and will always set both.
eac18a2a75654a71176720265be9d2e77658481fvboxsync */
eac18a2a75654a71176720265be9d2e77658481fvboxsyncRTR3DECL(int) RTDirSetTimes(PRTDIR pDir, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
eac18a2a75654a71176720265be9d2e77658481fvboxsync PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime);
eac18a2a75654a71176720265be9d2e77658481fvboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync#endif /* IN_RING3 */
eac18a2a75654a71176720265be9d2e77658481fvboxsync/** @} */
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsyncRT_C_DECLS_END
eac18a2a75654a71176720265be9d2e77658481fvboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync#endif
eac18a2a75654a71176720265be9d2e77658481fvboxsync
3c8ad0020c82e3ff4f3daad0d8cf2ef39085cbcavboxsync