VirtualBox

Changeset 33336 in vbox


Ignore:
Timestamp:
Oct 22, 2010 10:06:53 AM (14 years ago)
Author:
vboxsync
Message:

Main-OVF: Make the target format changeable, the right way.

File:
1 edited

Legend:

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

    r33332 r33336  
    16911691    /**************** Check */
    16921692
     1693    /* Figure out which format the user like to have. Default is VMDK. */
     1694    Utf8Str strFormat = "VMDK";
     1695    if (strTargetPath.endsWith("vdi", Utf8Str::CaseInsensitive))
     1696        strFormat = "VDI";
     1697    else if (strTargetPath.endsWith("vhd", Utf8Str::CaseInsensitive))
     1698        strFormat = "VHD";
     1699
     1700    bool fNeedsGlobalSaveSettings;
     1701    /* Create an IMedium object. */
    16931702    pTargetHD.createObject();
    1694     bool fNeedsGlobalSaveSettings;
    1695     // create an empty hard disk
    16961703    rc = pTargetHD->init(mVirtualBox,
    1697                          Utf8Str("VMDK"),
     1704                         strFormat,
    16981705                         strTargetPath,
    16991706                         Guid::Empty,        // media registry
     
    17011708    if (FAILED(rc)) throw rc;
    17021709
     1710    /* Now create an empty hard disk. */
     1711    rc = mVirtualBox->CreateHardDisk(NULL,
     1712                                     Bstr(strTargetPath).raw(),
     1713                                     ComPtr<IMedium>(pTargetHD).asOutParam());
     1714    if (FAILED(rc)) throw rc;
     1715
    17031716    /* If strHref is empty we have to create a new file */
    17041717    if (strSourceOVF.isEmpty())
    17051718    {
    1706         // which format to use?
    1707         Bstr srcFormat = L"VDI";
    1708         if (   di.strFormat.compare("http://www.vmware.com/specifications/vmdk.html#sparse", Utf8Str::CaseInsensitive)
    1709                || di.strFormat.compare("http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized", Utf8Str::CaseInsensitive)
    1710                || di.strFormat.compare("http://www.vmware.com/specifications/vmdk.html#compressed", Utf8Str::CaseInsensitive)
    1711                || di.strFormat.compare("http://www.vmware.com/interfaces/specifications/vmdk.html#compressed", Utf8Str::CaseInsensitive)
    1712            )
    1713             srcFormat = L"VMDK";
    1714         rc = mVirtualBox->CreateHardDisk(srcFormat.raw(),
    1715                                          Bstr(strTargetPath).raw(),
    1716                                          ComPtr<IMedium>(pTargetHD).asOutParam());
    1717         if (FAILED(rc)) throw rc;
    1718 
    17191719        // create a dynamic growing disk image with the given capacity
    17201720        rc = pTargetHD->CreateBaseStorage(di.iCapacity / _1M, MediumVariant_Standard, pProgress2.asOutParam());
     
    17271727    else
    17281728    {
    1729         /* Create a new hard disk interface for the destination disk image */
    1730         rc = mVirtualBox->CreateHardDisk(NULL,
    1731                                          Bstr(strTargetPath).raw(),
    1732                                          ComPtr<IMedium>(pTargetHD).asOutParam());
    1733         if (FAILED(rc)) throw rc;
    1734 
    17351729        // We need a proper format description
    17361730        ComObjPtr<MediumFormat> format;
    17371731        // Scope for the AutoReadLock
    17381732        {
     1733            /* Which format to use? */
     1734            Utf8Str strSrcFormat = "VDI";
     1735            if (   di.strFormat.compare("http://www.vmware.com/specifications/vmdk.html#sparse", Utf8Str::CaseInsensitive)
     1736                   || di.strFormat.compare("http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized", Utf8Str::CaseInsensitive)
     1737                   || di.strFormat.compare("http://www.vmware.com/specifications/vmdk.html#compressed", Utf8Str::CaseInsensitive)
     1738                   || di.strFormat.compare("http://www.vmware.com/interfaces/specifications/vmdk.html#compressed", Utf8Str::CaseInsensitive)
     1739               )
     1740                strSrcFormat = "VMDK";
    17391741            SystemProperties *pSysProps = mVirtualBox->getSystemProperties();
    17401742            AutoReadLock propsLock(pSysProps COMMA_LOCKVAL_SRC_POS);
    1741             Utf8Str strFormat = "VMDK";
    1742             if (strTargetPath.endsWith("vdi", Utf8Str::CaseInsensitive))
    1743                 strFormat = "VDI";
    1744             else if (strTargetPath.endsWith("vhd", Utf8Str::CaseInsensitive))
    1745                 strFormat = "VHD";
    1746             format = pSysProps->mediumFormat(strFormat);
     1743            format = pSysProps->mediumFormat(strSrcFormat);
    17471744            if (format.isNull())
    17481745                throw setError(VBOX_E_NOT_SUPPORTED,
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