Changeset 42759 in vbox
- Timestamp:
- Aug 10, 2012 3:53:25 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 79978
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp
r42693 r42759 238 238 || waitRes.mResult == ProcessWaitResult_Timeout) 239 239 { 240 rc = waitRes.mRC; 240 if (RT_FAILURE(waitRes.mRC)) 241 rc = waitRes.mRC; 241 242 break; 242 243 } -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r42758 r42759 534 534 rc = pProcess->waitFor(ProcessWaitForFlag_StdOut, 535 535 30 * 1000 /* Timeout */, waitRes); 536 if ( RT_FAILURE(rc) 537 && ( waitRes.mResult != ProcessWaitResult_StdOut 538 || waitRes.mResult != ProcessWaitResult_Any) 539 ) 536 if ( waitRes.mResult == ProcessWaitResult_StdOut 537 || waitRes.mResult == ProcessWaitResult_Any) 540 538 { 541 break; 542 } 543 544 size_t cbRead; 545 rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf), 546 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf), 547 &cbRead); 548 if (RT_FAILURE(rc)) 549 { 550 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 551 Utf8StrFmt(GuestSession::tr("Reading from file \"%s\" (offset %RU64) failed: %Rrc"), 552 mSource.c_str(), cbWrittenTotal, rc)); 553 break; 554 } 555 556 if (cbRead) 557 { 558 rc = RTFileWrite(fileDest, byBuf, cbRead, NULL /* No partial writes */); 539 size_t cbRead; 540 rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf), 541 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf), 542 &cbRead); 559 543 if (RT_FAILURE(rc)) 560 544 { 561 545 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 562 Utf8StrFmt(GuestSession::tr(" Error writing to file \"%s\" (%RU64 bytes left): %Rrc"),563 m Dest.c_str(), cbToRead, rc));546 Utf8StrFmt(GuestSession::tr("Reading from file \"%s\" (offset %RU64) failed: %Rrc"), 547 mSource.c_str(), cbWrittenTotal, rc)); 564 548 break; 565 549 } 566 550 567 /* Only subtract bytes reported written by the guest. */ 568 Assert(cbToRead >= cbRead); 569 cbToRead -= cbRead; 570 571 /* Update total bytes written to the guest. */ 572 cbWrittenTotal += cbRead; 573 Assert(cbWrittenTotal <= (uint64_t)objData.mObjectSize); 574 575 /* Did the user cancel the operation above? */ 576 if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled))) 577 && fCanceled) 578 break; 579 580 rc = setProgress((ULONG)(cbWrittenTotal / ((uint64_t)objData.mObjectSize / 100.0))); 581 if (RT_FAILURE(rc)) 582 break; 583 584 /* End of file reached? */ 585 if (cbToRead == 0) 586 break; 551 if (cbRead) 552 { 553 rc = RTFileWrite(fileDest, byBuf, cbRead, NULL /* No partial writes */); 554 if (RT_FAILURE(rc)) 555 { 556 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 557 Utf8StrFmt(GuestSession::tr("Error writing to file \"%s\" (%RU64 bytes left): %Rrc"), 558 mDest.c_str(), cbToRead, rc)); 559 break; 560 } 561 562 /* Only subtract bytes reported written by the guest. */ 563 Assert(cbToRead >= cbRead); 564 cbToRead -= cbRead; 565 566 /* Update total bytes written to the guest. */ 567 cbWrittenTotal += cbRead; 568 Assert(cbWrittenTotal <= (uint64_t)objData.mObjectSize); 569 570 /* Did the user cancel the operation above? */ 571 if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled))) 572 && fCanceled) 573 break; 574 575 rc = setProgress((ULONG)(cbWrittenTotal / ((uint64_t)objData.mObjectSize / 100.0))); 576 if (RT_FAILURE(rc)) 577 break; 578 } 579 } 580 else if ( RT_FAILURE(rc) 581 || waitRes.mResult == ProcessWaitResult_Terminate 582 || waitRes.mResult == ProcessWaitResult_Error 583 || waitRes.mResult == ProcessWaitResult_Timeout) 584 { 585 if (RT_FAILURE(waitRes.mRC)) 586 rc = waitRes.mRC; 587 break; 587 588 } 588 589 } /* for */ 590 591 LogFlowThisFunc(("rc=%Rrc, cbWrittenTotal=%RU64, cbSize=%RI64, cbToRead=%RU64\n", 592 rc, cbWrittenTotal, objData.mObjectSize, cbToRead)); 589 593 590 594 if ( !fCanceled … … 600 604 /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write 601 605 * to the destination -> access denied. */ 602 rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, 603 Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""), 604 mSource.c_str(), mDest.c_str())); 606 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 607 Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""), 608 mSource.c_str(), mDest.c_str())); 609 rc = VERR_GENERAL_FAILURE; /* Fudge. */ 605 610 } 606 611 else if (cbWrittenTotal < (uint64_t)objData.mObjectSize) 607 612 { 608 613 /* If we did not copy all let the user know. */ 609 rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, 610 Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RU64 bytes transfered)"), 611 mSource.c_str(), cbWrittenTotal, objData.mObjectSize)); 614 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 615 Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RI64 bytes transfered)"), 616 mSource.c_str(), cbWrittenTotal, objData.mObjectSize)); 617 rc = VERR_GENERAL_FAILURE; /* Fudge. */ 612 618 } 613 619 else … … 621 627 ) 622 628 { 623 rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, 624 Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %d"), 625 mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */ 629 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 630 Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %d"), 631 mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */ 632 rc = VERR_GENERAL_FAILURE; /* Fudge. */ 626 633 } 627 634 else /* Yay, success! */
Note:
See TracChangeset
for help on using the changeset viewer.