VirtualBox

Ignore:
Timestamp:
Aug 24, 2012 2:01:48 PM (12 years ago)
Author:
vboxsync
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
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