- Timestamp:
- Oct 22, 2010 12:11:21 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplImport.cpp
r33345 r33346 1667 1667 PSHA1STORAGE pStorage) 1668 1668 { 1669 // destination file must not exist1670 if ( strTargetPath.isEmpty()1671 || RTPathExists(strTargetPath.c_str())1672 )1673 throw setError(VBOX_E_FILE_ERROR,1674 tr("Destination file '%s' exists"),1675 strTargetPath.c_str());1676 1677 1669 ComObjPtr<Progress> pProgress; 1678 1670 pProgress.createObject(); … … 1686 1678 char *pszExt = RTPathExt(strTargetPath.c_str()); 1687 1679 /* Figure out which format the user like to have. Default is VMDK. */ 1688 ComObjPtr<MediumFormat> t argetFormat = pSysProps->mediumFormatFromExtension(&pszExt[1]);1689 if (t argetFormat.isNull())1680 ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension(&pszExt[1]); 1681 if (trgFormat.isNull()) 1690 1682 throw setError(VBOX_E_NOT_SUPPORTED, 1691 1683 tr("Could not find a valid medium format for the target disk '%s'"), 1692 1684 strTargetPath.c_str()); 1693 1685 Bstr bstrFormatName; 1694 rc = t argetFormat->COMGETTER(Name)(bstrFormatName.asOutParam());1686 rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 1695 1687 if (FAILED(rc)) throw rc; 1696 1688 strTrgFormat = Utf8Str(bstrFormatName); … … 1714 1706 1715 1707 const Utf8Str &strSourceOVF = di.strHref; 1716 / / construct source file path1708 /* Construct source file path */ 1717 1709 Utf8StrFmt strSrcFilePath("%s%c%s", stack.strSourceDir.c_str(), RTPATH_DELIMITER, strSourceOVF.c_str()); 1718 1710 1719 /* If strHref is empty we have to create a new file */1711 /* If strHref is empty we have to create a new file. */ 1720 1712 if (strSourceOVF.isEmpty()) 1721 1713 { 1722 / / create a dynamic growing disk image with the given capacity1714 /* Create a dynamic growing disk image with the given capacity. */ 1723 1715 rc = pTargetHD->CreateBaseStorage(di.iCapacity / _1M, MediumVariant_Standard, ComPtr<IProgress>(pProgress).asOutParam()); 1724 1716 if (FAILED(rc)) throw rc; 1725 1717 1726 / / advance to the next operation1718 /* Advance to the next operation. */ 1727 1719 stack.pProgress->SetNextOperation(BstrFmt(tr("Creating disk image '%s'"), strTargetPath.c_str()).raw(), 1728 1720 di.ulSuggestedSizeMB); // operation's weight, as set up with the IProgress originally … … 1730 1722 else 1731 1723 { 1732 // We need a proper format description 1733 ComObjPtr<MediumFormat> format; 1734 // Scope for the AutoReadLock 1735 { 1736 /* Which format to use? */ 1737 Utf8Str strSrcFormat = "VDI"; 1738 if ( di.strFormat.compare("http://www.vmware.com/specifications/vmdk.html#sparse", Utf8Str::CaseInsensitive) 1739 || di.strFormat.compare("http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized", Utf8Str::CaseInsensitive) 1740 || di.strFormat.compare("http://www.vmware.com/specifications/vmdk.html#compressed", Utf8Str::CaseInsensitive) 1741 || di.strFormat.compare("http://www.vmware.com/interfaces/specifications/vmdk.html#compressed", Utf8Str::CaseInsensitive) 1742 ) 1743 strSrcFormat = "VMDK"; 1744 format = pSysProps->mediumFormat(strSrcFormat); 1745 if (format.isNull()) 1746 throw setError(VBOX_E_NOT_SUPPORTED, 1747 tr("Could not find a valid medium format for the source disk '%s'"), 1748 RTPathFilename(strSrcFilePath.c_str())); 1749 } 1724 /* We need a proper source format description */ 1725 ComObjPtr<MediumFormat> srcFormat; 1726 /* Which format to use? */ 1727 Utf8Str strSrcFormat = "VDI"; 1728 if ( di.strFormat.compare("http://www.vmware.com/specifications/vmdk.html#sparse", Utf8Str::CaseInsensitive) 1729 || di.strFormat.compare("http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized", Utf8Str::CaseInsensitive) 1730 || di.strFormat.compare("http://www.vmware.com/specifications/vmdk.html#compressed", Utf8Str::CaseInsensitive) 1731 || di.strFormat.compare("http://www.vmware.com/interfaces/specifications/vmdk.html#compressed", Utf8Str::CaseInsensitive) 1732 ) 1733 strSrcFormat = "VMDK"; 1734 srcFormat = pSysProps->mediumFormat(strSrcFormat); 1735 if (srcFormat.isNull()) 1736 throw setError(VBOX_E_NOT_SUPPORTED, 1737 tr("Could not find a valid medium format for the source disk '%s'"), 1738 RTPathFilename(strSrcFilePath.c_str())); 1750 1739 1751 1740 /* Clone the source disk image */ 1752 1741 ComObjPtr<Medium> nullParent; 1753 1742 rc = pTargetHD->importFile(strSrcFilePath.c_str(), 1754 format,1743 srcFormat, 1755 1744 MediumVariant_Standard, 1756 1745 pCallbacks, pStorage, … … 1758 1747 pProgress); 1759 1748 1760 /* Advance to the next operation */1749 /* Advance to the next operation. */ 1761 1750 stack.pProgress->SetNextOperation(BstrFmt(tr("Importing virtual disk image '%s'"), RTPathFilename(strSrcFilePath.c_str())).raw(), 1762 1751 di.ulSuggestedSizeMB); // operation's weight, as set up with the IProgress originally); 1763 1752 } 1764 1753 1765 // now wait for the background disk operation to complete; this throws HRESULTs on error 1754 /* Now wait for the background disk operation to complete; this throws 1755 * HRESULTs on error. */ 1766 1756 ComPtr<IProgress> pp(pProgress); 1767 1757 waitForAsyncProgress(stack.pProgress, pp); 1768 1758 1759 /* Add the newly create disk path + a corresponding digest the our list for 1760 * later manifest verification. */ 1769 1761 stack.llSrcDisksDigest.push_back(STRPAIR(strSrcFilePath, pStorage->strDigest)); 1770 1762 }
Note:
See TracChangeset
for help on using the changeset viewer.