Changeset 38453 in vbox
- Timestamp:
- Aug 15, 2011 9:06:02 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r38446 r38453 858 858 } 859 859 860 /* 861 * Source Dest Translated 862 * c:\foo.txt c:\from_host c:\from_host\foo.txt 863 * c:\asdf\foo c:\qwer c:\qwer\foo 864 * c:\bar\baz.txt d:\users\ d:\users\baz.txt 865 * c:\*.dll e:\baz e:\baz 860 /** 861 * Translates a source path to a destintation path (can be both sides, 862 * either host or guest). The source root is needed to determine the start 863 * of the relative source path which also needs to present in the destination 864 * path. 865 * 866 * @return IPRT status code. 867 * @param pszSourceRoot Source root path. 868 * @param pszSource Actual source to transform. Must begin with 869 * the source root path! 870 * @param pszDest Destination path. 871 * @param ppszTranslated Pointer to the allocated, translated destination 872 * path. Must be free'd with RTStrFree(). 866 873 */ 867 static int ctrlCopyTranslatePath(PCOPYCONTEXT pContext, 868 const char *pszSourceRoot, const char *pszSource, 874 static int ctrlCopyTranslatePath(const char *pszSourceRoot, const char *pszSource, 869 875 const char *pszDest, char **ppszTranslated) 870 876 { 871 AssertPtrReturn(pContext, VERR_INVALID_POINTER);872 877 AssertPtrReturn(pszSourceRoot, VERR_INVALID_POINTER); 873 878 AssertPtrReturn(pszSource, VERR_INVALID_POINTER); … … 897 902 *ppszTranslated = pszTranslated; 898 903 899 #ifdef DEBUG 900 if (pContext->fVerbose) 901 RTPrintf("Translating root=%s, source=%s, dest=%s -> %s\n", 902 pszSourceRoot, pszSource, pszDest, *ppszTranslated); 904 return vrc; 905 } 906 907 #ifdef DEBUG_andy 908 static void tstTranslatePath() 909 { 910 static struct 911 { 912 const char *pszSourceRoot; 913 const char *pszSource; 914 const char *pszDest; 915 const char *pszTranslated; 916 int iResult; 917 } aTests[] = 918 { 919 /* Invalid stuff. */ 920 { NULL, NULL, NULL, NULL, VERR_INVALID_POINTER }, 921 /* Windows paths. */ 922 { "c:\\foo", "c:\\foo\\bar.txt", "c:\\test", "c:\\test\\bar.txt", VINF_SUCCESS }, 923 { "c:\\foo", "c:\\foo\\baz\\bar.txt", "c:\\test", "c:\\test\\baz\\bar.txt", VINF_SUCCESS } 924 /* UNIX-like paths. */ 925 /* Mixed paths*/ 926 /** @todo */ 927 }; 928 929 int iTest = 0; 930 for (iTest; iTest < RT_ELEMENTS(aTests); iTest++) 931 { 932 RTPrintf("=> Test %d\n", iTest); 933 RTPrintf("\tSourceRoot=%s, Source=%s, Dest=%s\n", 934 aTests[iTest].pszSourceRoot, aTests[iTest].pszSource, aTests[iTest].pszDest); 935 936 char *pszTranslated = NULL; 937 int iResult = ctrlCopyTranslatePath(aTests[iTest].pszSourceRoot, aTests[iTest].pszSource, 938 aTests[iTest].pszDest, &pszTranslated); 939 if (iResult != aTests[iTest].iResult) 940 { 941 RTPrintf("\tReturned %Rrc, expected %Rrc\n", 942 iResult, aTests[iTest].iResult); 943 } 944 else if ( pszTranslated 945 && strcmp(pszTranslated, aTests[iTest].pszTranslated)) 946 { 947 RTPrintf("\tReturned translated path %s, expected %s\n", 948 pszTranslated, aTests[iTest].pszTranslated); 949 } 950 951 if (pszTranslated) 952 { 953 RTPrintf("\tTranslated=%s\n", pszTranslated); 954 RTStrFree(pszTranslated); 955 } 956 } 957 } 903 958 #endif 904 905 return vrc;906 }907 959 908 960 static int ctrlCopyDirCreate(PCOPYCONTEXT pContext, const char *pszDir) … … 1143 1195 { 1144 1196 char *pszDestDir; 1145 rc = ctrlCopyTranslatePath(p Context, pszSource, szCurDir,1197 rc = ctrlCopyTranslatePath(pszSource, szCurDir, 1146 1198 pszDest, &pszDestDir); 1147 1199 if (RT_SUCCESS(rc)) … … 1161 1213 { 1162 1214 char *pszFileDest; 1163 rc = ctrlCopyTranslatePath(p Context, pszSource, pszFileSource,1215 rc = ctrlCopyTranslatePath(pszSource, pszFileSource, 1164 1216 pszDest, &pszFileDest); 1165 1217 if (RT_SUCCESS(rc)) … … 1216 1268 ULONG uDirHandle; 1217 1269 HRESULT hr = pContext->pGuest->DirectoryOpen(Bstr(szCurDir).raw(), Bstr(pszFilter).raw(), 1218 fFlags,1270 DirectoryOpenFlag_None /* No flags supported yet. */, 1219 1271 Bstr(pContext->pszUsername).raw(), Bstr(pContext->pszPassword).raw(), 1220 1272 &uDirHandle); … … 1281 1333 { 1282 1334 char *pszDestDir; 1283 rc = ctrlCopyTranslatePath(p Context, pszSource, szCurDir,1335 rc = ctrlCopyTranslatePath(pszSource, szCurDir, 1284 1336 pszDest, &pszDestDir); 1285 1337 if (RT_SUCCESS(rc)) … … 1299 1351 { 1300 1352 char *pszFileDest; 1301 rc = ctrlCopyTranslatePath(p Context, pszSource, pszFileSource,1353 rc = ctrlCopyTranslatePath(pszSource, pszFileSource, 1302 1354 pszDest, &pszFileDest); 1303 1355 if (RT_SUCCESS(rc)) … … 1413 1465 */ 1414 1466 1467 #ifdef DEBUG_andy 1468 tstTranslatePath(); 1469 return VINF_SUCCESS; 1470 #endif 1471 1415 1472 static const RTGETOPTDEF s_aOptions[] = 1416 1473 { … … 1596 1653 /* Single file. */ 1597 1654 char *pszDestFile; 1598 vrc = ctrlCopyTranslatePath(p Context, pszSourceRoot, pszSource,1655 vrc = ctrlCopyTranslatePath(pszSourceRoot, pszSource, 1599 1656 Utf8Dest.c_str(), &pszDestFile); 1600 1657 if (RT_SUCCESS(vrc))
Note:
See TracChangeset
for help on using the changeset viewer.