Changeset 99264 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 3, 2023 3:37:08 PM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r99150 r99264 2385 2385 } 2386 2386 2387 static DECLCALLBACK(RTEXITCODE) gctlHandleFsInfo(PGCTLCMDCTX pCtx, int argc, char **argv) 2388 { 2389 AssertPtrReturn(pCtx, RTEXITCODE_FAILURE); 2390 2391 static const RTGETOPTDEF s_aOptions[] = 2392 { 2393 GCTLCMD_COMMON_OPTION_DEFS() 2394 { "--human-readable", 'h', RTGETOPT_REQ_NOTHING } 2395 }; 2396 2397 int ch; 2398 RTGETOPTUNION ValueUnion; 2399 RTGETOPTSTATE GetState; 2400 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST); 2401 2402 bool fHumanReadable = false; 2403 2404 while ( (ch = RTGetOpt(&GetState, &ValueUnion)) != 0 2405 && ch != VINF_GETOPT_NOT_OPTION) 2406 { 2407 /* For options that require an argument, ValueUnion has received the value. */ 2408 switch (ch) 2409 { 2410 GCTLCMD_COMMON_OPTION_CASES(pCtx, ch, &ValueUnion); 2411 2412 case 'h': 2413 fHumanReadable = true; 2414 break; 2415 2416 default: 2417 return errorGetOpt(ch, &ValueUnion); 2418 } 2419 } 2420 2421 if (ch != VINF_GETOPT_NOT_OPTION) 2422 return errorSyntax(GuestCtrl::tr("No path specified to query information for!")); 2423 2424 RTEXITCODE rcExit = gctlCtxPostOptionParsingInit(pCtx); 2425 if (rcExit != RTEXITCODE_SUCCESS) 2426 return rcExit; 2427 2428 /* Stay within 80 characters width by default. */ 2429 unsigned const cwFileSys = 12; 2430 unsigned const cwSize = 16; 2431 unsigned const cwSizeTotal = cwSize; 2432 unsigned const cwSizeUsed = cwSize; 2433 unsigned const cwSizeAvail = cwSize; 2434 unsigned const cwPathSpacing = 6; /* Spacing between last value and actual path. */ 2435 2436 RTPrintf("%-*s%*s%*s%*s%*s%s\n", 2437 cwFileSys, GuestCtrl::tr("Filesystem"), 2438 cwSizeTotal, GuestCtrl::tr("Total"), cwSizeUsed, GuestCtrl::tr("Used"), cwSizeAvail, GuestCtrl::tr("Available"), 2439 cwPathSpacing, "", 2440 GuestCtrl::tr("Path")); 2441 2442 while (ch == VINF_GETOPT_NOT_OPTION) 2443 { 2444 ComPtr<IGuestFsInfo> pFsInfo; 2445 HRESULT hrc; 2446 CHECK_ERROR(pCtx->pGuestSession, FsQueryInfo(Bstr(ValueUnion.psz).raw(), pFsInfo.asOutParam())); 2447 if (FAILED(hrc)) 2448 { 2449 rcExit = RTEXITCODE_FAILURE; 2450 } 2451 else 2452 { 2453 Bstr bstr; 2454 CHECK_ERROR2I(pFsInfo, COMGETTER(Type)(bstr.asOutParam())); 2455 /** @todo Add label and mount point once we return this. */ 2456 LONG64 u64, u64_2; 2457 CHECK_ERROR2I(pFsInfo, COMGETTER(TotalSize)(&u64)); 2458 CHECK_ERROR2I(pFsInfo, COMGETTER(FreeSize)(&u64_2)); 2459 if (fHumanReadable) 2460 { 2461 RTPrintf("%-*ls%*Rhcb%*Rhcb%*Rhcb%*s%s", 2462 cwFileSys, bstr.raw(), /* Filesystem */ 2463 cwSizeTotal, u64, /* Total */ 2464 cwSizeUsed, u64 - u64_2, /* Used */ 2465 cwSizeAvail, u64_2, /* Available */ 2466 cwPathSpacing, "", 2467 ValueUnion.psz); /* Path */ 2468 } 2469 else 2470 { 2471 RTPrintf("%-*ls%*RU64%*RU64%*RU64%*s%s", 2472 cwFileSys, bstr.raw(), /* Filesystem */ 2473 cwSizeTotal, u64, /* Total */ 2474 cwSizeUsed, u64 - u64_2, /* Used */ 2475 cwSizeAvail, u64_2, /* Available */ 2476 cwPathSpacing, "", 2477 ValueUnion.psz); /* Path */ 2478 } 2479 RTPrintf("\n"); 2480 } 2481 2482 /* Next path. */ 2483 ch = RTGetOpt(&GetState, &ValueUnion); 2484 } 2485 2486 return rcExit; 2487 } 2488 2387 2489 static DECLCALLBACK(RTEXITCODE) gctlHandleStat(PGCTLCMDCTX pCtx, int argc, char **argv) 2388 2490 { … … 3610 3712 { "createtemporary", gctlHandleMkTemp, HELP_SCOPE_GUESTCONTROL_MKTEMP, 0 }, 3611 3713 3714 { "df", gctlHandleFsInfo, HELP_SCOPE_GUESTCONTROL_FSINFO, 0 }, 3715 { "fsinfo", gctlHandleFsInfo, HELP_SCOPE_GUESTCONTROL_FSINFO, 0 }, 3716 3612 3717 { "stat", gctlHandleStat, HELP_SCOPE_GUESTCONTROL_STAT, 0 }, 3613 3718
Note:
See TracChangeset
for help on using the changeset viewer.