VirtualBox

Changeset 69674 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Nov 13, 2017 3:29:43 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
119042
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/src/VBox/Runtime/r3
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.

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