VirtualBox

Changeset 25942 in vbox for trunk/src/VBox/Main/glue/com.cpp


Ignore:
Timestamp:
Jan 20, 2010 5:26:22 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56784
Message:

*: RTEnv usage cleanup - avoid RTEnvGet() as it doesn't necessarily return UTF-8 encoded strings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/com.cpp

    r22708 r25942  
    138138}
    139139
    140 int GetVBoxUserHomeDirectory (char *aDir, size_t aDirLen)
     140int GetVBoxUserHomeDirectory(char *aDir, size_t aDirLen)
    141141{
    142142    AssertReturn(aDir, VERR_INVALID_POINTER);
     
    146146    *aDir = 0;
    147147
    148     const char *VBoxUserHome = RTEnvGet ("VBOX_USER_HOME");
     148    const char *VBoxUserHome = RTEnvGet("VBOX_USER_HOME");
    149149
    150150    char path [RTPATH_MAX];
     
    155155        /* get the full path name */
    156156        char *VBoxUserHomeUtf8 = NULL;
    157         vrc = RTStrCurrentCPToUtf8 (&VBoxUserHomeUtf8, VBoxUserHome);
     157        vrc = RTStrCurrentCPToUtf8(&VBoxUserHomeUtf8, VBoxUserHome);
    158158        if (RT_SUCCESS(vrc))
    159159        {
    160             vrc = RTPathAbs (VBoxUserHomeUtf8, path, sizeof (path));
     160            vrc = RTPathAbs(VBoxUserHomeUtf8, path, sizeof (path));
    161161            if (RT_SUCCESS(vrc))
    162162            {
    163                 if (aDirLen < strlen (path) + 1)
     163                if (aDirLen < strlen(path) + 1)
    164164                    vrc = VERR_BUFFER_OVERFLOW;
    165165                else
    166                     strcpy (aDir, path);
     166                    strcpy(aDir, path);
    167167            }
    168             RTStrFree (VBoxUserHomeUtf8);
     168            RTStrFree(VBoxUserHomeUtf8);
    169169        }
    170170    }
     
    172172    {
    173173        /* compose the config directory (full path) */
    174         vrc = RTPathUserHome (path, sizeof (path));
     174        vrc = RTPathUserHome(path, sizeof(path));
    175175        if (RT_SUCCESS(vrc))
    176176        {
    177             size_t len =
    178                 RTStrPrintf (aDir, aDirLen, "%s%c%s",
    179                              path, RTPATH_DELIMITER, VBOX_USER_HOME_SUFFIX);
    180             if (len != strlen (path) + 1 + strlen (VBOX_USER_HOME_SUFFIX))
     177            size_t len = RTStrPrintf(aDir, aDirLen, "%s%c%s",
     178                                     path, RTPATH_DELIMITER, VBOX_USER_HOME_SUFFIX);
     179            if (len != strlen(path) + 1 + strlen (VBOX_USER_HOME_SUFFIX))
    181180                vrc = VERR_BUFFER_OVERFLOW;
    182181        }
     
    185184    /* ensure the home directory exists */
    186185    if (RT_SUCCESS(vrc))
    187         if (!RTDirExists (aDir))
    188             vrc = RTDirCreateFullPath (aDir, 0777);
     186        if (!RTDirExists(aDir))
     187            vrc = RTDirCreateFullPath(aDir, 0777);
    189188
    190189    return vrc;
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