VirtualBox

Changeset 43041 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Aug 28, 2012 1:58:40 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
80375
Message:

Main/VirtualBox: final API change, cleans up optional parameters to IVirtualBox::createMachine, preparing for adding more flags.

Location:
trunk/src/VBox/Main/src-server
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r42708 r43041  
    206206            rc = mVirtualBox->ComposeMachineFilename(Bstr(nameVBox).raw(),
    207207                                                     NULL /* aGroup */,
     208                                                     NULL /* aCreateFlags */,
    208209                                                     NULL /* aBaseFolder */,
    209210                                                     bstrMachineFilename.asOutParam());
     
    19541955                                    ComSafeArrayAsInParam(groups),
    19551956                                    Bstr(stack.strOsTypeVBox).raw(),
    1956                                     NULL, /* uuid */
    1957                                     FALSE, /* fForceOverwrite */
     1957                                    NULL, /* aCreateFlags */
    19581958                                    pNewMachine.asOutParam());
    19591959    if (FAILED(rc)) throw rc;
     
    28682868        rc = mVirtualBox->ComposeMachineFilename(Bstr(stack.strNameVBox).raw(),
    28692869                                                 NULL /* aGroup */,
     2870                                                 NULL /* aCreateFlags */,
    28702871                                                 NULL /* aBaseFolder */,
    28712872                                                 bstrMachineFilename.asOutParam());
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r43023 r43041  
    290290                      GuestOSType *aOsType,
    291291                      const Guid &aId,
    292                       bool fForceOverwrite)
     292                      bool fForceOverwrite,
     293                      bool fDirectoryIncludesUUID)
    293294{
    294295    LogFlowThisFuncEnter();
     
    324325        mUserData->s.llGroups = llGroups;
    325326
     327        mUserData->s.fDirectoryIncludesUUID = fDirectoryIncludesUUID;
    326328        // the "name sync" flag determines whether the machine directory gets renamed along
    327329        // with the machine file; say so if the settings file name is the same as the
     
    1094610948    strConfigFileOnly.stripPath()                           // vmname.vbox
    1094710949                     .stripExt();                           // vmname
     10950    /** @todo hack, make somehow use of ComposeMachineFilename */
     10951    if (mUserData->s.fDirectoryIncludesUUID)
     10952        strConfigFileOnly += Utf8StrFmt(" (%RTuuid)", mData->mUuid.raw());
    1094810953
    1094910954    AssertReturn(!strMachineDirName.isEmpty(), false);
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r42957 r43041  
    14061406STDMETHODIMP VirtualBox::ComposeMachineFilename(IN_BSTR aName,
    14071407                                                IN_BSTR aGroup,
     1408                                                IN_BSTR aCreateFlags,
    14081409                                                IN_BSTR aBaseFolder,
    14091410                                                BSTR *aFilename)
     
    14171418    AutoCaller autoCaller(this);
    14181419    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1420
     1421    Utf8Str strCreateFlags(aCreateFlags);
     1422    Guid id;
     1423    bool fDirectoryIncludesUUID = false;
     1424    if (!strCreateFlags.isEmpty())
     1425    {
     1426        const char *pcszNext = strCreateFlags.c_str();
     1427        while (*pcszNext != '\0')
     1428        {
     1429            Utf8Str strFlag;
     1430            const char *pcszComma = RTStrStr(pcszNext, ",");
     1431            if (!pcszComma)
     1432                strFlag = pcszNext;
     1433            else
     1434                strFlag = Utf8Str(pcszNext, pcszComma - pcszNext);
     1435
     1436            const char *pcszEqual = RTStrStr(strFlag.c_str(), "=");
     1437            /* skip over everything which doesn't contain '=' */
     1438            if (pcszEqual && pcszEqual != strFlag.c_str())
     1439            {
     1440                Utf8Str strKey(strFlag.c_str(), pcszEqual - strFlag.c_str());
     1441                Utf8Str strValue(strFlag.c_str() + (pcszEqual - strFlag.c_str() + 1));
     1442
     1443                if (strKey == "UUID")
     1444                    id = strValue.c_str();
     1445                else if (strKey == "directoryIncludesUUID")
     1446                    fDirectoryIncludesUUID = (strValue == "1");
     1447            }
     1448
     1449            if (!pcszComma)
     1450                pcszNext += strFlag.length();
     1451            else
     1452                pcszNext += strFlag.length() + 1;
     1453        }
     1454    }
     1455    if (id.isEmpty())
     1456        fDirectoryIncludesUUID = false;
    14191457
    14201458    Utf8Str strGroup(aGroup);
     
    14361474    Utf8Str strBase = aBaseFolder;
    14371475    Utf8Str strName = aName;
     1476    Utf8Str strDirName(strName);
     1477    if (fDirectoryIncludesUUID)
     1478        strDirName += Utf8StrFmt(" (%RTuuid)", id.raw());
    14381479    sanitiseMachineFilename(strName);
     1480    sanitiseMachineFilename(strDirName);
    14391481
    14401482    if (strBase.isEmpty())
     
    15511593                                       ComSafeArrayIn(IN_BSTR, aGroups),
    15521594                                       IN_BSTR aOsTypeId,
    1553                                        IN_BSTR aId,
    1554                                        BOOL forceOverwrite,
     1595                                       IN_BSTR aCreateFlags,
    15551596                                       IMachine **aMachine)
    15561597{
    15571598    LogFlowThisFuncEnter();
    1558     LogFlowThisFunc(("aSettingsFile=\"%ls\", aName=\"%ls\", aOsTypeId =\"%ls\"\n", aSettingsFile, aName, aOsTypeId));
     1599    LogFlowThisFunc(("aSettingsFile=\"%ls\", aName=\"%ls\", aOsTypeId =\"%ls\", aCreateFlags=\"%ls\"\n", aSettingsFile, aName, aOsTypeId, aCreateFlags));
    15591600
    15601601    CheckComArgStrNotEmptyOrNull(aName);
     
    15701611        return rc;
    15711612
     1613    Utf8Str strCreateFlags(aCreateFlags);
     1614    Guid id;
     1615    bool fForceOverwrite = false;
     1616    bool fDirectoryIncludesUUID = false;
     1617    if (!strCreateFlags.isEmpty())
     1618    {
     1619        const char *pcszNext = strCreateFlags.c_str();
     1620        while (*pcszNext != '\0')
     1621        {
     1622            Utf8Str strFlag;
     1623            const char *pcszComma = RTStrStr(pcszNext, ",");
     1624            if (!pcszComma)
     1625                strFlag = pcszNext;
     1626            else
     1627                strFlag = Utf8Str(pcszNext, pcszComma - pcszNext);
     1628
     1629            const char *pcszEqual = RTStrStr(strFlag.c_str(), "=");
     1630            /* skip over everything which doesn't contain '=' */
     1631            if (pcszEqual && pcszEqual != strFlag.c_str())
     1632            {
     1633                Utf8Str strKey(strFlag.c_str(), pcszEqual - strFlag.c_str());
     1634                Utf8Str strValue(strFlag.c_str() + (pcszEqual - strFlag.c_str() + 1));
     1635
     1636                if (strKey == "UUID")
     1637                    id = strValue.c_str();
     1638                else if (strKey == "forceOverwrite")
     1639                    fForceOverwrite = (strValue == "1");
     1640                else if (strKey == "directoryIncludesUUID")
     1641                    fDirectoryIncludesUUID = (strValue == "1");
     1642            }
     1643
     1644            if (!pcszComma)
     1645                pcszNext += strFlag.length();
     1646            else
     1647                pcszNext += strFlag.length() + 1;
     1648        }
     1649    }
     1650    /* Create UUID if none was specified. */
     1651    if (id.isEmpty())
     1652        id.create();
     1653
    15721654    /* NULL settings file means compose automatically */
    15731655    Bstr bstrSettingsFile(aSettingsFile);
    15741656    if (bstrSettingsFile.isEmpty())
    15751657    {
     1658        Utf8Str strNewCreateFlags(Utf8StrFmt("UUID=%RTuuid", id.raw()));
     1659        if (fDirectoryIncludesUUID)
     1660            strNewCreateFlags += ",directoryIncludesUUID=1";
     1661
    15761662        rc = ComposeMachineFilename(aName,
    15771663                                    Bstr(llGroups.front()).raw(),
     1664                                    Bstr(strNewCreateFlags).raw(),
    15781665                                    NULL /* aBaseFolder */,
    15791666                                    bstrSettingsFile.asOutParam());
     
    15851672    rc = machine.createObject();
    15861673    if (FAILED(rc)) return rc;
    1587 
    1588     /* Create UUID if an empty one was specified. */
    1589     Guid id(aId);
    1590     if (id.isEmpty())
    1591         id.create();
    15921674
    15931675    GuestOSType *osType = NULL;
     
    16021684                       osType,
    16031685                       id,
    1604                        !!forceOverwrite);
     1686                       fForceOverwrite,
     1687                       fDirectoryIncludesUUID);
    16051688    if (SUCCEEDED(rc))
    16061689    {
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