VirtualBox

Ignore:
Timestamp:
Apr 10, 2019 2:19:04 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129946
Message:

*,IPRT: Use new RTPathAbsExEx function instead of RTPathAbsEx. bugref:9172

Location:
trunk/src/VBox/Runtime/common/path
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/path/RTPathAbsEx.cpp

    r78048 r78090  
    5353RTDECL(int) RTPathAbsEx(const char *pszBase, const char *pszPath, char *pszAbsPath, size_t cbAbsPath)
    5454{
    55 #if 1
     55#if 0
    5656    if (    pszBase
    5757        &&  pszPath
  • trunk/src/VBox/Runtime/common/path/RTPathAbsExDup.cpp

    r76553 r78090  
    5050{
    5151    char szPath[RTPATH_MAX];
    52     int rc = RTPathAbsEx(pszBase, pszPath, szPath, sizeof(szPath));
     52    size_t cbPath = sizeof(szPath);
     53    int rc = RTPathAbsExEx(pszBase, pszPath, RTPATH_STR_F_STYLE_HOST, szPath, &cbPath);
    5354    if (RT_SUCCESS(rc))
    5455        return RTStrDup(szPath);
     56
     57    if (rc == VERR_BUFFER_OVERFLOW)
     58    {
     59        size_t   cbPrevPath = sizeof(szPath);
     60        uint32_t cTries = 6;
     61        while (cTries-- > 0)
     62        {
     63            cbPath     = RT_MAX(RT_ALIGN_Z(cbPath + 16, 64), cbPrevPath + 256);
     64            cbPrevPath = cbPath;
     65            char *pszAbsPath = (char *)RTStrAlloc(cbPath);
     66            if (pszAbsPath)
     67            {
     68                rc = RTPathAbsExEx(pszBase, pszPath, RTPATH_STR_F_STYLE_HOST, pszAbsPath, &cbPath);
     69                if (RT_SUCCESS(rc))
     70                    return pszAbsPath;
     71                RTStrFree(pszAbsPath);
     72            }
     73            else
     74                break;
     75        }
     76    }
    5577    return NULL;
    5678}
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