Changeset 38656 in vbox
- Timestamp:
- Sep 6, 2011 12:34:26 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73866
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r38586 r38656 73 73 IGuest *pGuest; 74 74 bool fVerbose; 75 bool fDryRun; 75 76 bool fHostToGuest; 76 77 char *pszUsername; … … 821 822 * @param pGuest Pointer to IGuest interface to use. 822 823 * @param fVerbose Flag indicating if we want to run in verbose mode. 824 * @param fDryRun Flag indicating if we want to run a dry run only. 823 825 * @param fHostToGuest Flag indicating if we want to copy from host to guest 824 826 * or vice versa. … … 827 829 * @param ppContext Pointer which receives the allocated copy context. 828 830 */ 829 static int ctrlCopyContextCreate(IGuest *pGuest, bool fVerbose, bool fHostToGuest, 831 static int ctrlCopyContextCreate(IGuest *pGuest, bool fVerbose, bool fDryRun, 832 bool fHostToGuest, 830 833 const char *pszUsername, const char *pszPassword, 831 834 PCOPYCONTEXT *ppContext) … … 839 842 pContext->pGuest = pGuest; 840 843 pContext->fVerbose = fVerbose; 844 pContext->fDryRun = fDryRun; 841 845 pContext->fHostToGuest = fHostToGuest; 842 846 … … 984 988 AssertPtrReturn(pszDir, VERR_INVALID_POINTER); 985 989 990 if (pContext->fVerbose) 991 RTPrintf("Creating directory \"%s\" ...\n", pszDir); 992 993 if (pContext->fDryRun) 994 return VINF_SUCCESS; 995 986 996 int rc = VINF_SUCCESS; 987 997 if (pContext->fHostToGuest) /* We want to create directories on the guest. */ … … 1160 1170 1161 1171 if (pContext->fVerbose) 1162 {1163 1172 RTPrintf("Copying \"%s\" to \"%s\" ...\n", 1164 1173 pszFileSource, pszFileDest); 1165 } 1174 1175 if (pContext->fDryRun) 1176 return VINF_SUCCESS; 1166 1177 1167 1178 int vrc = VINF_SUCCESS; … … 1225 1236 rc = RTPathAppend(szCurDir, sizeof(szCurDir), pszSubDir); 1226 1237 1238 if (pContext->fVerbose) 1239 RTPrintf("Processing directory: %s\n", szCurDir); 1240 1227 1241 /* Flag indicating whether the current directory was created on the 1228 1242 * target or not. */ … … 1263 1277 || !strcmp(DirEntry.szName, "..")) 1264 1278 break; 1279 1280 if (pContext->fVerbose) 1281 RTPrintf("Directory: %s\n", DirEntry.szName); 1265 1282 1266 1283 if (fFlags & CopyFileFlag_Recursive) … … 1299 1316 case RTDIRENTRYTYPE_FILE: 1300 1317 { 1301 if ( !pszFilter1302 ||RTStrSimplePatternMatch(pszFilter, DirEntry.szName))1318 if ( pszFilter 1319 && !RTStrSimplePatternMatch(pszFilter, DirEntry.szName)) 1303 1320 { 1304 if (!fDirCreated) 1321 break; /* Filter does not match. */ 1322 } 1323 1324 if (pContext->fVerbose) 1325 RTPrintf("File: %s\n", DirEntry.szName); 1326 1327 if (!fDirCreated) 1328 { 1329 char *pszDestDir; 1330 rc = ctrlCopyTranslatePath(pszSource, szCurDir, 1331 pszDest, &pszDestDir); 1332 if (RT_SUCCESS(rc)) 1305 1333 { 1306 char *pszDestDir; 1307 rc = ctrlCopyTranslatePath(pszSource, szCurDir, 1308 pszDest, &pszDestDir); 1334 rc = ctrlCopyDirCreate(pContext, pszDestDir); 1335 RTStrFree(pszDestDir); 1336 1337 fDirCreated = true; 1338 } 1339 } 1340 1341 if (RT_SUCCESS(rc)) 1342 { 1343 char *pszFileSource = RTPathJoinA(szCurDir, DirEntry.szName); 1344 if (pszFileSource) 1345 { 1346 char *pszFileDest; 1347 rc = ctrlCopyTranslatePath(pszSource, pszFileSource, 1348 pszDest, &pszFileDest); 1309 1349 if (RT_SUCCESS(rc)) 1310 1350 { 1311 rc = ctrlCopyDirCreate(pContext, pszDestDir); 1312 RTStrFree(pszDestDir); 1313 1314 fDirCreated = true; 1351 rc = ctrlCopyFileToDest(pContext, pszFileSource, 1352 pszFileDest, 0 /* Flags */); 1353 RTStrFree(pszFileDest); 1315 1354 } 1316 } 1317 1318 if (RT_SUCCESS(rc)) 1319 { 1320 char *pszFileSource = RTPathJoinA(szCurDir, DirEntry.szName); 1321 if (pszFileSource) 1322 { 1323 char *pszFileDest; 1324 rc = ctrlCopyTranslatePath(pszSource, pszFileSource, 1325 pszDest, &pszFileDest); 1326 if (RT_SUCCESS(rc)) 1327 { 1328 rc = ctrlCopyFileToDest(pContext, pszFileSource, 1329 pszFileDest, 0 /* Flags */); 1330 RTStrFree(pszFileDest); 1331 } 1332 RTStrFree(pszFileSource); 1333 } 1355 RTStrFree(pszFileSource); 1334 1356 } 1335 1357 } … … 1383 1405 return rc; 1384 1406 1407 if (pContext->fVerbose) 1408 RTPrintf("Processing directory: %s\n", szCurDir); 1409 1385 1410 /* Flag indicating whether the current directory was created on the 1386 1411 * target or not. */ … … 1413 1438 || !strName.compare(Bstr(".."))) 1414 1439 break; 1440 1441 if (pContext->fVerbose) 1442 { 1443 Utf8Str Utf8Dir(strName); 1444 RTPrintf("Directory: %s\n", Utf8Dir.c_str()); 1445 } 1415 1446 1416 1447 if (fFlags & CopyFileFlag_Recursive) … … 1450 1481 { 1451 1482 Utf8Str strFile(strName); 1452 if ( !pszFilter1453 ||RTStrSimplePatternMatch(pszFilter, strFile.c_str()))1483 if ( pszFilter 1484 && !RTStrSimplePatternMatch(pszFilter, strFile.c_str())) 1454 1485 { 1455 if (!fDirCreated) 1486 break; /* Filter does not match. */ 1487 } 1488 1489 if (pContext->fVerbose) 1490 RTPrintf("File: %s\n", strFile.c_str()); 1491 1492 if (!fDirCreated) 1493 { 1494 char *pszDestDir; 1495 rc = ctrlCopyTranslatePath(pszSource, szCurDir, 1496 pszDest, &pszDestDir); 1497 if (RT_SUCCESS(rc)) 1456 1498 { 1457 char *pszDestDir; 1458 rc = ctrlCopyTranslatePath(pszSource, szCurDir, 1459 pszDest, &pszDestDir); 1499 rc = ctrlCopyDirCreate(pContext, pszDestDir); 1500 RTStrFree(pszDestDir); 1501 1502 fDirCreated = true; 1503 } 1504 } 1505 1506 if (RT_SUCCESS(rc)) 1507 { 1508 char *pszFileSource = RTPathJoinA(szCurDir, strFile.c_str()); 1509 if (pszFileSource) 1510 { 1511 char *pszFileDest; 1512 rc = ctrlCopyTranslatePath(pszSource, pszFileSource, 1513 pszDest, &pszFileDest); 1460 1514 if (RT_SUCCESS(rc)) 1461 1515 { 1462 rc = ctrlCopyDirCreate(pContext, pszDestDir); 1463 RTStrFree(pszDestDir); 1464 1465 fDirCreated = true; 1516 rc = ctrlCopyFileToDest(pContext, pszFileSource, 1517 pszFileDest, 0 /* Flags */); 1518 RTStrFree(pszFileDest); 1466 1519 } 1520 RTStrFree(pszFileSource); 1467 1521 } 1468 1469 if (RT_SUCCESS(rc)) 1470 { 1471 char *pszFileSource = RTPathJoinA(szCurDir, strFile.c_str()); 1472 if (pszFileSource) 1473 { 1474 char *pszFileDest; 1475 rc = ctrlCopyTranslatePath(pszSource, pszFileSource, 1476 pszDest, &pszFileDest); 1477 if (RT_SUCCESS(rc)) 1478 { 1479 rc = ctrlCopyFileToDest(pContext, pszFileSource, 1480 pszFileDest, 0 /* Flags */); 1481 RTStrFree(pszFileDest); 1482 } 1483 RTStrFree(pszFileSource); 1484 } 1485 else 1486 rc = VERR_NO_MEMORY; 1487 } 1522 else 1523 rc = VERR_NO_MEMORY; 1488 1524 } 1489 1525 break; … … 1724 1760 * the routines need to know when handling the actual copying. */ 1725 1761 PCOPYCONTEXT pContext; 1726 vrc = ctrlCopyContextCreate(guest, fVerbose, f HostToGuest,1762 vrc = ctrlCopyContextCreate(guest, fVerbose, fDryRun, fHostToGuest, 1727 1763 Utf8UserName.c_str(), Utf8Password.c_str(), 1728 1764 &pContext); … … 1782 1818 vrc = ctrlCopyDirExistsOnSource(pContext, pszSource, &fExists); 1783 1819 1784 /* Strip trailing slash from our source element so that other functions 1785 * can use this stuff properly (like RTPathStartsWith). */ 1786 RTPathStripTrailingSlash(pszSource); 1820 if (fExists) 1821 { 1822 /* Strip trailing slash from our source element so that other functions 1823 * can use this stuff properly (like RTPathStartsWith). */ 1824 RTPathStripTrailingSlash(pszSource); 1825 } 1787 1826 } 1788 1827 else … … 1812 1851 } 1813 1852 else 1814 {1815 1853 RTMsgError("Unable to translate path for \"%s\", rc=%Rrc\n", 1816 1854 pszSource, vrc); 1817 }1818 1855 } 1819 1856 else
Note:
See TracChangeset
for help on using the changeset viewer.