Changeset 33336 in vbox
- Timestamp:
- Oct 22, 2010 10:06:53 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplImport.cpp
r33332 r33336 1691 1691 /**************** Check */ 1692 1692 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. */ 1693 1702 pTargetHD.createObject(); 1694 bool fNeedsGlobalSaveSettings;1695 // create an empty hard disk1696 1703 rc = pTargetHD->init(mVirtualBox, 1697 Utf8Str("VMDK"),1704 strFormat, 1698 1705 strTargetPath, 1699 1706 Guid::Empty, // media registry … … 1701 1708 if (FAILED(rc)) throw rc; 1702 1709 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 1703 1716 /* If strHref is empty we have to create a new file */ 1704 1717 if (strSourceOVF.isEmpty()) 1705 1718 { 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 1719 1719 // create a dynamic growing disk image with the given capacity 1720 1720 rc = pTargetHD->CreateBaseStorage(di.iCapacity / _1M, MediumVariant_Standard, pProgress2.asOutParam()); … … 1727 1727 else 1728 1728 { 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 1735 1729 // We need a proper format description 1736 1730 ComObjPtr<MediumFormat> format; 1737 1731 // Scope for the AutoReadLock 1738 1732 { 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"; 1739 1741 SystemProperties *pSysProps = mVirtualBox->getSystemProperties(); 1740 1742 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); 1747 1744 if (format.isNull()) 1748 1745 throw setError(VBOX_E_NOT_SUPPORTED,
Note:
See TracChangeset
for help on using the changeset viewer.