VirtualBox

Changeset 33598 in vbox


Ignore:
Timestamp:
Oct 29, 2010 11:08:42 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67209
Message:

Main: use RTPATH_MAX and RTPathUserHome() wrapper

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r33596 r33598  
    950950
    951951/**
     952 * Returns the user's home directory. Wrapper around RTPathUserHome().
     953 * @param strPath
     954 * @return
     955 */
     956HRESULT SystemProperties::getUserHomeDirectory(Utf8Str &strPath)
     957{
     958    char szHome[RTPATH_MAX];
     959    int vrc = RTPathUserHome(szHome, sizeof(szHome));
     960    if (RT_FAILURE(vrc))
     961        return setError(E_FAIL,
     962                        tr("Cannot determine user home directory (%Rrc)"),
     963                        vrc);
     964    strPath = szHome;
     965    return S_OK;
     966}
     967
     968/**
    952969 * Internal implementation to set the default machine folder. Gets called
    953970 * from the public attribute setter as well as loadSettings(). With 4.0,
     
    967984    {
    968985        // new default with VirtualBox 4.0: "$HOME/VirtualBox VMs"
    969         char szHome[200]; // RTPATH_MAX is ridiculously large
    970         int vrc = RTPathUserHome(szHome, sizeof(szHome));
    971         if (RT_FAILURE(vrc))
    972             return setError(E_FAIL,
    973                             tr("Cannot determine user home directory (%Rrc)"),
    974                             vrc);
    975 
    976         path = szHome;
     986        HRESULT rc = getUserHomeDirectory(path);
     987        if (FAILED(rc)) return rc;
    977988        path += RTPATH_SLASH_STR "VirtualBox VMs";
    978989    }
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r33596 r33598  
    118118    typedef std::list<ComObjPtr<MediumFormat> > MediumFormatList;
    119119
     120    HRESULT getUserHomeDirectory(Utf8Str &strPath);
    120121    HRESULT setDefaultMachineFolder(const Utf8Str &aPath);
    121122    HRESULT setDefaultHardDiskFormat(const Utf8Str &aFormat);
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