VirtualBox

Changeset 71319 in vbox


Ignore:
Timestamp:
Mar 14, 2018 12:25:05 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121268
Message:

Guest Control/VBoxManage: Check the source element to copy from guest to know whether to use IGuestSession::fileCopyTo() or IGuestSession::directoryCopyTo().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp

    r71251 r71319  
    18611861            if (RTFileExists(strSrc.c_str()))
    18621862            {
     1863                if (pCtx->cVerbose)
     1864                    RTPrintf("File '%s' -> '%s'\n", strSrc.c_str(), pszDst);
     1865
    18631866                SafeArray<FileCopyFlag_T> copyFlags;
    18641867                rc = pCtx->pGuestSession->FileCopyToGuest(Bstr(strSrc).raw(), Bstr(pszDst).raw(),
     
    18671870            else if (RTDirExists(strSrc.c_str()))
    18681871            {
     1872                if (pCtx->cVerbose)
     1873                    RTPrintf("Directory '%s' -> '%s'\n", strSrc.c_str(), pszDst);
     1874
    18691875                SafeArray<DirectoryCopyFlag_T> copyFlags;
    18701876                copyFlags.push_back(DirectoryCopyFlag_CopyIntoExisting);
     
    18771883        else
    18781884        {
    1879             if (   strSrc.endsWith("/")
    1880                 || strSrc.endsWith("\\"))
    1881             {
     1885            /* We need to query the source type on the guest first in order to know which copy flavor we need. */
     1886            ComPtr<IGuestFsObjInfo> pFsObjInfo;
     1887            FsObjType_T enmObjType = FsObjType_Unknown; /* Shut up MSC */
     1888            rc = pCtx->pGuestSession->FsObjQueryInfo(Bstr(strSrc).raw(), TRUE  /* fFollowSymlinks */, pFsObjInfo.asOutParam());
     1889            if (SUCCEEDED(rc))
     1890                rc = pFsObjInfo->COMGETTER(Type)(&enmObjType);
     1891            if (FAILED(rc))
     1892            {
     1893                if (pCtx->cVerbose)
     1894                    RTPrintf("Warning: Cannot stat for element '%s': No such element\n", strSrc.c_str());
     1895                continue; /* Skip. */
     1896            }
     1897
     1898            if (enmObjType == FsObjType_Directory)
     1899            {
     1900                if (pCtx->cVerbose)
     1901                    RTPrintf("Directory '%s' -> '%s'\n", strSrc.c_str(), pszDst);
     1902
    18821903                SafeArray<DirectoryCopyFlag_T> copyFlags;
    18831904                copyFlags.push_back(DirectoryCopyFlag_CopyIntoExisting);
     
    18851906                                                                 ComSafeArrayAsInParam(copyFlags), pProgress.asOutParam());
    18861907            }
    1887             else
    1888             {
     1908            else if (enmObjType == FsObjType_File)
     1909            {
     1910                if (pCtx->cVerbose)
     1911                    RTPrintf("File '%s' -> '%s'\n", strSrc.c_str(), pszDst);
     1912
    18891913                SafeArray<FileCopyFlag_T> copyFlags;
    18901914                rc = pCtx->pGuestSession->FileCopyFromGuest(Bstr(strSrc).raw(), Bstr(pszDst).raw(),
    18911915                                                            ComSafeArrayAsInParam(copyFlags), pProgress.asOutParam());
    18921916            }
     1917            else if (pCtx->cVerbose)
     1918                RTPrintf("Warning: Skipping '%s': Not handled\n", strSrc.c_str());
    18931919        }
    18941920    }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette