VirtualBox

Changeset 33411 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Oct 25, 2010 11:32:26 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67001
Message:

Guest Copy/VBoxManage+Main: Enabled code by default (VBoxManage "copyto"), added batch copy support.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/GuestImpl.cpp

    r33301 r33411  
    3333#endif
    3434#include <iprt/cpp/utils.h>
    35 #include <iprt/dir.h>
    3635#include <iprt/file.h>
    3736#include <iprt/getopt.h>
     
    18171816}
    18181817
    1819 #ifdef VBOX_WITH_COPYTOGUEST
    1820 int Guest::directoryEntryAppend(const char *pszPath, PRTLISTNODE pList)
    1821 {
    1822     using namespace guestControl;
    1823 
    1824     AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
    1825     AssertPtrReturn(pList, VERR_INVALID_POINTER);
    1826 
    1827     LogFlowFunc(("Appending to pList=%p: %s\n", pList, pszPath));
    1828 
    1829     VBoxGuestDirEntry *pNode = (VBoxGuestDirEntry*)RTMemAlloc(sizeof(VBoxGuestDirEntry));
    1830     if (pNode == NULL)
    1831         return VERR_NO_MEMORY;
    1832 
    1833     pNode->pszPath = NULL;
    1834     if (RT_SUCCESS(RTStrAAppend(&pNode->pszPath, pszPath)))
    1835     {
    1836         pNode->Node.pPrev = NULL;
    1837         pNode->Node.pNext = NULL;
    1838         RTListAppend(pList, &pNode->Node);
    1839         return VINF_SUCCESS;
    1840     }
    1841     return VERR_NO_MEMORY;
    1842 }
    1843 
    1844 int Guest::directoryRead(const char *pszDirectory, const char *pszFilter,
    1845                          ULONG uFlags, ULONG *pcObjects, PRTLISTNODE pList)
    1846 {
    1847     using namespace guestControl;
    1848 
    1849     AssertPtrReturn(pszDirectory, VERR_INVALID_POINTER);
    1850     /* Filter is optional. */
    1851     AssertPtrReturn(pcObjects, VERR_INVALID_POINTER);
    1852     AssertPtrReturn(pList, VERR_INVALID_POINTER);
    1853 
    1854     LogFlowFunc(("Reading directory: %s, filter: %s\n",
    1855                  pszDirectory, pszFilter ? pszFilter : "<None>"));
    1856 
    1857     PRTDIR pDir = NULL;
    1858     int rc = RTDirOpenFiltered(&pDir, pszDirectory,
    1859 #ifdef RT_OS_WINDOWS
    1860                                RTDIRFILTER_WINNT);
    1861 #else
    1862                                RTDIRFILTER_UNIX);
    1863 #endif
    1864     char *pszDirectoryStrip = RTStrDup(pszDirectory);
    1865     if (!pszDirectoryStrip)
    1866         rc = VERR_NO_MEMORY;
    1867 
    1868     if (RT_SUCCESS(rc))
    1869     {
    1870         RTPathStripFilename(pszDirectoryStrip);
    1871         for (;;)
    1872         {
    1873             RTDIRENTRY DirEntry;
    1874             rc = RTDirRead(pDir, &DirEntry, NULL);
    1875             if (RT_FAILURE(rc))
    1876             {
    1877                 if (rc == VERR_NO_MORE_FILES)
    1878                     rc = VINF_SUCCESS;
    1879                 break;
    1880             }
    1881             switch (DirEntry.enmType)
    1882             {
    1883                 case RTDIRENTRYTYPE_DIRECTORY:
    1884                     /* Skip "." and ".." entrires. */
    1885                     if (   !strcmp(DirEntry.szName, ".")
    1886                         || !strcmp(DirEntry.szName, ".."))
    1887                     {
    1888                         break;
    1889                     }
    1890                     if (uFlags & CopyFileFlag_Recursive)
    1891                         rc = directoryRead(DirEntry.szName, pszFilter,
    1892                                            uFlags, pcObjects, pList);
    1893                     break;
    1894 
    1895                 case RTDIRENTRYTYPE_FILE:
    1896                 {
    1897                     char *pszFile;
    1898                     if (RTStrAPrintf(&pszFile, "%s%c%s",
    1899                                      pszDirectoryStrip, RTPATH_SLASH, DirEntry.szName))
    1900                     {
    1901                         rc = directoryEntryAppend(pszFile, pList);
    1902                         if (RT_SUCCESS(rc))
    1903                             *pcObjects = *pcObjects + 1;
    1904                         RTStrFree(pszFile);
    1905                     }
    1906                     break;
    1907                 }
    1908 
    1909                 case RTDIRENTRYTYPE_SYMLINK:
    1910                     if (   (uFlags & CopyFileFlag_Recursive)
    1911                         && (uFlags & CopyFileFlag_FollowLinks))
    1912                     {
    1913                         rc = directoryRead(DirEntry.szName, pszFilter,
    1914                                            uFlags, pcObjects, pList);
    1915                     }
    1916                     break;
    1917 
    1918                 default:
    1919                     break;
    1920             }
    1921             if (RT_FAILURE(rc))
    1922                 break;
    1923         }
    1924         RTStrFree(pszDirectoryStrip);
    1925     }
    1926 
    1927     if (pDir)
    1928         RTDirClose(pDir);
    1929     return rc;
    1930 }
    1931 #endif
    1932 
    19331818/** @todo For having a progress object which actually reports something,
    19341819  *       the actual copy loop (see below) needs to go to some worker thread
     
    19421827    ReturnComNotImplemented();
    19431828#else  /* VBOX_WITH_GUEST_CONTROL */
    1944 #ifndef VBOX_WITH_COPYTOGUEST
    1945     ReturnComNotImplemented();
    1946 #else
    19471829    using namespace guestControl;
    19481830
     
    22652147    }
    22662148    return rc;
    2267 #endif /* VBOX_WITH_COPYTOGUEST */
    22682149#endif /* VBOX_WITH_GUEST_CONTROL */
    22692150}
  • trunk/src/VBox/Main/include/GuestImpl.h

    r33301 r33411  
    152152    typedef std::map< uint32_t, GuestProcess >::const_iterator GuestProcessMapIterConst;
    153153
    154 #ifdef VBOX_WITH_COPYTOGUEST
    155     /*
    156      * Structure holding a directory entry.
    157      */
    158     struct VBoxGuestDirEntry
    159     {
    160         char       *pszPath;
    161         RTLISTNODE  Node;
    162     };
    163 
    164154    int directoryEntryAppend(const char *pszPath, PRTLISTNODE pList);
    165155    int directoryRead(const char *pszDirectory, const char *pszFilter, ULONG uFlags, ULONG *pcObjects, PRTLISTNODE pList);
    166 #endif
    167156
    168157    int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
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