VirtualBox

忽略:
時間撮記:
2013-5-13 上午11:05:55 (12 年 以前)
作者:
vboxsync
訊息:

iprt/dir.h,++: Added RTDirQueryUnknownType, RTDirQueryUnknownTypeEx, RTDirEntryIsStdDotLink and RTDirEntryExIsStdDotLink to simplify directory enumeration.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/r3/dir.cpp

    r45630 r46008  
    731731}
    732732
     733
     734RTDECL(int) RTDirQueryUnknownTypeEx(const char *pszComposedName, RTDIRENTRYTYPE *penmType, PRTFSOBJINFO pObjInfo)
     735{
     736    int rc = RTPathQueryInfoEx(pszComposedName, pObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);
     737    if (RT_FAILURE(rc))
     738        return rc;
     739
     740    if (RTFS_IS_DIRECTORY(pObjInfo->Attr.fMode))
     741        *penmType = RTDIRENTRYTYPE_DIRECTORY;
     742    else if (RTFS_IS_FILE(pObjInfo->Attr.fMode))
     743        *penmType = RTDIRENTRYTYPE_FILE;
     744    else if (RTFS_IS_SYMLINK(pObjInfo->Attr.fMode))
     745        *penmType = RTDIRENTRYTYPE_SYMLINK;
     746    else if (RTFS_IS_FIFO(pObjInfo->Attr.fMode))
     747        *penmType = RTDIRENTRYTYPE_FIFO;
     748    else if (RTFS_IS_DEV_CHAR(pObjInfo->Attr.fMode))
     749        *penmType = RTDIRENTRYTYPE_DEV_CHAR;
     750    else if (RTFS_IS_DEV_BLOCK(pObjInfo->Attr.fMode))
     751        *penmType = RTDIRENTRYTYPE_DEV_BLOCK;
     752    else if (RTFS_IS_SOCKET(pObjInfo->Attr.fMode))
     753        *penmType = RTDIRENTRYTYPE_SOCKET;
     754    else if (RTFS_IS_WHITEOUT(pObjInfo->Attr.fMode))
     755        *penmType = RTDIRENTRYTYPE_WHITEOUT;
     756    else
     757        *penmType = RTDIRENTRYTYPE_UNKNOWN;
     758
     759    return VINF_SUCCESS;
     760}
     761
     762
     763RTDECL(int) RTDirQueryUnknownType(const char *pszComposedName, RTDIRENTRYTYPE *penmType)
     764{
     765    if (*penmType != RTDIRENTRYTYPE_UNKNOWN)
     766        return VINF_SUCCESS;
     767
     768    RTFSOBJINFO ObjInfo;
     769    return RTDirQueryUnknownTypeEx(pszComposedName, penmType, &ObjInfo);
     770}
     771
     772
     773RTDECL(bool) RTDirEntryIsStdDotLink(PRTDIRENTRY pDirEntry)
     774{
     775    if (pDirEntry->szName[0] != '.')
     776        return false;
     777    if (pDirEntry->cbName == 1)
     778        return true;
     779    if (pDirEntry->cbName != 2)
     780        return false;
     781    return pDirEntry->szName[1] == '.';
     782}
     783
     784
     785RTDECL(bool) RTDirEntryExIsStdDotLink(PCRTDIRENTRYEX pDirEntryEx)
     786{
     787    if (pDirEntryEx->szName[0] != '.')
     788        return false;
     789    if (pDirEntryEx->cbName == 1)
     790        return true;
     791    if (pDirEntryEx->cbName != 2)
     792        return false;
     793    return pDirEntryEx->szName[1] == '.';
     794}
     795
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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