Changeset 54979 in vbox for trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
- Timestamp:
- Mar 27, 2015 6:56:06 AM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 99240
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r54438 r54979 649 649 Utf8Str strTargetPath = Utf8Str(strMachineFolder); 650 650 strTargetPath.append(RTPATH_DELIMITER).append(di.strHref); 651 /* 652 * Remove last extension from the file name if the file is compressed 653 */ 654 if(di.strCompression.compare("gzip", Utf8Str::CaseInsensitive)==0) 655 { 656 strTargetPath.stripSuffix(); 657 } 658 651 659 i_searchUniqueDiskImageFilePath(strTargetPath); 652 660 … … 682 690 .append(RTPATH_DELIMITER) 683 691 .append(di.strHref); 692 /* 693 * Remove last extension from the file name if the file is compressed 694 */ 695 if(di.strCompression.compare("gzip", Utf8Str::CaseInsensitive)==0) 696 { 697 strTargetPath.stripSuffix(); 698 } 699 684 700 i_searchUniqueDiskImageFilePath(strTargetPath); 685 701 … … 2381 2397 /* Decompress the GZIP file and save a new file in the target path */ 2382 2398 strTargetDir = strTargetDir.stripFilename(); 2383 strTargetDir.append("/temp_"); 2384 2385 Utf8Str strTempTargetFilename(*strTargetPath); 2399 strTargetDir.append(RTPATH_SLASH_STR); 2400 strTargetDir.append("temp_"); 2401 2402 Utf8Str strTempTargetFilename(strSrcFilePath); 2386 2403 strTempTargetFilename = strTempTargetFilename.stripPath(); 2387 strTempTargetFilename = strTempTargetFilename.stripSuffix();2388 2404 2389 2405 strTargetDir.append(strTempTargetFilename); … … 2412 2428 /* Correct the source and the target with the actual values */ 2413 2429 strSrcFilePath = strTargetDir; 2414 strTargetDir = strTargetDir.stripFilename();2415 strTargetDir.append(RTPATH_SLASH_STR);2416 strTargetDir.append(strTempTargetFilename.c_str());2417 *strTargetPath = strTargetDir.c_str();2418 2430 2419 2431 pRealUsedStorage = &finalStorage; … … 2421 2433 2422 2434 Utf8Str strTrgFormat = "VMDK"; 2435 ComObjPtr<MediumFormat> trgFormat; 2436 Bstr bstrFormatName; 2423 2437 ULONG lCabs = 0; 2424 2438 2425 if (RTPathHasSuffix(strTargetPath->c_str())) 2426 { 2427 const char *pszSuff = RTPathSuffix(strTargetPath->c_str()); 2428 /* Figure out which format the user like to have. Default is VMDK. */ 2429 ComObjPtr<MediumFormat> trgFormat = pSysProps->i_mediumFormatFromExtension(&pszSuff[1]); 2439 //check existence of option "ImportToVDI", in this case all imported disks will be converted to VDI images 2440 bool chExt = m->optListImport.contains(ImportOptions_ImportToVDI); 2441 2442 char *pszSuff = NULL; 2443 2444 if ((pszSuff = RTPathSuffix(strTargetPath->c_str()))!=NULL) 2445 { 2446 /* 2447 * Figure out which format the user like to have. Default is VMDK 2448 * or it can be VDI if according command-line option is set 2449 */ 2450 2451 /* 2452 * We need a proper target format 2453 * if target format has been changed by user via GUI import wizard 2454 * or via VBoxManage import command (option --importtovdi) 2455 * then we need properly process such format like ISO 2456 * Because there is no conversion ISO to VDI 2457 */ 2458 2459 pszSuff++; 2460 trgFormat = pSysProps->i_mediumFormatFromExtension(pszSuff); 2430 2461 if (trgFormat.isNull()) 2431 throw setError(VBOX_E_NOT_SUPPORTED, 2432 tr("Could not find a valid medium format for the target disk '%s'"), 2433 strTargetPath->c_str()); 2462 { 2463 rc = setError(E_FAIL, 2464 tr("Internal inconsistency looking up medium format for the disk image '%s'"), 2465 di.strHref.c_str()); 2466 } 2467 2468 rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 2469 if (FAILED(rc)) throw rc; 2470 2471 strTrgFormat = Utf8Str(bstrFormatName); 2472 2473 if(chExt && strTrgFormat.compare("RAW", Utf8Str::CaseInsensitive) != 0) 2474 { 2475 /* change the target extension */ 2476 strTrgFormat = "vdi"; 2477 trgFormat = pSysProps->i_mediumFormatFromExtension(strTrgFormat); 2478 *strTargetPath = strTargetPath->stripSuffix(); 2479 *strTargetPath = strTargetPath->append("."); 2480 *strTargetPath = strTargetPath->append(strTrgFormat.c_str()); 2481 } 2482 2434 2483 /* Check the capabilities. We need create capabilities. */ 2435 2484 lCabs = 0; … … 2450 2499 tr("Could not find a valid medium format for the target disk '%s'"), 2451 2500 strTargetPath->c_str()); 2452 Bstr bstrFormatName;2453 rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam());2454 if (FAILED(rc)) throw rc;2455 strTrgFormat = Utf8Str(bstrFormatName);2456 2501 } 2457 2502 else … … 3808 3853 Utf8Str savedVBoxCurrent = vsdeTargetHD->strVBoxCurrent; 3809 3854 ComObjPtr<Medium> pTargetHD; 3855 3810 3856 i_importOneDiskImage(diCurrent, 3811 3857 &vsdeTargetHD->strVBoxCurrent,
Note:
See TracChangeset
for help on using the changeset viewer.