VirtualBox

Changeset 69674 in vbox for trunk


Ignore:
Timestamp:
Nov 13, 2017 3:29:43 PM (7 years ago)
Author:
vboxsync
Message:

iprt: A bunch of basic function for working the file system relative to an open directory. There is only a default implementation currently, the path race conditions will first be eliminated/reduced with platform specific implementations (POSIX, NT). Also added a VFS wrapper around RTDIR handles, completing RTVfsChainOpenDir and making RTLs work on normal directories too (instead of only isofs and fat).

Location:
trunk
Files:
2 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/dir.h

    r69105 r69674  
    3030#include <iprt/types.h>
    3131#include <iprt/fs.h>
     32#include <iprt/symlink.h>
    3233
    3334
     
    343344RTDECL(int) RTDirOpen(PRTDIR *ppDir, const char *pszPath);
    344345
    345 /** @name RTDirOpenFiltered flags.
     346/** @name RTDIR_F_XXX - RTDirOpenFiltered flags.
    346347 * @{ */
    347348/** Don't allow symbolic links as part of the path.
    348349 * @remarks this flag is currently not implemented and will be ignored. */
    349 #define RTDIROPEN_FLAGS_NO_SYMLINKS  RT_BIT(0)
     350#define RTDIR_F_NO_SYMLINKS     RT_BIT_32(0)
     351/** Deny relative opening of anything above this directory. */
     352#define RTDIR_F_DENY_ASCENT     RT_BIT_32(1)
     353/** Valid flag mask.   */
     354#define RTDIR_F_VALID_MASK      UINT32_C(0x00000003)
    350355/** @} */
    351356
    352357/**
    353  * Opens a directory filtering the entries using dos style wildcards.
     358 * Opens a directory with flags and optional filtering.
    354359 *
    355360 * @returns iprt status code.
     
    358363 * @param   enmFilter   The kind of filter to apply. Setting this to RTDIRFILTER_NONE makes
    359364 *                      this function behave like RTDirOpen.
    360  * @param   fOpen       Open flags, RTDIROPENFILTERED_FLAGS_*.
    361  */
    362 RTDECL(int) RTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fOpen);
     365 * @param   fFlags      Open flags, RTDIR_F_XXX.
     366 */
     367RTDECL(int) RTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fFlags);
    363368
    364369/**
     
    369374 */
    370375RTDECL(int) RTDirClose(PRTDIR pDir);
     376
     377/**
     378 * Checks if the supplied directory handle is valid.
     379 *
     380 * @returns true if valid.
     381 * @returns false if invalid.
     382 * @param   hDir        The directory handle.
     383 */
     384RTDECL(bool) RTDirIsValid(PRTDIR hDir);
    371385
    372386/**
     
    533547                            PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime);
    534548
     549
     550/** @defgroup grp_rt_dir_rel    Directory relative APIs
     551 *
     552 * This group of APIs allows working with paths that are relative to an open
     553 * directory, therebye eliminating some classic path related race conditions on
     554 * systems with native support for these kinds of operations.
     555 *
     556 * @{ */
     557
     558/**
     559 * Open a file relative to @a hDir.
     560 *
     561 * @returns IPRT status code.
     562 * @param   hDir            The directory to open relative to.
     563 * @param   pszRelFilename  The relative path to the file.
     564 * @param   fOpen           Open flags, i.e a combination of the RTFILE_O_XXX
     565 *                          defines.  The ACCESS, ACTION and DENY flags are
     566 *                          mandatory!
     567 * @param   phFile          Where to store the handle to the opened file.
     568 *
     569 * @sa      RTFileOpen
     570 */
     571RTDECL(int)  RTDirRelFileOpen(PRTDIR hDir, const char *pszRelFilename, uint64_t fOpen, PRTFILE phFile);
     572
     573
     574
     575/**
     576 * Opens a directory relative to @a hDir.
     577 *
     578 * @returns IPRT status code.
     579 * @param   hDir            The directory to open relative to.
     580 * @param   pszDir          The relative path to the directory to open.
     581 * @param   phDir           Where to store the directory handle.
     582 *
     583 * @sa      RTDirOpen
     584 */
     585RTDECL(int) RTDirRelDirOpen(PRTDIR hDir, const char *pszDir, PRTDIR *phDir);
     586
     587/**
     588 * Opens a directory relative to @a hDir, with flags and optional filtering.
     589 *
     590 * @returns IPRT status code.
     591 * @param   hDir            The directory to open relative to.
     592 * @param   pszDirAndFilter The relative path to the directory to search, this
     593 *                          must include wildcards.
     594 * @param   enmFilter       The kind of filter to apply. Setting this to
     595 *                          RTDIRFILTER_NONE makes this function behave like
     596 *                          RTDirOpen.
     597 * @param   fFlags          Open flags, RTDIR_F_XXX.
     598 * @param   phDir           Where to store the directory handle.
     599 *
     600 * @sa      RTDirOpenFiltered
     601 */
     602RTDECL(int) RTDirRelDirOpenFiltered(PRTDIR hDir, const char *pszDirAndFilter, RTDIRFILTER enmFilter,
     603                                    uint32_t fFlags, PRTDIR *phDir);
     604
     605/**
     606 * Creates a directory relative to @a hDir.
     607 *
     608 * @returns IPRT status code.
     609 * @param   hDir            The directory @a pszRelPath is relative to.
     610 * @param   pszRelPath      The relative path to the directory to create.
     611 * @param   fMode           The mode of the new directory.
     612 * @param   fCreate         Create flags, RTDIRCREATE_FLAGS_XXX.
     613 *
     614 * @sa      RTDirCreate
     615 */
     616RTDECL(int) RTDirRelDirCreate(PRTDIR hDir, const char *pszRelPath, RTFMODE fMode, uint32_t fCreate);
     617
     618/**
     619 * Removes a directory relative to @a hDir if empty.
     620 *
     621 * @returns IPRT status code.
     622 * @param   hDir            The directory @a pszRelPath is relative to.
     623 * @param   pszRelPath      The relative path to the directory to remove.
     624 *
     625 * @sa      RTDirRemove
     626 */
     627RTDECL(int) RTDirRelDirRemove(PRTDIR hDir, const char *pszRelPath);
     628
     629
     630/**
     631 * Query information about a file system object relative to @a hDir.
     632 *
     633 * @returns IPRT status code.
     634 * @retval  VINF_SUCCESS if the object exists, information returned.
     635 * @retval  VERR_PATH_NOT_FOUND if any but the last component in the specified
     636 *          path was not found or was not a directory.
     637 * @retval  VERR_FILE_NOT_FOUND if the object does not exist (but path to the
     638 *          parent directory exists).
     639 *
     640 * @param   hDir            The directory @a pszRelPath is relative to.
     641 * @param   pszRelPath      The relative path to the file system object.
     642 * @param   pObjInfo        Object information structure to be filled on successful
     643 *                          return.
     644 * @param   enmAddAttr      Which set of additional attributes to request.
     645 *                          Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
     646 * @param   fFlags          RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
     647 *
     648 * @sa      RTPathQueryInfoEx
     649 */
     650RTDECL(int) RTDirRelPathQueryInfo(PRTDIR hDir, const char *pszRelPath, PRTFSOBJINFO pObjInfo,
     651                                  RTFSOBJATTRADD enmAddAttr, uint32_t fFlags);
     652
     653/**
     654 * Changes the mode flags of a file system object relative to @a hDir.
     655 *
     656 * The API requires at least one of the mode flag sets (Unix/Dos) to
     657 * be set. The type is ignored.
     658 *
     659 * @returns IPRT status code.
     660 * @param   hDir            The directory @a pszRelPath is relative to.
     661 * @param   pszRelPath      The relative path to the file system object.
     662 * @param   fMode           The new file mode, see @ref grp_rt_fs for details.
     663 * @param   fFlags          RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
     664 *
     665 * @sa      RTPathSetMode
     666 */
     667RTDECL(int) RTDirRelPathSetMode(PRTDIR hDir, const char *pszRelPath, RTFMODE fMode, uint32_t fFlags);
     668
     669/**
     670 * Changes one or more of the timestamps associated of file system object
     671 * relative to @a hDir.
     672 *
     673 * @returns IPRT status code.
     674 * @param   hDir                The directory @a pszRelPath is relative to.
     675 * @param   pszRelPath          The relative path to the file system object.
     676 * @param   pAccessTime         Pointer to the new access time.
     677 * @param   pModificationTime   Pointer to the new modification time.
     678 * @param   pChangeTime         Pointer to the new change time. NULL if not to be changed.
     679 * @param   pBirthTime          Pointer to the new time of birth. NULL if not to be changed.
     680 * @param   fFlags              RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
     681 *
     682 * @remark  The file system might not implement all these time attributes,
     683 *          the API will ignore the ones which aren't supported.
     684 *
     685 * @remark  The file system might not implement the time resolution
     686 *          employed by this interface, the time will be chopped to fit.
     687 *
     688 * @remark  The file system may update the change time even if it's
     689 *          not specified.
     690 *
     691 * @remark  POSIX can only set Access & Modification and will always set both.
     692 *
     693 * @sa      RTPathSetTimesEx
     694 */
     695RTDECL(int) RTDirRelPathSetTimes(PRTDIR hDir, const char *pszRelPath, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
     696                                 PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime, uint32_t fFlags);
     697
     698/**
     699 * Changes the owner and/or group of a file system object relative to @a hDir.
     700 *
     701 * @returns IPRT status code.
     702 * @param   hDir            The directory @a pszRelPath is relative to.
     703 * @param   pszRelPath      The relative path to the file system object.
     704 * @param   uid             The new file owner user id.  Pass NIL_RTUID to leave
     705 *                          this unchanged.
     706 * @param   gid             The new group id.  Pass NIL_RTGID to leave this
     707 *                          unchanged.
     708 * @param   fFlags          RTPATH_F_ON_LINK or RTPATH_F_FOLLOW_LINK.
     709 *
     710 * @sa      RTPathSetOwnerEx
     711 */
     712RTDECL(int) RTDirRelPathSetOwner(PRTDIR hDir, const char *pszRelPath, uint32_t uid, uint32_t gid, uint32_t fFlags);
     713
     714/**
     715 * Renames a directory relative path within a filesystem.
     716 *
     717 * This will rename symbolic links.  If RTPATHRENAME_FLAGS_REPLACE is used and
     718 * pszDst is a symbolic link, it will be replaced and not its target.
     719 *
     720 * @returns IPRT status code.
     721 * @param   hDirSrc         The directory the source path is relative to.
     722 * @param   pszSrc          The source path, relative to @a hDirSrc.
     723 * @param   hDirSrc         The directory the destination path is relative to.
     724 * @param   pszDst          The destination path, relative to @a hDirDst.
     725 * @param   fRename         Rename flags, RTPATHRENAME_FLAGS_XXX.
     726 *
     727 * @sa      RTPathRename
     728 */
     729RTDECL(int) RTDirRelPathRename(PRTDIR hDirSrc, const char *pszSrc, PRTDIR hDirDst, const char *pszDst, unsigned fRename);
     730
     731/**
     732 * Removes the last component of the directory relative path.
     733 *
     734 * @returns IPRT status code.
     735 * @param   hDir            The directory @a pszRelPath is relative to.
     736 * @param   pszRelPath      The relative path to the file system object.
     737 * @param   fUnlink         Unlink flags, RTPATHUNLINK_FLAGS_XXX.
     738 *
     739 * @sa      RTPathUnlink
     740 */
     741RTDECL(int) RTDirRelPathUnlink(PRTDIR hDir, const char *pszRelPath, uint32_t fUnlink);
     742
     743
     744
     745/**
     746 * Creates a symbolic link (@a pszSymlink) relative to @a hDir targeting @a
     747 * pszTarget.
     748 *
     749 * @returns IPRT status code.
     750 * @param   hDir            The directory @a pszSymlink is relative to.
     751 * @param   pszSymlink      The relative path of the symbolic link.
     752 * @param   pszTarget       The path to the symbolic link target.  This is
     753 *                          relative to @a pszSymlink or an absolute path.
     754 * @param   enmType         The symbolic link type.  For Windows compatability
     755 *                          it is very important to set this correctly.  When
     756 *                          RTSYMLINKTYPE_UNKNOWN is used, the API will try
     757 *                          make a guess and may attempt query information
     758 *                          about @a pszTarget in the process.
     759 * @param   fCreate         Create flags, RTSYMLINKCREATE_FLAGS_XXX.
     760 *
     761 * @sa      RTSymlinkCreate
     762 */
     763RTDECL(int) RTDirRelSymlinkCreate(PRTDIR hDir, const char *pszSymlink, const char *pszTarget,
     764                                  RTSYMLINKTYPE enmType, uint32_t fCreate);
     765
     766/**
     767 * Read the symlink target relative to @a hDir.
     768 *
     769 * @returns IPRT status code.
     770 * @retval  VERR_NOT_SYMLINK if @a pszSymlink does not specify a symbolic link.
     771 * @retval  VERR_BUFFER_OVERFLOW if the link is larger than @a cbTarget.  The
     772 *          buffer will contain what all we managed to read, fully terminated
     773 *          if @a cbTarget > 0.
     774 *
     775 * @param   hDir            The directory @a pszSymlink is relative to.
     776 * @param   pszSymlink      The relative path to the symbolic link that should
     777 *                          be read.
     778 * @param   pszTarget       The target buffer.
     779 * @param   cbTarget        The size of the target buffer.
     780 * @param   fRead           Read flags, RTSYMLINKREAD_FLAGS_XXX.
     781 *
     782 * @sa      RTSymlinkRead
     783 */
     784RTDECL(int) RTDirRelSymlinkRead(PRTDIR hDir, const char *pszSymlink, char *pszTarget, size_t cbTarget, uint32_t fRead);
     785
    535786/** @} */
    536787
     788
     789/** @} */
     790
    537791RT_C_DECLS_END
    538792
  • trunk/include/iprt/mangling.h

    r69616 r69674  
    759759# define RTDirFlush                                     RT_MANGLER(RTDirFlush)
    760760# define RTDirFlushParent                               RT_MANGLER(RTDirFlushParent)
     761# define RTDirIsValid                                   RT_MANGLER(RTDirIsValid)
    761762# define RTDirOpen                                      RT_MANGLER(RTDirOpen)
    762763# define RTDirOpenFiltered                              RT_MANGLER(RTDirOpenFiltered)
     
    770771# define RTDirRename                                    RT_MANGLER(RTDirRename)
    771772# define RTDirSetTimes                                  RT_MANGLER(RTDirSetTimes)
     773# define RTDirRelFileOpen                               RT_MANGLER(RTDirRelFileOpen)
     774# define RTDirRelDirOpen                                RT_MANGLER(RTDirRelDirOpen)
     775# define RTDirRelDirOpenFiltered                        RT_MANGLER(RTDirRelDirOpenFiltered)
     776# define RTDirRelDirCreate                              RT_MANGLER(RTDirRelDirCreate)
     777# define RTDirRelDirRemove                              RT_MANGLER(RTDirRelDirRemove)
     778# define RTDirRelPathQueryInfo                          RT_MANGLER(RTDirRelPathQueryInfo)
     779# define RTDirRelPathSetMode                            RT_MANGLER(RTDirRelPathSetMode)
     780# define RTDirRelPathSetTimes                           RT_MANGLER(RTDirRelPathSetTimes)
     781# define RTDirRelPathSetOwner                           RT_MANGLER(RTDirRelPathSetOwner)
     782# define RTDirRelPathRename                             RT_MANGLER(RTDirRelPathRename)
     783# define RTDirRelPathUnlink                             RT_MANGLER(RTDirRelPathUnlink)
     784# define RTDirRelSymlinkCreate                          RT_MANGLER(RTDirRelSymlinkCreate)
     785# define RTDirRelSymlinkRead                            RT_MANGLER(RTDirRelSymlinkRead)
     786# define RTVfsDirOpenDir                                RT_MANGLER(RTVfsDirOpenDir)
     787# define RTVfsDirFromRTDir                              RT_MANGLER(RTVfsDirFromRTDir)
     788# define RTVfsDirOpenNormal                             RT_MANGLER(RTVfsDirOpenNormal)
    772789# define RTDvmCreate                                    RT_MANGLER(RTDvmCreate)
    773790# define RTDvmCreateFromVfsFile                         RT_MANGLER(RTDvmCreateFromVfsFile)
  • trunk/include/iprt/vfs.h

    r69105 r69674  
    478478
    479479/**
     480 * Create a VFS directory handle from a standard IPRT directory handle (PRTDIR).
     481 *
     482 * @returns IPRT status code.
     483 * @param   hDir            The standard IPRT directory handle.
     484 * @param   fLeaveOpen      Whether to leave the handle open when the VFS
     485 *                          directory is released, or to close it (@c false).
     486 * @param   phVfsDi         Where to return the VFS directory handle.
     487 */
     488RTDECL(int) RTVfsDirFromRTDir(PRTDIR hDir, bool fLeaveOpen, PRTVFSDIR phVfsDir);
     489
     490/**
     491 * RTDirOpen + RTVfsDirFromRTDir.
     492 *
     493 * @returns IPRT status code.
     494 * @param   hDir            The standard IPRT directory handle.
     495 * @param   fFlags          RTDIR_F_XXX.
     496 * @param   fLeaveOpen      Whether to leave the handle open when the VFS
     497 *                          directory is released, or to close it (@c false).
     498 * @param   phVfsDi         Where to return the VFS directory handle.
     499 */
     500RTDECL(int) RTVfsDirOpenNormal(const char *pszFilename, uint32_t fFlags, PRTVFSDIR phVfsDir);
     501
     502/**
    480503 * Queries information about a object in or under the given directory.
    481504 *
  • trunk/include/iprt/vfslowlevel.h

    r69105 r69674  
    251251    DECLCALLBACKMEMBER(int, pfnTraverse)(void *pvThis, const char *pszPath, size_t *poffPath, PRTVFS??? phVfs?, ???* p???);
    252252#endif
     253
     254    /** @todo need rename API */
    253255
    254256    /** Marks the end of the structure (RTVFSOPS_VERSION). */
     
    562564     * @param   pvThis      The implementation specific directory data.
    563565     * @param   pszSubDir   The name of the immediate subdirectory to open.
     566     * @param   fFlags      RTDIR_F_XXX.
    564567     * @param   phVfsDir    Where to return the handle to the opened directory.
    565568     * @sa      RTDirOpen.
     
    645648     * @param   pszNewName  The new entry name.
    646649     * @sa      RTPathRename
     650     *
     651     * @todo    This API is not flexible enough, must be able to rename between
     652     *          directories within a file system.
    647653     */
    648654    DECLCALLBACKMEMBER(int, pfnRenameEntry)(void *pvThis, const char *pszEntry, RTFMODE fType, const char *pszNewName);
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceCpuHotPlug.cpp

    r69500 r69674  
    196196                if (pszPathTmp)
    197197                {
    198                     rc = RTDirOpenFiltered(&pDirCurr, pszPathTmp, RTDIRFILTER_WINNT, 0);
     198                    rc = RTDirOpenFiltered(&pDirCurr, pszPathTmp, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    199199                    RTStrFree(pszPathTmp);
    200200                }
     
    289289
    290290        /* Open the directory */
    291         rc = RTDirOpenFiltered(&pAcpiCpuPathLvl->pDir, pszPath, RTDIRFILTER_WINNT, 0);
     291        rc = RTDirOpenFiltered(&pAcpiCpuPathLvl->pDir, pszPath, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    292292        if (RT_SUCCESS(rc))
    293293        {
     
    378378
    379379                        /* Open the directory */
    380                         rc = RTDirOpenFiltered(&pAcpiCpuPathLvl->pDir, pszPathDir, RTDIRFILTER_WINNT, 0);
     380                        rc = RTDirOpenFiltered(&pAcpiCpuPathLvl->pDir, pszPathDir, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    381381                        if (RT_FAILURE(rc))
    382382                            break;
  • trunk/src/VBox/HostServices/SharedFolders/testcase/tstShflCase.cpp

    r69500 r69674  
    106106};
    107107
    108 int rtDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter)
    109 {
    110     RT_NOREF1(enmFilter);
     108int rtDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uitn32_t fFlags)
     109{
     110    RT_NOREF1(enmFilter, fFlags);
    111111    if (!strcmp(pszPath, "c:\\*"))
    112112        iDirList = 1;
     
    225225    strcat(pDirEntry->szName, szWildCard);
    226226
    227     rc = RTDirOpenFiltered (&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT);
     227    rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    228228    *(pszStartComponent-1) = RTPATH_DELIMITER;
    229229    if (RT_FAILURE(rc))
  • trunk/src/VBox/HostServices/SharedFolders/teststubs.h

    r69500 r69674  
    3434extern int testRTDirOpen(PRTDIR *ppDir, const char *pszPath);
    3535#define RTDirOpenFiltered    testRTDirOpenFiltered
    36 extern int testRTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fOpen);
     36extern int testRTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fFlags);
    3737#define RTDirQueryInfo       testRTDirQueryInfo
    3838extern int testRTDirQueryInfo(PRTDIR pDir, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs);
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp

    r69500 r69674  
    668668        {
    669669            /* Open the directory now */
    670             rc = RTDirOpenFiltered(&pHandle->dir.Handle, pszPath, RTDIRFILTER_NONE, 0);
     670            rc = RTDirOpenFiltered(&pHandle->dir.Handle, pszPath, RTDIRFILTER_NONE, 0 /*fFlags*/);
    671671            if (RT_SUCCESS(rc))
    672672            {
     
    12001200            if (RT_SUCCESS(rc))
    12011201            {
    1202                 rc = RTDirOpenFiltered(&pHandle->dir.SearchHandle, pszFullPath, RTDIRFILTER_WINNT, 0);
     1202                rc = RTDirOpenFiltered(&pHandle->dir.SearchHandle, pszFullPath, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    12031203
    12041204                /* free the path string */
  • trunk/src/VBox/HostServices/SharedFolders/vbsfpath.cpp

    r69500 r69674  
    9898    {
    9999        PRTDIR hSearch = NULL;
    100         rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT, 0);
     100        rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    101101        if (RT_SUCCESS(rc))
    102102        {
  • trunk/src/VBox/Runtime/Makefile.kmk

    r69111 r69674  
    624624        common/vfs/vfsprogress.cpp \
    625625        common/vfs/vfsreadahead.cpp \
     626        common/vfs/vfsstddir.cpp \
    626627        common/vfs/vfsstdfile.cpp \
    627628        common/vfs/vfsstdpipe.cpp \
     
    679680        r3/tcp.cpp \
    680681        r3/udp.cpp \
     682        r3/generic/dirrel-r3-generic.cpp \
    681683        r3/generic/semspinmutex-r3-generic.cpp \
    682684        r3/xml.cpp \
  • trunk/src/VBox/Runtime/common/vfs/vfschain.cpp

    r69630 r69674  
    11871187     * Path to regular file system.
    11881188     */
    1189     /** @todo implement system specific standard VFS directory class. */
    1190     rc = VERR_NOT_IMPLEMENTED;
     1189    rc = RTVfsDirOpenNormal(pszSpec, fOpen, phVfsDir);
    11911190
    11921191    RTVfsChainSpecFree(pSpec);
  • trunk/src/VBox/Runtime/include/internal/dir.h

    r69474 r69674  
    7373    /** The length of the path. */
    7474    size_t              cchPath;
    75     /** Set to indicate that the Data member contains unread data. */
    76     bool                fDataUnread;
    7775    /** Pointer to the converted filename.
    7876     * This can be NULL. */
     
    8684    /** The size of this structure. */
    8785    size_t              cbSelf;
     86    /** The RTDIR_F_XXX flags passed to RTDirOpenFiltered */
     87    uint32_t            fFlags;
     88    /** Set to indicate that the Data member contains unread data. */
     89    bool                fDataUnread;
    8890
    8991#ifndef RTDIR_AGNOSTIC
  • trunk/src/VBox/Runtime/r3/dir.cpp

    r69111 r69674  
    510510 * @param   pszFilter   Pointer to where the filter start in the path. NULL if no filter.
    511511 * @param   enmFilter   The type of filter to apply.
    512  */
    513 static int rtDirOpenCommon(PRTDIR *ppDir, const char *pszPath, const char *pszFilter, RTDIRFILTER enmFilter)
     512 * @param   fFlags      RTDIR_F_XXX.
     513 */
     514static int rtDirOpenCommon(PRTDIR *ppDir, const char *pszPath, const char *pszFilter, RTDIRFILTER enmFilter, uint32_t fFlags)
    514515{
    515516    /*
     
    614615    pDir->pszPath = (char *)memcpy(pb, szRealPath, cchRealPath + 1);
    615616    Assert(pb - (uint8_t *)pDir + cchRealPath + 1 <= cbAllocated);
    616     pDir->fDataUnread = false;
    617617    pDir->pszName = NULL;
    618618    pDir->cchName = 0;
     619    pDir->fFlags  = fFlags;
     620    pDir->fDataUnread = false;
    619621
    620622    /*
     
    643645     * Take common cause with RTDirOpenFiltered().
    644646     */
    645     int rc = rtDirOpenCommon(ppDir, pszPath, NULL,  RTDIRFILTER_NONE);
     647    int rc = rtDirOpenCommon(ppDir, pszPath, NULL, RTDIRFILTER_NONE, 0 /*fFlags*/);
    646648    LogFlow(("RTDirOpen(%p:{%p}, %p:{%s}): return %Rrc\n", ppDir, *ppDir, pszPath, pszPath, rc));
    647649    return rc;
     
    649651
    650652
    651 RTDECL(int) RTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fOpen)
     653RTDECL(int) RTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fFlags)
    652654{
    653655    /*
     
    656658    AssertMsgReturn(VALID_PTR(ppDir), ("%p\n", ppDir), VERR_INVALID_POINTER);
    657659    AssertMsgReturn(VALID_PTR(pszPath), ("%p\n", pszPath), VERR_INVALID_POINTER);
    658     AssertReturn(!(fOpen & ~RTDIROPEN_FLAGS_NO_SYMLINKS), VERR_INVALID_FLAGS);
     660    AssertReturn(!(fFlags & ~RTDIR_F_VALID_MASK), VERR_INVALID_FLAGS);
    659661    switch (enmFilter)
    660662    {
     
    687689     * and initialize the handle, and finally call the backend.
    688690     */
    689     int rc = rtDirOpenCommon(ppDir, pszPath, pszFilter, enmFilter);
    690 
    691     LogFlow(("RTDirOpenFiltered(%p:{%p}, %p:{%s}, %d): return %Rrc\n",
    692              ppDir, *ppDir, pszPath, pszPath, enmFilter, rc));
     691    int rc = rtDirOpenCommon(ppDir, pszPath, pszFilter, enmFilter, fFlags);
     692
     693    LogFlow(("RTDirOpenFiltered(%p:{%p}, %p:{%s}, %d, %#x): return %Rrc\n",
     694             ppDir, *ppDir, pszPath, pszPath, enmFilter, fFlags, rc));
    693695    return rc;
     696}
     697
     698
     699RTDECL(bool) RTDirIsValid(PRTDIR hDir)
     700{
     701    return RT_VALID_PTR(hDir)
     702        && hDir->u32Magic == RTDIR_MAGIC;
    694703}
    695704
  • trunk/src/VBox/Runtime/testcase/tstDir-2.cpp

    r69111 r69674  
    4242        /* open */
    4343        PRTDIR pDir;
    44         int rc = RTDirOpenFiltered(&pDir, argv[i], RTDIRFILTER_WINNT, 0);
     44        int rc = RTDirOpenFiltered(&pDir, argv[i], RTDIRFILTER_WINNT, 0 /*fFlags*/);
    4545        if (RT_SUCCESS(rc))
    4646        {
  • trunk/src/VBox/Runtime/testcase/tstDir-3.cpp

    r69434 r69674  
    3737    unsigned cFilesMatch = 0;
    3838    PRTDIR pDir;
    39     int rc = RTDirOpenFiltered(&pDir, pszFilter, RTDIRFILTER_WINNT, 0);
     39    int rc = RTDirOpenFiltered(&pDir, pszFilter, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    4040    if (RT_SUCCESS(rc))
    4141    {
  • trunk/src/VBox/Runtime/testcase/tstDir.cpp

    r69111 r69674  
    8686                rc = RTDirOpen(&pDir, argv[i]);
    8787            else
    88                 rc = RTDirOpenFiltered(&pDir, argv[i], RTDIRFILTER_WINNT, 0);
     88                rc = RTDirOpenFiltered(&pDir, argv[i], RTDIRFILTER_WINNT, 0 /*fFlags*/);
    8989            if (RT_SUCCESS(rc))
    9090            {
  • trunk/src/VBox/Storage/VDPlugin.cpp

    r69230 r69674  
    645645    PRTDIR pPluginDir = NULL;
    646646    size_t cbPluginDirEntry = sizeof(RTDIRENTRYEX);
    647     int rc = RTDirOpenFiltered(&pPluginDir, pszPluginFilter, RTDIRFILTER_WINNT, 0);
     647    int rc = RTDirOpenFiltered(&pPluginDir, pszPluginFilter, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    648648    if (RT_SUCCESS(rc))
    649649    {
     
    768768    PRTDIR pPluginDir = NULL;
    769769    size_t cbPluginDirEntry = sizeof(RTDIRENTRYEX);
    770     int rc = RTDirOpenFiltered(&pPluginDir, pszPluginFilter, RTDIRFILTER_WINNT, 0);
     770    int rc = RTDirOpenFiltered(&pPluginDir, pszPluginFilter, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    771771    if (RT_SUCCESS(rc))
    772772    {
  • trunk/src/VBox/VMM/VMMR3/DBGFR3PlugIn.cpp

    r69111 r69674  
    472472
    473473    PRTDIR pDir;
    474     rc = RTDirOpenFiltered(&pDir, szPath, RTDIRFILTER_WINNT, 0);
     474    rc = RTDirOpenFiltered(&pDir, szPath, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    475475    if (RT_SUCCESS(rc))
    476476    {
  • trunk/src/VBox/ValidationKit/utils/usb/UsbTestServicePlatform-linux.cpp

    r69227 r69674  
    126126
    127127    PRTDIR pDir = NULL;
    128     rc = RTDirOpenFiltered(&pDir, aszPath, RTDIRFILTER_WINNT, 0);
     128    rc = RTDirOpenFiltered(&pDir, aszPath, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    129129    if (RT_SUCCESS(rc))
    130130    {
     
    206206    /* Enumerate the available HCD and their bus numbers. */
    207207    PRTDIR pDir = NULL;
    208     int rc = RTDirOpenFiltered(&pDir, aszPath, RTDIRFILTER_WINNT, 0);
     208    int rc = RTDirOpenFiltered(&pDir, aszPath, RTDIRFILTER_WINNT, 0 /*fFlags*/);
    209209    if (RT_SUCCESS(rc))
    210210    {
  • trunk/src/bldprogs/scm.cpp

    r69510 r69674  
    22982298     */
    22992299    PRTDIR pDir;
    2300     rc = RTDirOpenFiltered(&pDir, pszBuf, RTDIRFILTER_NONE, 0);
     2300    rc = RTDirOpenFiltered(&pDir, pszBuf, RTDIRFILTER_NONE, 0 /*fFlags*/);
    23012301    if (RT_FAILURE(rc))
    23022302    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette