Changeset 24884 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 23, 2009 6:48:14 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r24590 r24884 288 288 if (SUCCEEDED(rc) && progress) 289 289 { 290 showProgress(progress);291 if ( SUCCEEDED(rc))290 rc = showProgress(progress); 291 if (FAILED(rc)) 292 292 { 293 LONG iRc; 294 progress->COMGETTER(ResultCode)(&iRc); 295 rc = iRc; 296 if (FAILED(rc)) 293 com::ProgressErrorInfo info(progress); 294 if (info.isBasicAvailable()) 295 RTPrintf("Error: failed to create hard disk. Error message: %lS\n", info.getText().raw()); 296 else 297 RTPrintf("Error: failed to create hard disk. No error message available!\n"); 298 } 299 else 300 { 301 doClose = !fRemember; 302 303 Bstr uuid; 304 CHECK_ERROR(hardDisk, COMGETTER(Id)(uuid.asOutParam())); 305 306 if (DiskType == MediumType_Writethrough) 297 307 { 298 com::ProgressErrorInfo info(progress); 299 if (info.isBasicAvailable()) 300 RTPrintf("Error: failed to create hard disk. Error message: %lS\n", info.getText().raw()); 301 else 302 RTPrintf("Error: failed to create hard disk. No error message available!\n"); 308 CHECK_ERROR(hardDisk, COMSETTER(Type)(MediumType_Writethrough)); 303 309 } 304 else 305 { 306 doClose = !fRemember; 307 308 Bstr uuid; 309 CHECK_ERROR(hardDisk, COMGETTER(Id)(uuid.asOutParam())); 310 311 if (DiskType == MediumType_Writethrough) 312 { 313 CHECK_ERROR(hardDisk, COMSETTER(Type)(MediumType_Writethrough)); 314 } 315 316 RTPrintf("Disk image created. UUID: %s\n", Utf8Str(uuid).raw()); 317 } 310 311 RTPrintf("Disk image created. UUID: %s\n", Utf8Str(uuid).raw()); 318 312 } 319 313 } … … 482 476 CHECK_ERROR(hardDisk, Compact(progress.asOutParam())); 483 477 if (SUCCEEDED(rc)) 484 { 485 showProgress(progress); 486 LONG iRc; 487 progress->COMGETTER(ResultCode)(&iRc); 488 rc = iRc; 489 } 478 rc = showProgress(progress); 490 479 if (FAILED(rc)) 491 480 { … … 699 688 CHECK_ERROR_BREAK(srcDisk, CloneTo(dstDisk, DiskVariant, NULL, progress.asOutParam())); 700 689 701 showProgress(progress); 702 LONG iRc; 703 progress->COMGETTER(ResultCode)(&iRc); 704 rc = iRc; 690 rc = showProgress(progress); 705 691 if (FAILED(rc)) 706 692 { … … 1440 1426 else if (cmd == CMD_DVD) 1441 1427 { 1442 if (fDiskType || fSet ImageId || fSetParentId)1428 if (fDiskType || fSetParentId) 1443 1429 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for DVD images"); 1430 Bstr ImageIdStr = BstrFmt("%RTuuid", &ImageId); 1444 1431 ComPtr<IMedium> dvdImage; 1445 rc = a->virtualBox->OpenDVDImage(Bstr(Filename), Bstr(), dvdImage.asOutParam());1432 rc = a->virtualBox->OpenDVDImage(Bstr(Filename), ImageIdStr, dvdImage.asOutParam()); 1446 1433 if (rc == VBOX_E_FILE_ERROR) 1447 1434 { … … 1453 1440 return 1; 1454 1441 } 1455 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(szFilenameAbs), Bstr(), dvdImage.asOutParam()));1442 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(szFilenameAbs), ImageIdStr, dvdImage.asOutParam())); 1456 1443 } 1457 1444 else if (FAILED(rc)) 1458 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(Filename), Bstr(), dvdImage.asOutParam()));1445 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(Filename), ImageIdStr, dvdImage.asOutParam())); 1459 1446 } 1460 1447 else if (cmd == CMD_FLOPPY) … … 1462 1449 if (fDiskType || fSetImageId || fSetParentId) 1463 1450 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for floppy images"); 1451 Bstr ImageIdStr = BstrFmt("%RTuuid", &ImageId); 1464 1452 ComPtr<IMedium> floppyImage; 1465 rc = a->virtualBox->OpenFloppyImage(Bstr(Filename), Bstr(), floppyImage.asOutParam());1453 rc = a->virtualBox->OpenFloppyImage(Bstr(Filename), ImageIdStr, floppyImage.asOutParam()); 1466 1454 if (rc == VBOX_E_FILE_ERROR) 1467 1455 { … … 1473 1461 return 1; 1474 1462 } 1475 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(szFilenameAbs), Bstr(), floppyImage.asOutParam()));1463 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(szFilenameAbs), ImageIdStr, floppyImage.asOutParam())); 1476 1464 } 1477 1465 else if (FAILED(rc)) 1478 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(Filename), Bstr(), floppyImage.asOutParam()));1466 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(Filename), ImageIdStr, floppyImage.asOutParam())); 1479 1467 } 1480 1468 … … 1487 1475 { "dvd", 'D', RTGETOPT_REQ_NOTHING }, 1488 1476 { "floppy", 'f', RTGETOPT_REQ_NOTHING }, 1477 { "--delete", 'r', RTGETOPT_REQ_NOTHING }, 1489 1478 }; 1490 1479 … … 1499 1488 } cmd = CMD_NONE; 1500 1489 const char *FilenameOrUuid = NULL; 1490 bool fDelete = false; 1501 1491 1502 1492 int c; … … 1525 1515 return errorSyntax(USAGE_CLOSEMEDIUM, "Only one command can be specified: '%s'", ValueUnion.psz); 1526 1516 cmd = CMD_FLOPPY; 1517 break; 1518 1519 case 'r': // --delete 1520 fDelete = true; 1527 1521 break; 1528 1522 … … 1557 1551 return errorSyntax(USAGE_CLOSEMEDIUM, "Disk name or UUID required"); 1558 1552 1553 ComPtr<IMedium> medium; 1554 1559 1555 /* first guess is that it's a UUID */ 1560 1556 Bstr uuid(FilenameOrUuid); … … 1562 1558 if (cmd == CMD_DISK) 1563 1559 { 1564 ComPtr<IMedium> hardDisk; 1565 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 1560 rc = a->virtualBox->GetHardDisk(uuid, medium.asOutParam()); 1566 1561 /* not a UUID or not registered? Then it must be a filename */ 1567 if (!hardDisk) 1568 { 1569 CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(FilenameOrUuid), hardDisk.asOutParam())); 1570 } 1571 if (SUCCEEDED(rc) && hardDisk) 1572 { 1573 CHECK_ERROR(hardDisk, Close()); 1562 if (!medium) 1563 { 1564 CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(FilenameOrUuid), medium.asOutParam())); 1574 1565 } 1575 1566 } … … 1577 1568 if (cmd == CMD_DVD) 1578 1569 { 1579 ComPtr<IMedium> dvdImage; 1580 rc = a->virtualBox->GetDVDImage(uuid, dvdImage.asOutParam()); 1570 rc = a->virtualBox->GetDVDImage(uuid, medium.asOutParam()); 1581 1571 /* not a UUID or not registered? Then it must be a filename */ 1582 if (!dvdImage) 1583 { 1584 CHECK_ERROR(a->virtualBox, FindDVDImage(Bstr(FilenameOrUuid), dvdImage.asOutParam())); 1585 } 1586 if (SUCCEEDED(rc) && dvdImage) 1587 { 1588 CHECK_ERROR(dvdImage, Close()); 1572 if (!medium) 1573 { 1574 CHECK_ERROR(a->virtualBox, FindDVDImage(Bstr(FilenameOrUuid), medium.asOutParam())); 1589 1575 } 1590 1576 } … … 1592 1578 if (cmd == CMD_FLOPPY) 1593 1579 { 1594 ComPtr<IMedium> floppyImage; 1595 rc = a->virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam()); 1580 rc = a->virtualBox->GetFloppyImage(uuid, medium.asOutParam()); 1596 1581 /* not a UUID or not registered? Then it must be a filename */ 1597 if (!floppyImage) 1598 { 1599 CHECK_ERROR(a->virtualBox, FindFloppyImage(Bstr(FilenameOrUuid), floppyImage.asOutParam())); 1600 } 1601 if (SUCCEEDED(rc) && floppyImage) 1602 { 1603 CHECK_ERROR(floppyImage, Close()); 1604 } 1582 if (!medium) 1583 { 1584 CHECK_ERROR(a->virtualBox, FindFloppyImage(Bstr(FilenameOrUuid), medium.asOutParam())); 1585 } 1586 } 1587 1588 if (SUCCEEDED(rc) && medium) 1589 { 1590 if (fDelete) 1591 { 1592 ComPtr<IProgress> progress; 1593 CHECK_ERROR(medium, DeleteStorage(progress.asOutParam())); 1594 if (SUCCEEDED(rc)) 1595 { 1596 rc = showProgress(progress); 1597 if (FAILED(rc)) 1598 { 1599 com::ProgressErrorInfo info(progress); 1600 if (info.isBasicAvailable()) 1601 RTPrintf("Error: failed to delete medium. Error message: %lS\n", info.getText().raw()); 1602 else 1603 RTPrintf("Error: failed to delete medium. No error message available!\n"); 1604 } 1605 } 1606 else 1607 RTPrintf("Error: failed to delete medium. Error code %Rrc\n", rc); 1608 } 1609 CHECK_ERROR(medium, Close()); 1605 1610 } 1606 1611 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r24874 r24884 343 343 RTPrintf("VBoxManage openmedium disk|dvd|floppy <filename>\n" 344 344 " [--type normal|immutable|writethrough] (disk only)\n" 345 " [--uuid <uuid>]\n" 346 " [--parentuuid <uuid>] (disk only)\n" 345 347 "\n"); 346 348 } … … 349 351 { 350 352 RTPrintf("VBoxManage closemedium disk|dvd|floppy <uuid>|<filename>\n" 353 " [--delete]\n" 351 354 "\n"); 352 355 }
Note:
See TracChangeset
for help on using the changeset viewer.