- Timestamp:
- Sep 26, 2008 6:23:12 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 37117
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r12775 r12776 1520 1520 AssertRC(vrc); 1521 1521 1522 /* Try to determine input image format */ 1523 if (srcformat.isEmpty()) 1524 { 1525 char *pszFormat = NULL; 1526 vrc = VDGetFormat(Utf8Str(src).raw(), &pszFormat); 1522 do 1523 { 1524 /* Try to determine input image format */ 1525 if (srcformat.isEmpty()) 1526 { 1527 char *pszFormat = NULL; 1528 vrc = VDGetFormat(Utf8Str(src).raw(), &pszFormat); 1529 if (VBOX_FAILURE(vrc)) 1530 { 1531 RTPrintf("No file format specified and autodetect failed - please specify format: %Vrc\n", vrc); 1532 break; 1533 } 1534 srcformat = pszFormat; 1535 RTStrFree(pszFormat); 1536 } 1537 1538 vrc = VDCreate(&vdInterfaceError, &pSrcDisk); 1527 1539 if (VBOX_FAILURE(vrc)) 1528 1540 { 1529 RTPrintf("No file format specified and autodetect failed - please specify format: %Vrc\n", vrc); 1530 goto cleanup; 1531 } 1532 srcformat = pszFormat; 1533 RTStrFree(pszFormat); 1534 } 1535 1536 vrc = VDCreate(&vdInterfaceError, &pSrcDisk); 1537 if (VBOX_FAILURE(vrc)) 1538 { 1539 RTPrintf("Error while creating the source virtual disk container: %Vrc\n", vrc); 1540 goto cleanup; 1541 } 1542 1543 /* Open the input image */ 1544 vrc = VDOpen(pSrcDisk, Utf8Str(srcformat).raw(), Utf8Str(src).raw(), VD_OPEN_FLAGS_READONLY, NULL); 1545 if (VBOX_FAILURE(vrc)) 1546 { 1547 RTPrintf("Error while opening the source image: %Vrc\n", vrc); 1548 goto cleanup; 1549 } 1550 1551 /* Output format defaults to VDI */ 1552 if (dstformat.isEmpty()) 1553 dstformat = "VDI"; 1554 1555 vrc = VDCreate(&vdInterfaceError, &pDstDisk); 1556 if (VBOX_FAILURE(vrc)) 1557 { 1558 RTPrintf("Error while creating the destination virtual disk container: %Vrc\n", vrc); 1559 goto cleanup; 1560 } 1561 1562 uint64_t cbSize = VDGetSize(pSrcDisk, VD_LAST_IMAGE); 1563 RTPrintf("Converting image \"%s\" with size %RU64 bytes (%RU64MB)...\n", Utf8Str(src).raw(), cbSize, (cbSize + _1M - 1) / _1M); 1564 1565 /* Create the output image */ 1566 vrc = VDCopy(pSrcDisk, VD_LAST_IMAGE, pDstDisk, Utf8Str(dstformat).raw(), 1567 Utf8Str(dst).raw(), false, 0, NULL, NULL, NULL); 1568 if (VBOX_FAILURE(vrc)) 1569 { 1570 RTPrintf("Error while copying the image: %Vrc\n", vrc); 1571 } 1572 1573 cleanup: 1541 RTPrintf("Error while creating the source virtual disk container: %Vrc\n", vrc); 1542 break; 1543 } 1544 1545 /* Open the input image */ 1546 vrc = VDOpen(pSrcDisk, Utf8Str(srcformat).raw(), Utf8Str(src).raw(), VD_OPEN_FLAGS_READONLY, NULL); 1547 if (VBOX_FAILURE(vrc)) 1548 { 1549 RTPrintf("Error while opening the source image: %Vrc\n", vrc); 1550 break; 1551 } 1552 1553 /* Output format defaults to VDI */ 1554 if (dstformat.isEmpty()) 1555 dstformat = "VDI"; 1556 1557 vrc = VDCreate(&vdInterfaceError, &pDstDisk); 1558 if (VBOX_FAILURE(vrc)) 1559 { 1560 RTPrintf("Error while creating the destination virtual disk container: %Vrc\n", vrc); 1561 break; 1562 } 1563 1564 uint64_t cbSize = VDGetSize(pSrcDisk, VD_LAST_IMAGE); 1565 RTPrintf("Converting image \"%s\" with size %RU64 bytes (%RU64MB)...\n", Utf8Str(src).raw(), cbSize, (cbSize + _1M - 1) / _1M); 1566 1567 /* Create the output image */ 1568 vrc = VDCopy(pSrcDisk, VD_LAST_IMAGE, pDstDisk, Utf8Str(dstformat).raw(), 1569 Utf8Str(dst).raw(), false, 0, NULL, NULL, NULL); 1570 if (VBOX_FAILURE(vrc)) 1571 { 1572 RTPrintf("Error while copying the image: %Vrc\n", vrc); 1573 break; 1574 } 1575 } 1576 while (0); 1577 1574 1578 if (pDstDisk) 1575 1579 VDCloseAll(pDstDisk); 1576 1580 if (pSrcDisk) 1577 1581 VDCloseAll(pSrcDisk); 1582 1578 1583 return VBOX_SUCCESS(vrc) ? 0 : 1; 1579 1584 }
Note:
See TracChangeset
for help on using the changeset viewer.