VirtualBox

Ignore:
Timestamp:
Apr 29, 2010 6:12:35 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
60863
Message:

iprt: More path conversion avoidance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/pathhost-posix.cpp

    r28912 r28915  
    177177
    178178
    179 int rtPathToNative(char **ppszNativePath, const char *pszPath)
     179int rtPathToNative(char const **ppszNativePath, const char *pszPath, const char *pszBasePath)
    180180{
    181181    *ppszNativePath = NULL;
     
    185185    {
    186186        if (g_fPassthruUtf8 || !*pszPath)
    187             *ppszNativePath = (char *)pszPath;
     187            *ppszNativePath = pszPath;
    188188        else
    189189            rc = rtStrConvert(pszPath, strlen(pszPath), "UTF-8",
    190                               ppszNativePath, 0, g_szFsCodeset,
     190                              (char **)ppszNativePath, 0, g_szFsCodeset,
    191191                              2, g_enmUtf8ToFsIdx);
    192192    }
     193    NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */
    193194    return rc;
    194195}
    195196
    196197
    197 int rtPathToNativeEx(char **ppszNativePath, const char *pszPath, const char *pszBasePath)
    198 {
    199     /* We don't query the FS for codeset preferences yet, so nothing special to do here. */
    200     NOREF(pszBasePath);
    201     return rtPathToNative(ppszNativePath, pszPath);
    202 }
    203 
    204 
    205 void rtPathFreeNative(char *pszNativePath, const char *pszPath)
     198void rtPathFreeNative(char const *pszNativePath, const char *pszPath)
    206199{
    207200    if (    pszNativePath != pszPath
    208201        &&  pszNativePath)
    209         RTStrFree(pszNativePath);
    210 }
    211 
    212 
    213 int rtPathFromNative(char **ppszPath, const char *pszNativePath)
     202        RTStrFree((char *)pszNativePath);
     203}
     204
     205
     206int rtPathFromNative(const char **ppszPath, const char *pszNativePath, const char *pszBasePath)
    214207{
    215208    *ppszPath = NULL;
     
    235228        else
    236229            rc = rtStrConvert(pszNativePath, strlen(pszNativePath), g_szFsCodeset,
    237                               ppszPath, 0, "UTF-8",
     230                              (char **)ppszPath, 0, "UTF-8",
    238231                              2, g_enmFsToUtf8Idx);
    239232    }
     233    NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */
    240234    return rc;
    241235}
    242236
    243237
    244 int rtPathFromNativeEx(char **ppszPath, const char *pszNativePath, const char *pszBasePath)
    245 {
    246     /* We don't query the FS for codeset preferences yet, so nothing special to do here. */
    247     NOREF(pszBasePath);
    248     return rtPathFromNative(ppszPath, pszNativePath);
    249 }
    250 
     238void rtPathFreeIprt(const char *pszPath, const char *pszNativePath)
     239{
     240    if (   pszPath != pszNativePath
     241        && !pszPath)
     242        RTStrFree((char *)pszPath);
     243}
     244
     245
     246int rtPathFromNativeCopy(char *pszPath, size_t cbPath, const char *pszNativePath, const char *pszBasePath)
     247{
     248    int rc = RTOnce(&g_OnceInitPathConv, rtPathConvInitOnce, NULL, NULL);
     249    if (RT_SUCCESS(rc))
     250    {
     251        if (g_fPassthruUtf8 || !*pszNativePath)
     252            rc = RTStrCopyEx(pszPath, cbPath, pszNativePath, RTSTR_MAX);
     253        else if (cbPath)
     254            rc = rtStrConvert(pszNativePath, strlen(pszNativePath), g_szFsCodeset,
     255                              &pszPath, cbPath, "UTF-8",
     256                              2, g_enmFsToUtf8Idx);
     257        else
     258            rc = VERR_BUFFER_OVERFLOW;
     259    }
     260
     261    NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */
     262    return rc;
     263}
     264
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