Changeset 33411 in vbox for trunk/src/VBox/Main
- Timestamp:
- Oct 25, 2010 11:32:26 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67001
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/GuestImpl.cpp
r33301 r33411 33 33 #endif 34 34 #include <iprt/cpp/utils.h> 35 #include <iprt/dir.h>36 35 #include <iprt/file.h> 37 36 #include <iprt/getopt.h> … … 1817 1816 } 1818 1817 1819 #ifdef VBOX_WITH_COPYTOGUEST1820 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_WINDOWS1860 RTDIRFILTER_WINNT);1861 #else1862 RTDIRFILTER_UNIX);1863 #endif1864 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 #endif1932 1933 1818 /** @todo For having a progress object which actually reports something, 1934 1819 * the actual copy loop (see below) needs to go to some worker thread … … 1942 1827 ReturnComNotImplemented(); 1943 1828 #else /* VBOX_WITH_GUEST_CONTROL */ 1944 #ifndef VBOX_WITH_COPYTOGUEST1945 ReturnComNotImplemented();1946 #else1947 1829 using namespace guestControl; 1948 1830 … … 2265 2147 } 2266 2148 return rc; 2267 #endif /* VBOX_WITH_COPYTOGUEST */2268 2149 #endif /* VBOX_WITH_GUEST_CONTROL */ 2269 2150 } -
trunk/src/VBox/Main/include/GuestImpl.h
r33301 r33411 152 152 typedef std::map< uint32_t, GuestProcess >::const_iterator GuestProcessMapIterConst; 153 153 154 #ifdef VBOX_WITH_COPYTOGUEST155 /*156 * Structure holding a directory entry.157 */158 struct VBoxGuestDirEntry159 {160 char *pszPath;161 RTLISTNODE Node;162 };163 164 154 int directoryEntryAppend(const char *pszPath, PRTLISTNODE pList); 165 155 int directoryRead(const char *pszDirectory, const char *pszFilter, ULONG uFlags, ULONG *pcObjects, PRTLISTNODE pList); 166 #endif167 156 168 157 int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
Note:
See TracChangeset
for help on using the changeset viewer.