VirtualBox

忽略:
時間撮記:
2012-8-24 下午02:01:48 (12 年 以前)
作者:
vboxsync
訊息:

RTPathStartsWith: Deal with pszParentPath = root (or having a trailing slash). This fixes 'VBoxManage copyfrom /root-file hostfile'.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/common/path/comparepaths.cpp

    r33540 r42978  
    158158 * @param   pszParentPath   Parent path, must be an absolute path.
    159159 *                          No trailing directory slash!
    160  *
    161  * @remarks This API doesn't currently handle root directory compares in a
    162  *          manner consistent with the other APIs. RTPathStartsWith(pszSomePath,
    163  *          "/") will not work if pszSomePath isn't "/".
    164160 */
    165161RTDECL(bool) RTPathStartsWith(const char *pszPath, const char *pszParentPath)
     
    174170
    175171    const size_t cchParentPath = strlen(pszParentPath);
    176     return RTPATH_IS_SLASH(pszPath[cchParentPath])
    177         || pszPath[cchParentPath] == '\0';
     172    if (RTPATH_IS_SLASH(pszPath[cchParentPath]))
     173        return true;
     174    if (pszPath[cchParentPath] == '\0')
     175        return true;
     176
     177    /* Deal with pszParentPath = root (or having a trailing slash). */
     178    if (   pszParentPath > 0
     179        && RTPATH_IS_SLASH(pszParentPath[cchParentPath - 1])
     180        && RTPATH_IS_SLASH(pszPath[cchParentPath - 1]))
     181        return true;
     182
     183    return false;
    178184}
    179185
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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