Changeset 19037 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Apr 20, 2009 3:56:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r19026 r19037 440 440 if (fModifyCompact) 441 441 { 442 #if 1 443 RTPrintf("Error: Compact hard disk operation is not implemented!\n"); 444 RTPrintf("The functionality will be restored later.\n"); 445 return 1; 446 #else 442 bool unknown = false; 447 443 /* the hard disk image might not be registered */ 448 444 if (!hardDisk) 449 445 { 450 a->virtualBox->OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam()); 451 if (!hardDisk) 452 return errorArgument("Hard disk image not found"); 453 } 454 455 /** @todo implement compacting of images. */ 456 #endif 446 unknown = true; 447 rc = a->virtualBox->OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam()); 448 if (rc == VBOX_E_FILE_ERROR) 449 { 450 char szFilenameAbs[RTPATH_MAX] = ""; 451 int vrc = RTPathAbs(FilenameOrUuid, szFilenameAbs, sizeof(szFilenameAbs)); 452 if (RT_FAILURE(vrc)) 453 { 454 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", FilenameOrUuid); 455 return 1; 456 } 457 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, hardDisk.asOutParam())); 458 } 459 else if (FAILED(rc)) 460 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam())); 461 } 462 if (SUCCEEDED(rc) && hardDisk) 463 { 464 ComPtr<IProgress> progress; 465 CHECK_ERROR(hardDisk, Compact(progress.asOutParam())); 466 showProgress(progress); 467 progress->COMGETTER(ResultCode)(&rc); 468 if (FAILED(rc)) 469 { 470 if (rc == VBOX_E_NOT_SUPPORTED) 471 { 472 RTPrintf("Error: Compact hard disk operation is not implemented!\n"); 473 RTPrintf("The functionality will be restored later.\n"); 474 } 475 else if (rc == E_NOTIMPL) 476 { 477 RTPrintf("Error: Compact hard disk operation for this format is not implemented yet!\n"); 478 } 479 else 480 com::GluePrintRCMessage(rc); 481 } 482 if (unknown) 483 hardDisk->Close(); 484 } 457 485 } 458 486 … … 557 585 { 558 586 rc = a->virtualBox->FindHardDisk(src, srcDisk.asOutParam()); 559 /* no? well, then it's an unk wnown image */587 /* no? well, then it's an unknown image */ 560 588 if (FAILED (rc)) 561 589 { 562 CHECK_ERROR(a->virtualBox, OpenHardDisk(src, AccessMode_ReadWrite, srcDisk.asOutParam())); 590 rc = a->virtualBox->OpenHardDisk(src, AccessMode_ReadWrite, srcDisk.asOutParam()); 591 if (rc == VBOX_E_FILE_ERROR) 592 { 593 char szFilenameAbs[RTPATH_MAX] = ""; 594 int vrc = RTPathAbs(Utf8Str(src), szFilenameAbs, sizeof(szFilenameAbs)); 595 if (RT_FAILURE(vrc)) 596 { 597 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", Utf8Str(src).raw()); 598 return 1; 599 } 600 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, srcDisk.asOutParam())); 601 } 602 else if (FAILED(rc)) 603 CHECK_ERROR(a->virtualBox, OpenHardDisk(src, AccessMode_ReadWrite, srcDisk.asOutParam())); 563 604 if (SUCCEEDED (rc)) 564 605 { … … 1061 1102 if (FAILED (rc)) 1062 1103 { 1063 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam())); 1104 rc = a->virtualBox->OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam()); 1105 if (rc == VBOX_E_FILE_ERROR) 1106 { 1107 char szFilenameAbs[RTPATH_MAX] = ""; 1108 int vrc = RTPathAbs(FilenameOrUuid, szFilenameAbs, sizeof(szFilenameAbs)); 1109 if (RT_FAILURE(vrc)) 1110 { 1111 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", FilenameOrUuid); 1112 return 1; 1113 } 1114 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, hardDisk.asOutParam())); 1115 } 1116 else if (FAILED(rc)) 1117 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam())); 1064 1118 if (SUCCEEDED (rc)) 1065 1119 {
Note:
See TracChangeset
for help on using the changeset viewer.