Changeset 40684 in vbox for trunk/src/VBox
- Timestamp:
- Mar 28, 2012 2:41:08 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 77138
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r40398 r40684 401 401 } 402 402 403 static int ctrlPrintProgressError(ComPtr<IProgress> progress) 404 { 405 int rc; 406 BOOL fCanceled; 407 if ( SUCCEEDED(progress->COMGETTER(Canceled(&fCanceled))) 408 && fCanceled) 409 { 410 rc = VERR_CANCELLED; 411 } 412 else 413 { 414 com::ProgressErrorInfo ErrInfo(progress); 415 rc = ctrlPrintError(ErrInfo); 416 } 417 return rc; 403 static int ctrlPrintProgressError(ComPtr<IProgress> pProgress) 404 { 405 int vrc = VINF_SUCCESS; 406 HRESULT rc; 407 408 do 409 { 410 BOOL fCanceled; 411 CHECK_ERROR_BREAK(pProgress, COMGETTER(Canceled)(&fCanceled)); 412 if (!fCanceled) 413 { 414 LONG rcProc; 415 CHECK_ERROR_BREAK(pProgress, COMGETTER(ResultCode)(&rcProc)); 416 if (FAILED(rcProc)) 417 vrc = ctrlPrintError(com::ProgressErrorInfo(pProgress)); 418 } 419 420 } while(0); 421 422 if (FAILED(rc)) 423 AssertMsgStmt(NULL, ("Could not lookup progress information\n"), vrc = VERR_COM_UNEXPECTED); 424 425 return vrc; 418 426 } 419 427 … … 1111 1119 1112 1120 bool fDirExists; 1113 int rc = ctrlCopyDirExists(pContext, pContext->fHostToGuest, pszDir, &fDirExists);1114 if ( RT_SUCCESS( rc)1121 int vrc = ctrlCopyDirExists(pContext, pContext->fHostToGuest, pszDir, &fDirExists); 1122 if ( RT_SUCCESS(vrc) 1115 1123 && fDirExists) 1116 1124 { … … 1120 1128 } 1121 1129 1130 /* If querying for a directory existence fails there's no point of even trying 1131 * to create such a directory. */ 1132 if (RT_FAILURE(vrc)) 1133 return vrc; 1134 1122 1135 if (pContext->fVerbose) 1123 1136 RTPrintf("Creating directory \"%s\" ...\n", pszDir); … … 1128 1141 if (pContext->fHostToGuest) /* We want to create directories on the guest. */ 1129 1142 { 1130 HRESULT hrc = pContext->pGuest->DirectoryCreate(Bstr(pszDir).raw(),1131 1132 1133 if (FAILED( hrc))1134 rc = ctrlPrintError(pContext->pGuest, COM_IIDOF(IGuest));1143 HRESULT rc = pContext->pGuest->DirectoryCreate(Bstr(pszDir).raw(), 1144 Bstr(pContext->pszUsername).raw(), Bstr(pContext->pszPassword).raw(), 1145 0700, DirectoryCreateFlag_Parents); 1146 if (FAILED(rc)) 1147 vrc = ctrlPrintError(pContext->pGuest, COM_IIDOF(IGuest)); 1135 1148 } 1136 1149 else /* ... or on the host. */ 1137 1150 { 1138 rc = RTDirCreateFullPath(pszDir, 0700);1139 if ( rc == VERR_ALREADY_EXISTS)1140 rc = VINF_SUCCESS;1141 } 1142 return rc;1151 vrc = RTDirCreateFullPath(pszDir, 0700); 1152 if (vrc == VERR_ALREADY_EXISTS) 1153 vrc = VINF_SUCCESS; 1154 } 1155 return vrc; 1143 1156 } 1144 1157 … … 1331 1344 else 1332 1345 rc = progress->WaitForCompletion(-1 /* No timeout */); 1333 CHECK_PROGRESS_ERROR(progress, ("File copy failed"));1334 if (FAILED(rc))1335 vrc = ctrlPrintError(pContext->pGuest, COM_IIDOF(IGuest));1346 if (SUCCEEDED(rc)) 1347 CHECK_PROGRESS_ERROR(progress, ("File copy failed")); 1348 vrc = ctrlPrintProgressError(progress); 1336 1349 } 1337 1350 … … 2268 2281 if (!fExists) 2269 2282 { 2270 RTPrintf("Cannot stat for element \"%s\": No such file or directory\n", 2271 it->first.c_str()); 2283 if (fVerbose) 2284 RTPrintf("Cannot stat for element \"%s\": No such file or directory\n", 2285 it->first.c_str()); 2272 2286 rcExit = RTEXITCODE_FAILURE; 2273 2287 } … … 2368 2382 2369 2383 HRESULT rc = S_OK; 2370 ComPtr<IProgress> p rogress;2384 ComPtr<IProgress> pProgress; 2371 2385 CHECK_ERROR(guest, UpdateGuestAdditions(Bstr(Utf8Source).raw(), 2372 2386 /* Wait for whole update process to complete. */ 2373 2387 AdditionsUpdateFlag_None, 2374 p rogress.asOutParam()));2388 pProgress.asOutParam())); 2375 2389 if (FAILED(rc)) 2376 2390 vrc = ctrlPrintError(guest, COM_IIDOF(IGuest)); … … 2378 2392 { 2379 2393 if (fVerbose) 2380 rc = showProgress(p rogress);2394 rc = showProgress(pProgress); 2381 2395 else 2382 rc = progress->WaitForCompletion(-1 /* No timeout */); 2383 CHECK_PROGRESS_ERROR(progress, ("Guest additions update failed")); 2384 if (FAILED(rc)) 2385 vrc = ctrlPrintError(guest, COM_IIDOF(IGuest)); 2386 else if ( SUCCEEDED(rc) 2387 && fVerbose) 2396 rc = pProgress->WaitForCompletion(-1 /* No timeout */); 2397 2398 if (SUCCEEDED(rc)) 2399 CHECK_PROGRESS_ERROR(pProgress, ("Guest additions update failed")); 2400 vrc = ctrlPrintProgressError(pProgress); 2401 if ( RT_SUCCESS(vrc) 2402 && fVerbose) 2388 2403 { 2389 2404 RTPrintf("Guest Additions update successful\n");
Note:
See TracChangeset
for help on using the changeset viewer.