VirtualBox

Ignore:
Timestamp:
Oct 19, 2010 3:41:23 PM (14 years ago)
Author:
vboxsync
Message:

Main: new VirtualBox::ComposeMachineFilename() API; remove the 'default hard disk folder' concept and related APIs; GUI wizards need fixing

File:
1 edited

Legend:

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

    r33232 r33238  
    11491149/////////////////////////////////////////////////////////////////////////////
    11501150
     1151STDMETHODIMP VirtualBox::ComposeMachineFilename(IN_BSTR aName,
     1152                                                IN_BSTR aBaseFolder,
     1153                                                BSTR *aFilename)
     1154{
     1155    LogFlowThisFuncEnter();
     1156    LogFlowThisFunc(("aName=\"%ls\",aBaseFolder=\"%ls\"\n", aName, aBaseFolder));
     1157
     1158    CheckComArgStrNotEmptyOrNull(aName);
     1159    CheckComArgOutPointerValid(aFilename);
     1160
     1161    AutoCaller autoCaller(this);
     1162    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1163
     1164    /* Compose the settings file name using the following scheme:
     1165     *
     1166     *     <base_folder>/<machine_name>/<machine_name>.xml
     1167     *
     1168     * If a non-null and non-empty base folder is specified, the default
     1169     * machine folder will be used as a base folder.
     1170     */
     1171    Utf8Str strBase = aBaseFolder;
     1172    if (strBase.isEmpty())
     1173        /* we use the non-full folder value below to keep the path relative */
     1174        getDefaultMachineFolder(strBase);
     1175
     1176    Bstr bstrSettingsFile = BstrFmt("%s%c%ls%c%ls.vbox",
     1177                                    strBase.c_str(),
     1178                                    RTPATH_DELIMITER,
     1179                                    aName,
     1180                                    RTPATH_DELIMITER,
     1181                                    aName);
     1182
     1183    bstrSettingsFile.detachTo(aFilename);
     1184
     1185    return S_OK;
     1186}
     1187
    11511188/** @note Locks mSystemProperties object for reading. */
    11521189STDMETHODIMP VirtualBox::CreateMachine(IN_BSTR aName,
     
    11671204    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    11681205
    1169     /* Compose the settings file name using the following scheme:
    1170      *
    1171      *     <base_folder>/<machine_name>/<machine_name>.xml
    1172      *
    1173      * If a non-null and non-empty base folder is specified, the default
    1174      * machine folder will be used as a base folder.
    1175      */
    1176     Utf8Str strSettingsFile = aBaseFolder;
    1177     if (strSettingsFile.isEmpty())
    1178         /* we use the non-full folder value below to keep the path relative */
    1179         getDefaultMachineFolder(strSettingsFile);
    1180 
    1181     strSettingsFile = Utf8StrFmt("%s%c%ls%c%ls.vbox",
    1182                                  strSettingsFile.c_str(),
    1183                                  RTPATH_DELIMITER,
    1184                                  aName,
    1185                                  RTPATH_DELIMITER,
    1186                                  aName);
    1187 
    1188     HRESULT rc = E_FAIL;
     1206    Bstr bstrSettingsFilename;
     1207    HRESULT rc = ComposeMachineFilename(aName, aBaseFolder, bstrSettingsFilename.asOutParam());
     1208    if (FAILED(rc)) return rc;
    11891209
    11901210    /* create a new object */
     
    12041224    /* initialize the machine object */
    12051225    rc = machine->init(this,
    1206                        strSettingsFile,
     1226                       Utf8Str(bstrSettingsFilename),
    12071227                       Utf8Str(aName),
    12081228                       id,
     
    28462866    AutoReadLock propsLock(m->pSystemProperties COMMA_LOCKVAL_SRC_POS);
    28472867    str = m->pSystemProperties->m->strDefaultMachineFolder;
    2848 }
    2849 
    2850 /**
    2851  * Returns the default hard disk folder from the system properties
    2852  * with proper locking.
    2853  * @return
    2854  */
    2855 void VirtualBox::getDefaultHardDiskFolder(Utf8Str &str) const
    2856 {
    2857     AutoReadLock propsLock(m->pSystemProperties COMMA_LOCKVAL_SRC_POS);
    2858     str = m->pSystemProperties->m->strDefaultHardDiskFolder;
    28592868}
    28602869
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