Changeset 38561 in vbox
- Timestamp:
- Aug 29, 2011 7:15:48 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73727
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r38551 r38561 883 883 * 884 884 * @return IPRT status code. 885 * @param pszSourceRoot Source root path. 885 * @param pszSourceRoot Source root path. No trailing directory slash! 886 886 * @param pszSource Actual source to transform. Must begin with 887 887 * the source root path! … … 897 897 AssertPtrReturn(pszDest, VERR_INVALID_POINTER); 898 898 AssertPtrReturn(ppszTranslated, VERR_INVALID_POINTER); 899 900 /* Source path must contain the source root! */ 901 if (!RTPathStartsWith(pszSource, pszSourceRoot)) 902 return VERR_INVALID_PARAMETER; 899 AssertReturn(RTPathStartsWith(pszSource, pszSourceRoot), VERR_INVALID_PARAMETER); 903 900 904 901 /* Construct the relative dest destination path by "subtracting" the … … 909 906 * translated = "d:\baz\bar\" 910 907 */ 911 912 size_t lenRoot = strlen(pszSourceRoot); 913 AssertReturn(lenRoot, VERR_INVALID_PARAMETER); 914 char *pszTranslated = RTStrDup(pszDest); 915 AssertReturn(pszTranslated, VERR_NO_MEMORY); 916 int vrc = RTStrAAppend(&pszTranslated, &pszSource[lenRoot]); 917 if (RT_FAILURE(vrc)) 918 return vrc; 919 920 *ppszTranslated = pszTranslated; 921 922 return vrc; 908 char szTranslated[RTPATH_MAX]; 909 size_t srcOff = strlen(pszSourceRoot); 910 AssertReturn(srcOff, VERR_INVALID_PARAMETER); 911 int rc = RTPathJoin(szTranslated, sizeof(szTranslated), 912 pszDest, &pszSource[srcOff]); 913 if (RT_SUCCESS(rc)) 914 *ppszTranslated = RTStrDup(szTranslated); 915 return rc; 923 916 } 924 917 … … 1002 995 else /* ... or on the host. */ 1003 996 { 1004 rc = RTDirCreate (pszDir, 700);997 rc = RTDirCreateFullPath(pszDir, 700); 1005 998 if (rc == VERR_ALREADY_EXISTS) 1006 999 rc = VINF_SUCCESS; … … 1214 1207 const char *pszSource, const char *pszFilter, 1215 1208 const char *pszDest, uint32_t fFlags, 1216 const char *pszSubDir /* For recursion */)1209 const char *pszSubDir /* For recursion. */) 1217 1210 { 1218 1211 AssertPtrReturn(pContext, VERR_INVALID_POINTER); … … 1273 1266 char *pszNewSub = NULL; 1274 1267 if (pszSubDir) 1275 RTStrAPrintf(&pszNewSub, "%s/%s",pszSubDir, DirEntry.szName);1268 pszNewSub = RTPathJoinA(pszSubDir, DirEntry.szName); 1276 1269 else 1277 RTStrAPrintf(&pszNewSub, "%s", DirEntry.szName); 1270 { 1271 pszNewSub = RTStrDup(DirEntry.szName); 1272 RTPathStripTrailingSlash(pszNewSub); 1273 } 1278 1274 1279 1275 if (pszNewSub) … … 1320 1316 if (RT_SUCCESS(rc)) 1321 1317 { 1322 char *pszFileSource; 1323 if (RTStrAPrintf(&pszFileSource, "%s/%s", 1324 szCurDir, DirEntry.szName)) 1318 char *pszFileSource = RTPathJoinA(szCurDir, DirEntry.szName); 1319 if (pszFileSource) 1325 1320 { 1326 1321 char *pszFileDest; … … 1367 1362 const char *pszSource, const char *pszFilter, 1368 1363 const char *pszDest, uint32_t fFlags, 1369 const char *pszSubDir /* For recursion */)1364 const char *pszSubDir /* For recursion. */) 1370 1365 { 1371 1366 AssertPtrReturn(pContext, VERR_INVALID_POINTER); … … 1422 1417 char *pszNewSub = NULL; 1423 1418 if (pszSubDir) 1424 RTStrAPrintf(&pszNewSub, "%s/%s",pszSubDir, strDir.c_str());1419 pszNewSub = RTPathJoinA(pszSubDir, strDir.c_str()); 1425 1420 else 1426 RTStrAPrintf(&pszNewSub, "%s", strDir.c_str()); 1427 1421 { 1422 pszNewSub = RTStrDup(strDir.c_str()); 1423 RTPathStripTrailingSlash(pszNewSub); 1424 } 1428 1425 if (pszNewSub) 1429 1426 { … … 1470 1467 if (RT_SUCCESS(rc)) 1471 1468 { 1472 char *pszFileSource; 1473 if (RTStrAPrintf(&pszFileSource, "%s/%s", 1474 szCurDir, strFile.c_str())) 1469 char *pszFileSource = RTPathJoinA(szCurDir, strFile.c_str()); 1470 if (pszFileSource) 1475 1471 { 1476 1472 char *pszFileDest; … … 1754 1750 for (unsigned long s = 0; s < vecSources.size(); s++) 1755 1751 { 1756 const char *pszSource = vecSources[s].mSource.c_str(); 1752 char *pszSource = RTStrDup(vecSources[s].mSource.c_str()); 1753 AssertPtrBreakStmt(pszSource, vrc = VERR_NO_MEMORY); 1757 1754 const char *pszFilter = vecSources[s].mFilter.c_str(); 1758 1755 if (!strlen(pszFilter)) … … 1773 1770 bool fIsFile = false; 1774 1771 bool fExists; 1775 Utf8Str Utf8CurSource(pszSource); 1776 if ( Utf8CurSource.endsWith("/") 1777 || Utf8CurSource.endsWith("\\")) 1778 { 1779 #ifndef DEBUG_andy 1780 if (pContext->fHostToGuest) 1781 { 1782 #endif 1783 if (pszFilter) /* Directory with filter. */ 1784 vrc = ctrlCopyDirExistsOnSource(pContext, pszSourceRoot, &fExists); 1785 else /* Regular directory without filter. */ 1786 vrc = ctrlCopyDirExistsOnSource(pContext, pszSource, &fExists); 1787 #ifndef DEBUG_andy 1788 } 1789 else 1790 { 1791 RTMsgError("Copying of guest directories to the host is not supported yet!\n"); 1792 vrc = VERR_NOT_IMPLEMENTED; 1793 } 1794 #endif 1772 1773 size_t cchSource = strlen(pszSource); 1774 if ( cchSource > 1 1775 && RTPATH_IS_SLASH(pszSource[cchSource - 1])) 1776 { 1777 if (pszFilter) /* Directory with filter (so use source root w/o the actual filter). */ 1778 vrc = ctrlCopyDirExistsOnSource(pContext, pszSourceRoot, &fExists); 1779 else /* Regular directory without filter. */ 1780 vrc = ctrlCopyDirExistsOnSource(pContext, pszSource, &fExists); 1781 1782 /* Strip trailing slash from our source element so that other functions 1783 * can use this stuff properly (like RTPathStartsWith). */ 1784 RTPathStripTrailingSlash(pszSource); 1795 1785 } 1796 1786 else … … 1799 1789 if ( RT_SUCCESS(vrc) 1800 1790 && fExists) 1791 { 1801 1792 fIsFile = true; 1802 } 1803 1804 if (RT_SUCCESS(vrc)) 1793 } 1794 } 1795 1796 if ( RT_SUCCESS(vrc) 1797 && fExists) 1805 1798 { 1806 1799 if (fIsFile) … … 1837 1830 RTMsgError("Warning: Source \"%s\" does not exist, skipping!\n", 1838 1831 pszSource); 1832 RTStrFree(pszSource); 1839 1833 continue; 1840 1834 } 1841 1842 if (RT_FAILURE(vrc)) 1835 else if (RT_FAILURE(vrc)) 1843 1836 { 1844 1837 RTMsgError("Error processing \"%s\", rc=%Rrc\n", 1845 1838 pszSource, vrc); 1846 break; 1847 } 1839 RTStrFree(pszSource); 1840 break; 1841 } 1842 1843 RTStrFree(pszSource); 1848 1844 } 1849 1845 }
Note:
See TracChangeset
for help on using the changeset viewer.