Changeset 97448 in vbox for trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
- Timestamp:
- Nov 8, 2022 10:09:13 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 154453
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r97446 r97448 496 496 * Copies a file from the guest to the host. 497 497 * 498 * @return VBox status code. 499 * @retval VWRN_ALREADY_EXISTS if the file already exists and FileCopyFlag_NoReplace is specified, 500 * *or * the file at the destination has the same (or newer) modification time 501 * and FileCopyFlag_Update is specified. 498 502 * @param strSrc Full path of source file on the guest to copy. 499 503 * @param strDst Full destination path and file name (host style) to copy file to. … … 579 583 if (fFileCopyFlags & FileCopyFlag_NoReplace) 580 584 { 581 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 582 Utf8StrFmt(tr("Host file \"%s\" already exists"), strDst.c_str())); 583 vrc = VERR_ALREADY_EXISTS; 584 } 585 586 if (fFileCopyFlags & FileCopyFlag_Update) 585 LogRel2(("Guest Control: Host file \"%s\" already exists, skipping", strDst.c_str())); 586 vrc = VWRN_ALREADY_EXISTS; 587 fSkip = true; 588 } 589 590 if ( !fSkip 591 && fFileCopyFlags & FileCopyFlag_Update) 587 592 { 588 593 RTTIMESPEC srcModificationTimeTS; … … 591 596 { 592 597 LogRel2(("Guest Control: Host file \"%s\" has same or newer modification date, skipping", strDst.c_str())); 598 vrc = VWRN_ALREADY_EXISTS; 593 599 fSkip = true; 594 600 } … … 601 607 else if (vrc != VERR_FILE_NOT_FOUND) /* Ditto. */ 602 608 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 603 Utf8StrFmt(tr("Host destinationfile lookup for \"%s\" failed: %Rrc"), strDst.c_str(), vrc));609 Utf8StrFmt(tr("Host file lookup for \"%s\" failed: %Rrc"), strDst.c_str(), vrc)); 604 610 } 605 611 } … … 609 615 int vrc2 = srcFile->i_closeFile(&vrcGuest); 610 616 AssertRC(vrc2); 611 return VINF_SUCCESS;617 return vrc; 612 618 } 613 619 … … 642 648 } 643 649 644 LogRel2(("Guest Control: Copying file '%s' from guest to '%s' on host ...\n", strSrc.c_str(), strDst.c_str()));645 646 650 LogFlowFunc(("vrc=%Rrc, dstFsType=%#x, pszDstFile=%s\n", vrc, dstObjInfo.Attr.fMode & RTFS_TYPE_MASK, strDst.c_str())); 647 651 … … 649 653 || vrc == VERR_FILE_NOT_FOUND) 650 654 { 655 LogRel2(("Guest Control: Copying file '%s' from guest to '%s' on host ...\n", strSrc.c_str(), strDst.c_str())); 651 656 652 657 RTFILE hDstFile; … … 788 793 * Copies a file from the host to the guest. 789 794 * 795 * @return VBox status code. 796 * @retval VWRN_ALREADY_EXISTS if the file already exists and FileCopyFlag_NoReplace is specified, 797 * *or * the file at the destination has the same (or newer) modification time 798 * and FileCopyFlag_Update is specified. 790 799 * @param strSrc Full path of source file on the host. 791 800 * @param strDst Full destination path and file name (guest style) to copy file to. Guest-path style. … … 794 803 int GuestSessionTask::fileCopyToGuest(const Utf8Str &strSrc, const Utf8Str &strDst, FileCopyFlag_T fFileCopyFlags) 795 804 { 796 LogFlowThisFunc(("strSource=%s, strDst=%s, fFileCopyFlags= 0x%x\n", strSrc.c_str(), strDst.c_str(), fFileCopyFlags));805 LogFlowThisFunc(("strSource=%s, strDst=%s, fFileCopyFlags=%#x\n", strSrc.c_str(), strDst.c_str(), fFileCopyFlags)); 797 806 798 807 GuestFileOpenInfo dstOpenInfo; … … 840 849 if (RT_SUCCESS(vrc)) 841 850 { 842 if (fFileCopyFlags & FileCopyFlag_Update) 851 /* Only perform a remote file query when needed. */ 852 if ( (fFileCopyFlags & FileCopyFlag_Update) 853 || (fFileCopyFlags & FileCopyFlag_NoReplace)) 843 854 { 844 855 GuestFsObjData dstObjData; … … 847 858 if (RT_SUCCESS(vrc)) 848 859 { 849 RTTIMESPEC dstModificationTimeTS; 850 RTTimeSpecSetSeconds(&dstModificationTimeTS, dstObjData.mModificationTime); 851 if (RTTimeSpecCompare(&dstModificationTimeTS, &srcObjInfo.ModificationTime) <= 0) 860 if (fFileCopyFlags & FileCopyFlag_NoReplace) 852 861 { 853 LogRel2(("Guest Control: Guest file \"%s\" has same or newer modification date, skipping",854 strDst.c_str()));862 LogRel2(("Guest Control: Guest file \"%s\" already exists, skipping", strDst.c_str())); 863 vrc = VWRN_ALREADY_EXISTS; 855 864 fSkip = true; 865 } 866 867 if ( !fSkip 868 && fFileCopyFlags & FileCopyFlag_Update) 869 { 870 RTTIMESPEC dstModificationTimeTS; 871 RTTimeSpecSetSeconds(&dstModificationTimeTS, dstObjData.mModificationTime); 872 if (RTTimeSpecCompare(&dstModificationTimeTS, &srcObjInfo.ModificationTime) <= 0) 873 { 874 LogRel2(("Guest Control: Guest file \"%s\" has same or newer modification date, skipping", 875 strDst.c_str())); 876 vrc = VWRN_ALREADY_EXISTS; 877 fSkip = true; 878 } 856 879 } 857 880 } … … 893 916 int vrc2 = dstFile->i_closeFile(&vrcGuest); 894 917 AssertRC(vrc2); 895 return VINF_SUCCESS;918 return vrc; 896 919 } 897 920 … … 1792 1815 break; 1793 1816 } 1817 1818 /* Append the actual file name to the destination. */ 1819 strDstRootAbs += PATH_STYLE_SEP_STR(PATH_STYLE_NATIVE); 1820 strDstRootAbs += RTPathFilename(strSrcRootAbs.c_str()); 1794 1821 break; 1795 1822 }
Note:
See TracChangeset
for help on using the changeset viewer.