VirtualBox

Changeset 28915 in vbox for trunk/src/VBox/Runtime/r3/darwin


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.

Location:
trunk/src/VBox/Runtime/r3/darwin
Files:
2 edited

Legend:

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

    r28880 r28915  
    4141
    4242
    43 int rtPathToNative(char **ppszNativePath, const char *pszPath)
     43int rtPathToNative(const char **ppszNativePath, const char *pszPath, const char *pszBasePath)
    4444{
    4545    /** @todo We should decompose the string here, but the file system will do
    4646     *        that for us if we don't, so why bother. */
    4747    *ppszNativePath = (char *)pszPath;
     48    NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */
    4849    return VINF_SUCCESS;
    4950}
    5051
    5152
    52 int rtPathToNativeEx(char **ppszNativePath, const char *pszPath, const char *pszBasePath)
     53void rtPathFreeNative(char const *pszNativePath, const char *pszPath)
    5354{
    54     NOREF(pszBasePath);
    55     return rtPathToNative(ppszNativePath, pszPath);
    56 }
    57 
    58 
    59 void rtPathFreeNative(char *pszNativePath, const char *pszPath)
    60 {
    61     Assert((const char *)pszNativePath == pszPath || !pszNativePath);
     55    Assert(pszNativePath == pszPath || !pszNativePath);
    6256    NOREF(pszNativePath);
    6357    NOREF(pszPath);
     
    6559
    6660
    67 int rtPathFromNative(char **ppszPath, const char *pszNativePath)
     61int rtPathFromNative(char const **ppszPath, const char *pszNativePath, const char *pszBasePath)
    6862{
    6963    /** @todo We must compose the codepoints in the string here.  We get file names
    7064     *        in normalization form D so we'll end up with normalization form C
    7165     *        whatever approach we take. */
    72     return RTStrDupEx(ppszPath, pszNativePath);
     66    int rc = RTStrValidateEncodingEx(pszNativePath, RTSTR_MAX, 0 /*fFlags*/);
     67    if (RT_SUCCESS(rc))
     68        *ppszPath = pszNativePath;
     69    NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */
     70    return rc;
    7371}
    7472
    7573
    76 int rtPathFromNativeEx(char **ppszPath, const char *pszNativePath, const char *pszBasePath)
     74void rtPathFreeIprt(const char *pszPath, const char *pszNativePath)
    7775{
    78     NOREF(pszBasePath);
    79     return rtPathFromNative(ppszPath, pszNativePath);
     76    Assert(pszPath == pszNativePath || !pszPath);
     77    NOREF(pszPath); NOREF(pszNativePath);
    8078}
    8179
     80
     81int rtPathFromNativeCopy(char *pszPath, size_t cbPath, const char *pszNativePath, const char *pszBasePath)
     82{
     83    /** @todo We must compose the codepoints in the string here.  We get file names
     84     *        in normalization form D so we'll end up with normalization form C
     85     *        whatever approach we take. */
     86    int rc = RTStrValidateEncodingEx(pszNativePath, RTSTR_MAX, 0 /*fFlags*/);
     87    if (RT_SUCCESS(rc))
     88        rc = RTStrCopyEx(pszPath, cbPath, pszNativePath, RTSTR_MAX);
     89    NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */
     90    return rc;
     91}
     92
  • trunk/src/VBox/Runtime/r3/darwin/rtProcInitExePath-darwin.cpp

    r28800 r28915  
    4949    AssertReturn(pszImageName, VERR_INTERNAL_ERROR);
    5050
    51     char *pszTmp;
    52     int rc = rtPathFromNative(&pszTmp, pszImageName);
     51    int rc = rtPathFromNativeCopy(pszPath, cchPath, pszImageName, NULL);
    5352    AssertMsgRCReturn(rc, ("rc=%Rrc pszLink=\"%s\"\nhex: %.*Rhsx\n", rc, pszPath, strlen(pszImageName), pszPath), rc);
    54 
    55     size_t cch = strlen(pszTmp);
    56     AssertReturn(cch <= cchPath, VERR_BUFFER_OVERFLOW);
    57 
    58     memcpy(pszPath, pszTmp, cch + 1);
    59     RTStrFree(pszTmp);
    6053
    6154    return VINF_SUCCESS;
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