Changeset 18814 in vbox for trunk/src/VBox
- Timestamp:
- Apr 7, 2009 12:31:20 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 45810
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r18759 r18814 33 33 #include <iprt/asm.h> 34 34 #include <iprt/file.h> 35 #include <iprt/path.h> 36 #include <iprt/param.h> 35 37 #include <iprt/stream.h> 36 38 #include <iprt/string.h> … … 172 174 { 173 175 HRESULT rc; 176 int vrc; 174 177 Bstr filename; 175 178 uint64_t sizeMB = 0; … … 210 213 211 214 case 'm': // --variant 212 rc = parseDiskVariant(ValueUnion.psz, &DiskVariant);213 if (RT_FAILURE( rc))215 vrc = parseDiskVariant(ValueUnion.psz, &DiskVariant); 216 if (RT_FAILURE(vrc)) 214 217 return errorArgument("Invalid hard disk variant '%s'", ValueUnion.psz); 215 218 break; … … 224 227 225 228 case 't': // --type 226 rc = parseDiskType(ValueUnion.psz, &DiskType);227 if ( RT_FAILURE( rc)229 vrc = parseDiskType(ValueUnion.psz, &DiskType); 230 if ( RT_FAILURE(vrc) 228 231 || (DiskType != HardDiskType_Normal && DiskType != HardDiskType_Writethrough)) 229 232 return errorArgument("Invalid hard disk type '%s'", ValueUnion.psz); … … 340 343 { 341 344 HRESULT rc; 345 int vrc; 342 346 ComPtr<IHardDisk> hardDisk; 343 347 HardDiskType_T DiskType; … … 356 360 { 357 361 case 't': // --type 358 rc = parseDiskType(ValueUnion.psz, &DiskType);359 if (RT_FAILURE( rc))362 vrc = parseDiskType(ValueUnion.psz, &DiskType); 363 if (RT_FAILURE(vrc)) 360 364 return errorArgument("Invalid hard disk type '%s'", ValueUnion.psz); 361 365 fModifyDiskType = true; … … 363 367 364 368 case 'z': // --autoreset 365 rc = parseBool(ValueUnion.psz, &AutoReset);366 if (RT_FAILURE( rc))369 vrc = parseBool(ValueUnion.psz, &AutoReset); 370 if (RT_FAILURE(vrc)) 367 371 return errorArgument("Invalid autoreset parameter '%s'", ValueUnion.psz); 368 372 fModifyAutoReset = true; … … 474 478 int handleCloneHardDisk(HandlerArg *a) 475 479 { 480 HRESULT rc; 481 int vrc; 476 482 Bstr src, dst; 477 483 Bstr format; … … 479 485 bool fRemember = false; 480 486 HardDiskType_T DiskType = HardDiskType_Normal; 481 482 HRESULT rc;483 487 484 488 int c; … … 496 500 497 501 case 'm': // --variant 498 rc = parseDiskVariant(ValueUnion.psz, &DiskVariant);499 if (RT_FAILURE( rc))502 vrc = parseDiskVariant(ValueUnion.psz, &DiskVariant); 503 if (RT_FAILURE(vrc)) 500 504 return errorArgument("Invalid hard disk variant '%s'", ValueUnion.psz); 501 505 break; … … 506 510 507 511 case 't': // --type 508 rc = parseDiskType(ValueUnion.psz, &DiskType);509 if (RT_FAILURE( rc))512 vrc = parseDiskType(ValueUnion.psz, &DiskType); 513 if (RT_FAILURE(vrc)) 510 514 return errorArgument("Invalid hard disk type '%s'", ValueUnion.psz); 511 515 break; … … 829 833 { 830 834 HRESULT rc; 835 int vrc; 831 836 Bstr server; 832 837 Bstr target; … … 877 882 878 883 case 't': // --type 879 rc = parseDiskType(ValueUnion.psz, &DiskType);880 if (RT_FAILURE( rc))884 vrc = parseDiskType(ValueUnion.psz, &DiskType); 885 if (RT_FAILURE(vrc)) 881 886 return errorArgument("Invalid hard disk type '%s'", ValueUnion.psz); 882 887 break; … … 1171 1176 { 1172 1177 HRESULT rc = S_OK; 1178 int vrc; 1173 1179 enum { 1174 1180 CMD_NONE, … … 1209 1215 1210 1216 case 't': // --type 1211 rc = parseDiskType(ValueUnion.psz, &DiskType);1212 if (RT_FAILURE( rc))1217 vrc = parseDiskType(ValueUnion.psz, &DiskType); 1218 if (RT_FAILURE(vrc)) 1213 1219 return errorArgument("Invalid hard disk type '%s'", ValueUnion.psz); 1214 1220 fDiskType = true; … … 1245 1251 return errorSyntax(USAGE_OPENMEDIUM, "Disk name required"); 1246 1252 1253 /** @todo remove this hack! 1254 * First try opening the image as is (using the regular API semantics for 1255 * images with relative path or without path), and if that fails with a 1256 * file related error then try it again with what the client thinks the 1257 * relative path would mean. Requires doing the command twice in certain 1258 * cases. This is an ugly hack and needs to be removed whevever we have a 1259 * chance to clean up the API semantics. */ 1247 1260 if (cmd == CMD_DISK) 1248 1261 { 1249 1262 ComPtr<IHardDisk> hardDisk; 1250 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(Filename), AccessMode_ReadWrite, hardDisk.asOutParam())); 1263 rc = a->virtualBox->OpenHardDisk(Bstr(Filename), AccessMode_ReadWrite, hardDisk.asOutParam()); 1264 if (rc == VBOX_E_FILE_ERROR) 1265 { 1266 char szFilenameAbs[RTPATH_MAX] = ""; 1267 int vrc = RTPathAbs(Filename, szFilenameAbs, sizeof(szFilenameAbs)); 1268 if (RT_FAILURE(vrc)) 1269 { 1270 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", Filename); 1271 return 1; 1272 } 1273 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, hardDisk.asOutParam())); 1274 } 1275 else 1276 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(Filename), AccessMode_ReadWrite, hardDisk.asOutParam())); 1251 1277 if (SUCCEEDED(rc) && hardDisk) 1252 1278 { … … 1263 1289 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for DVD images"); 1264 1290 ComPtr<IDVDImage> dvdImage; 1265 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(Filename), Guid(), dvdImage.asOutParam())); 1291 rc = a->virtualBox->OpenDVDImage(Bstr(Filename), Guid(), dvdImage.asOutParam()); 1292 if (rc == VBOX_E_FILE_ERROR) 1293 { 1294 char szFilenameAbs[RTPATH_MAX] = ""; 1295 int vrc = RTPathAbs(Filename, szFilenameAbs, sizeof(szFilenameAbs)); 1296 if (RT_FAILURE(vrc)) 1297 { 1298 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", Filename); 1299 return 1; 1300 } 1301 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(szFilenameAbs), Guid(), dvdImage.asOutParam())); 1302 } 1303 else 1304 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(Filename), Guid(), dvdImage.asOutParam())); 1266 1305 } 1267 1306 else if (cmd == CMD_FLOPPY) … … 1270 1309 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for DVD images"); 1271 1310 ComPtr<IFloppyImage> floppyImage; 1272 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(Filename), Guid(), floppyImage.asOutParam())); 1311 rc = a->virtualBox->OpenFloppyImage(Bstr(Filename), Guid(), floppyImage.asOutParam()); 1312 if (rc == VBOX_E_FILE_ERROR) 1313 { 1314 char szFilenameAbs[RTPATH_MAX] = ""; 1315 int vrc = RTPathAbs(Filename, szFilenameAbs, sizeof(szFilenameAbs)); 1316 if (RT_FAILURE(vrc)) 1317 { 1318 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", Filename); 1319 return 1; 1320 } 1321 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(szFilenameAbs), Guid(), floppyImage.asOutParam())); 1322 } 1323 else 1324 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(Filename), Guid(), floppyImage.asOutParam())); 1273 1325 } 1274 1326
Note:
See TracChangeset
for help on using the changeset viewer.