Changeset 10002 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Jun 27, 2008 4:03:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r10000 r10002 528 528 if (u64Cmd & USAGE_CONVERTDD) 529 529 { 530 RTPrintf("VBoxManage convertdd <filename> <outputfile>\n"531 "VBoxManage convertdd stdin <outputfile> <bytes>\n"530 RTPrintf("VBoxManage convertdd [-static] <filename> <outputfile>\n" 531 "VBoxManage convertdd [-static] stdin <outputfile> <bytes>\n" 532 532 "\n"); 533 533 } … … 3349 3349 static int handleConvertDDImage(int argc, char *argv[]) 3350 3350 { 3351 #ifdef RT_OS_LINUX 3352 const bool fReadFromStdIn = (argc >= 1) && !strcmp(argv[0], "stdin"); 3351 int arg = 0; 3352 VDIIMAGETYPE enmImgType = VDI_IMAGE_TYPE_NORMAL; 3353 if (argc >= 1 && !strcmp(argv[arg], "-static")) 3354 { 3355 arg++; 3356 enmImgType = VDI_IMAGE_TYPE_FIXED; 3357 } 3358 3359 #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) 3360 const bool fReadFromStdIn = (argc >= arg + 1) && !strcmp(argv[arg], "stdin"); 3353 3361 #else 3354 3362 const bool fReadFromStdIn = false; 3355 3363 #endif 3356 3364 3357 if ((!fReadFromStdIn && argc != 2) || (fReadFromStdIn && argc !=3))3365 if ((!fReadFromStdIn && argc != arg + 2) || (fReadFromStdIn && argc != arg + 3)) 3358 3366 return errorSyntax(USAGE_CONVERTDD, "Incorrect number of parameters"); 3359 3367 3360 3368 RTPrintf("Converting VDI: from DD image file=\"%s\" to file=\"%s\"...\n", 3361 argv[ 0], argv[1]);3369 argv[arg], argv[arg + 1]); 3362 3370 3363 3371 /* open raw image file. */ … … 3367 3375 File = 0; 3368 3376 else 3369 rc = RTFileOpen(&File, argv[ 0], RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);3377 rc = RTFileOpen(&File, argv[arg], RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE); 3370 3378 if (VBOX_FAILURE(rc)) 3371 3379 { 3372 RTPrintf("File=\"%s\" open error: %Rrf\n", argv[ 0], rc);3380 RTPrintf("File=\"%s\" open error: %Rrf\n", argv[arg], rc); 3373 3381 return rc; 3374 3382 } … … 3377 3385 /* get image size. */ 3378 3386 if (fReadFromStdIn) 3379 cbFile = RTStrToUInt64(argv[ 2]);3387 cbFile = RTStrToUInt64(argv[arg + 2]); 3380 3388 else 3381 3389 rc = RTFileGetSize(File, &cbFile); 3382 3390 if (VBOX_SUCCESS(rc)) 3383 3391 { 3384 RTPrintf("Creating fixed image with size %RU64 bytes (%RU64MB)...\n", cbFile, (cbFile + _1M - 1) / _1M);3392 RTPrintf("Creating %s image with size %RU64 bytes (%RU64MB)...\n", (enmImgType == VDI_IMAGE_TYPE_FIXED) ? "fixed" : "dynamic", cbFile, (cbFile + _1M - 1) / _1M); 3385 3393 char pszComment[256]; 3386 RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", argv[ 0]);3387 rc = VDICreateBaseImage(argv[ 1],3388 VDI_IMAGE_TYPE_FIXED,3394 RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", argv[arg]); 3395 rc = VDICreateBaseImage(argv[arg + 1], 3396 enmImgType, 3389 3397 cbFile, 3390 3398 pszComment, NULL, NULL); … … 3392 3400 { 3393 3401 PVDIDISK pVdi = VDIDiskCreate(); 3394 rc = VDIDiskOpenImage(pVdi, argv[ 1], VDI_OPEN_FLAGS_NORMAL);3402 rc = VDIDiskOpenImage(pVdi, argv[arg + 1], VDI_OPEN_FLAGS_NORMAL); 3395 3403 if (VBOX_SUCCESS(rc)) 3396 3404 { … … 3427 3435 /* delete image on error */ 3428 3436 RTPrintf("Failed (%Vrc)!\n", rc); 3429 VDIDeleteImage(argv[ 1]);3437 VDIDeleteImage(argv[arg + 1]); 3430 3438 } 3431 3439 }
Note:
See TracChangeset
for help on using the changeset viewer.