- Timestamp:
- Mar 27, 2009 2:06:29 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r18072 r18396 67 67 #endif /* !VBOX_ONLY_DOCS */ 68 68 69 // funcs 70 /////////////////////////////////////////////////////////////////////////////// 69 //////////////////////////////////////////////////////////////////////////////// 70 // 71 // global variables 72 // 73 //////////////////////////////////////////////////////////////////////////////// 74 75 /*extern*/ bool g_fDetailedProgress = false; 76 77 //////////////////////////////////////////////////////////////////////////////// 78 // 79 // functions 80 // 81 //////////////////////////////////////////////////////////////////////////////// 82 83 #ifndef VBOX_ONLY_DOCS 84 /** 85 * Print out progress on the console 86 */ 87 void showProgress(ComPtr<IProgress> progress) 88 { 89 BOOL fCompleted; 90 ULONG ulCurrentPercent; 91 ULONG ulLastPercent = 0; 92 93 ULONG ulCurrentOperationPercent; 94 ULONG ulLastOperationPercent; 95 96 ULONG ulLastOperation = (ULONG)-1; 97 Bstr bstrOperationDescription; 98 99 ULONG cOperations; 100 progress->COMGETTER(OperationCount)(&cOperations); 101 102 if (!g_fDetailedProgress) 103 { 104 RTPrintf("0%%..."); 105 RTStrmFlush(g_pStdOut); 106 } 107 108 while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted)))) 109 { 110 ULONG ulOperation; 111 progress->COMGETTER(Operation)(&ulOperation); 112 113 progress->COMGETTER(Percent(&ulCurrentPercent)); 114 progress->COMGETTER(OperationPercent(&ulCurrentOperationPercent)); 115 116 if (g_fDetailedProgress) 117 { 118 if (ulLastOperation != ulOperation) 119 { 120 progress->COMGETTER(OperationDescription(bstrOperationDescription.asOutParam())); 121 ulLastPercent = (ULONG)-1; // force print 122 ulLastOperation = ulOperation; 123 } 124 125 if ( (ulCurrentPercent != ulLastPercent) 126 || (ulCurrentOperationPercent != ulLastOperationPercent) 127 ) 128 { 129 RTPrintf("(%ld/%ld) %ls %ld%% => %ld%%\n", ulOperation + 1, cOperations, bstrOperationDescription.raw(), ulCurrentOperationPercent, ulCurrentPercent); 130 ulLastPercent = ulCurrentPercent; 131 ulLastOperationPercent = ulCurrentOperationPercent; 132 } 133 } 134 else 135 { 136 /* did we cross a 10% mark? */ 137 if (((ulCurrentPercent / 10) > (ulLastPercent / 10))) 138 { 139 /* make sure to also print out missed steps */ 140 for (ULONG curVal = (ulLastPercent / 10) * 10 + 10; curVal <= (ulCurrentPercent / 10) * 10; curVal += 10) 141 { 142 if (curVal < 100) 143 { 144 RTPrintf("%ld%%...", curVal); 145 RTStrmFlush(g_pStdOut); 146 } 147 } 148 ulLastPercent = (ulCurrentPercent / 10) * 10; 149 } 150 } 151 if (fCompleted) 152 break; 153 154 /* make sure the loop is not too tight */ 155 progress->WaitForCompletion(100); 156 } 157 158 /* complete the line. */ 159 HRESULT rc; 160 if (SUCCEEDED(progress->COMGETTER(ResultCode)(&rc))) 161 { 162 if (SUCCEEDED(rc)) 163 RTPrintf("100%%\n"); 164 else 165 RTPrintf("FAILED\n"); 166 } 167 else 168 RTPrintf("\n"); 169 RTStrmFlush(g_pStdOut); 170 } 171 #endif /* !VBOX_ONLY_DOCS */ 71 172 72 173 void showLogo(void) -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r18023 r18396 36 36 # define USE_XPCOM_QUEUE 37 37 #endif 38 39 //////////////////////////////////////////////////////////////////////////////// 40 // 41 // definitions 42 // 43 //////////////////////////////////////////////////////////////////////////////// 38 44 39 45 /** @name Syntax diagram category. … … 124 130 } VMINFO_DETAILS; 125 131 126 /* 127 * Prototypes 128 */ 132 //////////////////////////////////////////////////////////////////////////////// 133 // 134 // global variables 135 // 136 //////////////////////////////////////////////////////////////////////////////// 137 138 extern bool g_fDetailedProgress; // in VBoxManage.cpp 139 140 //////////////////////////////////////////////////////////////////////////////// 141 // 142 // prototypes 143 // 144 //////////////////////////////////////////////////////////////////////////////// 129 145 130 146 /* VBoxManageHelp.cpp */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r18270 r18396 554 554 } 555 555 556 #ifndef VBOX_ONLY_DOCS557 /**558 * Print out progress on the console559 */560 void showProgress(ComPtr<IProgress> progress)561 {562 BOOL fCompleted;563 ULONG currentPercent;564 ULONG lastPercent = 0;565 566 RTPrintf("0%%...");567 RTStrmFlush(g_pStdOut);568 while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted))))569 {570 progress->COMGETTER(Percent(¤tPercent));571 572 /* did we cross a 10% mark? */573 if (((currentPercent / 10) > (lastPercent / 10)))574 {575 /* make sure to also print out missed steps */576 for (ULONG curVal = (lastPercent / 10) * 10 + 10; curVal <= (currentPercent / 10) * 10; curVal += 10)577 {578 if (curVal < 100)579 {580 RTPrintf("%ld%%...", curVal);581 RTStrmFlush(g_pStdOut);582 }583 }584 lastPercent = (currentPercent / 10) * 10;585 }586 if (fCompleted)587 break;588 589 /* make sure the loop is not too tight */590 progress->WaitForCompletion(100);591 }592 593 /* complete the line. */594 HRESULT rc;595 if (SUCCEEDED(progress->COMGETTER(ResultCode)(&rc)))596 {597 if (SUCCEEDED(rc))598 RTPrintf("100%%\n");599 else600 RTPrintf("FAILED\n");601 }602 else603 RTPrintf("\n");604 RTStrmFlush(g_pStdOut);605 }606 607 #endif /* !VBOX_ONLY_DOCS */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp
r18337 r18396 104 104 ) 105 105 fExecute = false; 106 else if (strThisArg == "--detailed-progress") 107 g_fDetailedProgress = true; 106 108 else if (strThisArg == "-vsys") 107 109 {
Note:
See TracChangeset
for help on using the changeset viewer.