Changeset 39418 in vbox for trunk/src/VBox/Main/src-client/GuestCtrlImplTasks.cpp
- Timestamp:
- Nov 25, 2011 10:11:06 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestCtrlImplTasks.cpp
r38627 r39418 522 522 * actual copying, start the guest part now. 523 523 */ 524 rc = pGuest->ExecuteProcess(Bstr(VBOXSERVICE_TOOL_CAT).raw(), 525 ExecuteProcessFlag_Hidden, 526 ComSafeArrayAsInParam(args), 527 ComSafeArrayAsInParam(env), 528 Bstr(aTask->strUserName).raw(), 529 Bstr(aTask->strPassword).raw(), 530 5 * 1000 /* Wait 5s for getting the process started. */, 531 &uPID, execProgress.asOutParam()); 524 rc = pGuest->executeAndWaitForTool(Bstr(VBOXSERVICE_TOOL_CAT).raw(), 525 Bstr("Copying file to host").raw(), 526 ComSafeArrayAsInParam(args), 527 ComSafeArrayAsInParam(env), 528 Bstr(aTask->strUserName).raw(), 529 Bstr(aTask->strPassword).raw(), 530 ExecuteProcessFlag_WaitForStdOut, 531 NULL, NULL, 532 execProgress.asOutParam(), &uPID); 532 533 if (FAILED(rc)) 533 534 rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest); … … 551 552 size_t cbTransfered = 0; 552 553 SafeArray<BYTE> aOutputData(_64K); 553 while (SUCCEEDED(execProgress->COMGETTER(Completed(&fCompleted)))) 554 { 555 rc = this->GetProcessOutput(uPID, ProcessOutputFlag_None, 556 10 * 1000 /* Timeout in ms */, 557 _64K, ComSafeArrayAsOutParam(aOutputData)); 554 while ( SUCCEEDED(execProgress->COMGETTER(Completed(&fCompleted))) 555 && !fCompleted) 556 { 557 rc = pGuest->GetProcessOutput(uPID, ProcessOutputFlag_None /* StdOut */, 558 0 /* No timeout. */, 559 _64K, ComSafeArrayAsOutParam(aOutputData)); 558 560 if (SUCCEEDED(rc)) 559 561 { 560 if (!aOutputData.size()) 561 { 562 /* 563 * Only bitch about an unexpected end of a file when there already 564 * was data read from that file. If this was the very first read we can 565 * be (almost) sure that this file is not meant to be read by the specified user. 566 */ 567 if ( cbTransfered 568 && cbToRead) 562 if (aOutputData.size()) 563 { 564 vrc = RTFileWrite(hFileDest, aOutputData.raw(), aOutputData.size(), NULL /* No partial writes */); 565 if (RT_FAILURE(vrc)) 569 566 { 570 567 rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress, 571 Guest::tr("Unexpected end of file \"%s\" (%u bytes left, %u bytes written)"), 572 aTask->strSource.c_str(), cbToRead, cbTransfered); 568 Guest::tr("Error writing to file \"%s\" (%u bytes left), rc=%Rrc"), 569 aTask->strSource.c_str(), cbToRead, vrc); 570 break; 573 571 } 574 break; 575 } 576 577 vrc = RTFileWrite(hFileDest, aOutputData.raw(), aOutputData.size(), NULL /* No partial writes */); 578 if (RT_FAILURE(vrc)) 579 { 580 rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress, 581 Guest::tr("Error writing to file \"%s\" (%u bytes left), rc=%Rrc"), 582 aTask->strSource.c_str(), cbToRead, vrc); 583 break; 584 } 585 586 cbToRead -= aOutputData.size(); 587 cbTransfered += aOutputData.size(); 588 589 aTask->progress->SetCurrentOperationProgress(cbTransfered / (lFileSize / 100.0)); 572 573 cbToRead -= aOutputData.size(); 574 Assert(cbToRead >= 0); 575 cbTransfered += aOutputData.size(); 576 577 aTask->progress->SetCurrentOperationProgress(cbTransfered / (lFileSize / 100.0)); 578 } 579 580 /* Nothing read this time; try next round. */ 590 581 } 591 582 else … … 596 587 } 597 588 589 RTFileClose(hFileDest); 590 591 if ( cbTransfered 592 && (cbTransfered != lFileSize)) 593 { 594 /* 595 * Only bitch about an unexpected end of a file when there already 596 * was data read from that file. If this was the very first read we can 597 * be (almost) sure that this file is not meant to be read by the specified user. 598 */ 599 rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress, 600 Guest::tr("Unexpected end of file \"%s\" (%u bytes total, %u bytes transferred)"), 601 aTask->strSource.c_str(), lFileSize, cbTransfered); 602 } 603 598 604 if (SUCCEEDED(rc)) 599 605 aTask->progress->notifyComplete(S_OK); 600 601 RTFileClose(hFileDest);602 606 } 603 607 }
Note:
See TracChangeset
for help on using the changeset viewer.