Changeset 72045 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 26, 2018 3:39:10 PM (7 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestSessionImplTasks.h
r72001 r72045 173 173 } 174 174 175 const ComObjPtr<Progress>& GetProgressObject( ) const { return mProgress; }176 177 const ComObjPtr<GuestSession>& GetSession( ) const { return mSession; }175 const ComObjPtr<Progress>& GetProgressObject(void) const { return mProgress; } 176 177 const ComObjPtr<GuestSession>& GetSession(void) const { return mSession; } 178 178 179 179 protected: -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r72007 r72045 812 812 813 813 } 814 catch (std::bad_alloc &)814 catch (std::bad_alloc &) 815 815 { 816 816 hrc = E_OUTOFMEMORY; 817 817 } 818 catch (HRESULT eHR)818 catch (HRESULT eHR) 819 819 { 820 820 hrc = eHR; 821 LogFlowThisFunc(("Exception was caught in the function\n"));822 } 823 821 } 822 823 LogFlowFunc(("Returning %Rhrc\n", hrc)); 824 824 return hrc; 825 825 } … … 913 913 914 914 } 915 catch (std::bad_alloc &)915 catch (std::bad_alloc &) 916 916 { 917 917 hrc = E_OUTOFMEMORY; 918 918 } 919 catch (HRESULT eHR)919 catch (HRESULT eHR) 920 920 { 921 921 hrc = eHR; 922 LogFlowThisFunc(("Exception was caught in the function\n"));923 } 924 922 } 923 924 LogFlowFunc(("Returning %Rhrc\n", hrc)); 925 925 return hrc; 926 926 } -
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r72023 r72045 124 124 } 125 125 126 127 126 int GuestSessionTask::getGuestProperty(const ComObjPtr<Guest> &pGuest, 128 127 const Utf8Str &strPath, Utf8Str &strValue) … … 213 212 * Creates a directory on the guest. 214 213 * 215 * @return VBox status code. V WRN_ALREADY_EXISTS if directory on the guest already exists.214 * @return VBox status code. VERR_ALREADY_EXISTS if directory on the guest already exists. 216 215 * @param strPath Absolute path to directory on the guest (guest style path) to create. 217 216 * @param enmDirectoryCreateFlags Directory creation flags. … … 229 228 if (RT_SUCCESS(rc)) 230 229 { 231 return V WRN_ALREADY_EXISTS;230 return VERR_ALREADY_EXISTS; 232 231 } 233 232 else … … 747 746 if ( !strDest.endsWith("\\") 748 747 && !strDest.endsWith("/")) 749 RTStrCat(szDstPath, sizeof(szDstPath), mPathStyle.c_str());748 RTStrCat(szDstPath, sizeof(szDstPath), "/"); 750 749 751 750 RTStrCat(szDstPath, sizeof(szDstPath), RTPathFilename(strSource.c_str())); … … 985 984 if ( !mSrcRootAbs.endsWith("/") 986 985 && !mSrcRootAbs.endsWith("\\")) 987 mSrcRootAbs += mSourceSpec.enmPathStyle == PathStyle_DOS ? "\\" :"/";986 mSrcRootAbs += "/"; 988 987 989 988 if ( !mDstRootAbs.endsWith("/") … … 1029 1028 if ( !strPathAbs.endsWith("/") 1030 1029 && !strPathAbs.endsWith("\\")) 1031 strPathAbs += mSourceSpec.enmPathStyle == PathStyle_DOS ? "\\" :"/";1030 strPathAbs += "/"; 1032 1031 1033 1032 Utf8Str strPathSub = strSubDir; … … 1035 1034 && !strPathSub.endsWith("/") 1036 1035 && !strPathSub.endsWith("\\")) 1037 strPathSub += mSourceSpec.enmPathStyle == PathStyle_DOS ? "\\" :"/";1036 strPathSub += "/"; 1038 1037 1039 1038 strPathAbs += strPathSub; … … 1129 1128 } 1130 1129 } 1130 1131 if (rc == VERR_NO_MORE_FILES) /* End of listing reached? */ 1132 rc = VINF_SUCCESS; 1131 1133 } 1132 1134 … … 1359 1361 1360 1362 ULONG cOperations = 0; 1363 Utf8Str strErrorInfo; 1364 1365 /** 1366 * Note: We need to build up the file/directory here instead of GuestSessionTaskCopyFrom::Run 1367 * because the caller expects a ready-for-operation progress object on return. 1368 * The progress object will have a variable operation count, based on the elements to 1369 * be processed. 1370 */ 1361 1371 1362 1372 GuestSessionFsSourceSet::iterator itSrc = mSources.begin(); … … 1375 1385 if ( !strDst.endsWith("/") 1376 1386 && !strDst.endsWith("\\")) 1377 strDst += mPathStyle;1387 strDst += "/"; 1378 1388 1379 1389 strDst += Utf8StrFmt("%s", RTPathFilenameEx(strSrc.c_str(), mfPathStyle)); 1380 1390 } 1381 1391 } 1392 1393 LogFlowFunc(("strSrc=%s, strDst=%s\n", strSrc.c_str(), strDst.c_str())); 1382 1394 1383 1395 GuestFsObjData srcObjData; int rcGuest; … … 1386 1398 if (RT_FAILURE(rc)) 1387 1399 { 1400 strErrorInfo = Utf8StrFmt(GuestSession::tr("No such source file/directory: %s"), strSrc.c_str()); 1388 1401 break; 1389 1402 } … … 1393 1406 if (itSrc->enmType != FsObjType_Directory) 1394 1407 { 1408 strErrorInfo = Utf8StrFmt(GuestSession::tr("Source is not a file: %s"), strSrc.c_str()); 1395 1409 rc = VERR_NOT_A_FILE; 1396 1410 break; … … 1401 1415 if (itSrc->enmType != FsObjType_File) 1402 1416 { 1417 strErrorInfo = Utf8StrFmt(GuestSession::tr("Source is not a directory: %s"), strSrc.c_str()); 1403 1418 rc = VERR_NOT_A_DIRECTORY; 1404 1419 break; 1405 1420 } 1406 1421 } 1407 1408 LogFlowFunc(("strSrc=%s, strDst=%s\n", strSrc.c_str(), strDst.c_str()));1409 1410 #if 01411 if (itSrc->enmType == FsObjType_Directory)1412 {1413 bool fDstExists = RTDirExists(strDstDir.c_str());1414 if (fDstExists)1415 {1416 if (!(itSrc->Type.Dir.fCopyFlags & DirectoryCopyFlag_CopyIntoExisting))1417 {1418 setProgressErrorMsg(VBOX_E_IPRT_ERROR,1419 Utf8StrFmt(GuestSession::tr("Destination directory \"%s\" exists when it must not"), mDest.c_str()));1420 rc = VERR_ALREADY_EXISTS;1421 break;1422 }1423 }1424 1425 if ( !strSrcDir.endsWith("/")1426 && !strSrcDir.endsWith("\\"))1427 {1428 if ( !strDstDir.endsWith("/")1429 && !strDstDir.endsWith("\\"))1430 strDstDir += "/"; /* IPRT can handle / on all hosts. */1431 1432 strDstDir += Utf8StrFmt("%s", RTPathFilenameEx(strSrcDir.c_str(), mfPathStyle));1433 }1434 1435 /* Create the final target directory on the host.1436 * The target directory might already exist on the host (which can be controlled by the copy flags). */1437 fDstExists = RTDirExists(strDstDir.c_str());1438 if (fDstExists)1439 {1440 if (!(itSrc->Type.Dir.fCopyFlags & DirectoryCopyFlag_CopyIntoExisting))1441 {1442 setProgressErrorMsg(VBOX_E_IPRT_ERROR,1443 Utf8StrFmt(GuestSession::tr("Destination directory \"%s\" exists when it must not"), strDstDir.c_str()));1444 rc = VERR_ALREADY_EXISTS;1445 break;1446 }1447 }1448 else1449 {1450 rc = RTDirCreate(strDstDir.c_str(), fDirMode, 0);1451 if (RT_FAILURE(rc))1452 {1453 setProgressErrorMsg(VBOX_E_IPRT_ERROR,1454 Utf8StrFmt(GuestSession::tr("Error creating destination directory \"%s\", rc=%Rrc"),1455 strDstDir.c_str(), rc));1456 break;1457 }1458 }1459 }1460 else if (itSrc->enmType == FsObjType_File)1461 {1462 1463 }1464 else1465 AssertFailed();1466 #endif1467 1422 1468 1423 FsList *pFsList = NULL; … … 1484 1439 { 1485 1440 delete pFsList; 1441 strErrorInfo = Utf8StrFmt(GuestSession::tr("Error adding source '%s' to list: %Rrc"), strSrc.c_str(), rc); 1486 1442 break; 1487 1443 } … … 1501 1457 } 1502 1458 1503 if (RT_SUCCESS(rc)) 1504 { 1505 Utf8Str strFirstOp; 1506 if (cOperations) /* Use the first element as description (if available). */ 1507 { 1508 Assert(mVecLists.size()); 1509 Assert(mVecLists[0]->mVecEntries.size()); 1510 1511 strFirstOp = mDest + mVecLists[0]->mVecEntries[0]->strPath; 1512 } 1513 1459 if (cOperations) /* Use the first element as description (if available). */ 1460 { 1461 Assert(mVecLists.size()); 1462 Assert(mVecLists[0]->mVecEntries.size()); 1463 1464 Utf8Str strFirstOp = mDest + mVecLists[0]->mVecEntries[0]->strPath; 1514 1465 hr = pProgress->init(static_cast<IGuestSession*>(mSession), Bstr(mDesc).raw(), 1515 1466 TRUE /* aCancelable */, cOperations + 1 /* Number of operations */, 1516 1467 Bstr(strFirstOp).raw()); 1517 1468 } 1518 1469 else /* If no operations have been defined, go with an "empty" progress object when will be used for error handling. */ 1470 hr = pProgress->init(static_cast<IGuestSession*>(mSession), Bstr(mDesc).raw(), 1471 TRUE /* aCancelable */, 1 /* cOperations */, Bstr(mDesc).raw()); 1472 1473 if (RT_FAILURE(rc)) 1474 { 1475 Assert(strErrorInfo.isNotEmpty()); 1476 setProgressErrorMsg(VBOX_E_IPRT_ERROR, strErrorInfo); 1477 } 1478 1479 LogFlowFunc(("Returning %Rhrc (%Rrc)\n", hr, rc)); 1519 1480 return rc; 1520 1481 } … … 1563 1524 strSrcAbs += pEntry->strPath; 1564 1525 strDstAbs += pEntry->strPath; 1565 } 1566 1567 LogFlowFunc(("Entry '%s': %s -> %s\n", pEntry->strPath.c_str(), strSrcAbs.c_str(), strDstAbs.c_str())); 1526 1527 if (pList->mSourceSpec.enmPathStyle == PathStyle_DOS) 1528 strDstAbs.findReplace('\\', '/'); 1529 } 1568 1530 1569 1531 switch (pEntry->fMode & RTFS_TYPE_MASK) 1570 1532 { 1571 1533 case RTFS_TYPE_DIRECTORY: 1534 LogFlowFunc(("Directory '%s': %s -> %s\n", pEntry->strPath.c_str(), strSrcAbs.c_str(), strDstAbs.c_str())); 1572 1535 if (!pList->mSourceSpec.fDryRun) 1573 1536 { … … 1577 1540 if (!fCopyIntoExisting) 1578 1541 { 1542 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 1543 Utf8StrFmt(GuestSession::tr("Destination directory \"%s\" already exists"), 1544 strDstAbs.c_str())); 1579 1545 break; 1580 1546 } … … 1589 1555 1590 1556 case RTFS_TYPE_FILE: 1557 LogFlowFunc(("File '%s': %s -> %s\n", pEntry->strPath.c_str(), strSrcAbs.c_str(), strDstAbs.c_str())); 1591 1558 if (!pList->mSourceSpec.fDryRun) 1592 1559 rc = fileCopyFromGuest(strSrcAbs, strDstAbs, FileCopyFlag_None); … … 1650 1617 1651 1618 ULONG cOperations = 0; 1619 Utf8Str strErrorInfo; 1620 1621 /** 1622 * Note: We need to build up the file/directory here instead of GuestSessionTaskCopyTo::Run 1623 * because the caller expects a ready-for-operation progress object on return. 1624 * The progress object will have a variable operation count, based on the elements to 1625 * be processed. 1626 */ 1652 1627 1653 1628 GuestSessionFsSourceSet::iterator itSrc = mSources.begin(); … … 1666 1641 if ( !strDst.endsWith("/") 1667 1642 && !strDst.endsWith("\\")) 1668 strDst += mPathStyle;1643 strDst += "/"; 1669 1644 1670 1645 strDst += Utf8StrFmt("%s", RTPathFilenameEx(strSrc.c_str(), mfPathStyle)); 1671 1646 } 1672 1647 } 1648 1649 LogFlowFunc(("strSrc=%s, strDst=%s\n", strSrc.c_str(), strDst.c_str())); 1673 1650 1674 1651 RTFSOBJINFO srcFsObjInfo; 1675 1652 rc = RTPathQueryInfo(strSrc.c_str(), &srcFsObjInfo, RTFSOBJATTRADD_NOTHING); 1676 1653 if (RT_FAILURE(rc)) 1654 { 1655 strErrorInfo = Utf8StrFmt(GuestSession::tr("No such source file/directory: %s"), strSrc.c_str()); 1677 1656 break; 1657 } 1678 1658 1679 1659 if (RTFS_IS_DIRECTORY(srcFsObjInfo.Attr.fMode)) … … 1681 1661 if (itSrc->enmType != FsObjType_Directory) 1682 1662 { 1663 strErrorInfo = Utf8StrFmt(GuestSession::tr("Source is not a file: %s"), strSrc.c_str()); 1683 1664 rc = VERR_NOT_A_FILE; 1684 1665 break; … … 1689 1670 if (itSrc->enmType == FsObjType_Directory) 1690 1671 { 1672 strErrorInfo = Utf8StrFmt(GuestSession::tr("Source is not a directory: %s"), strSrc.c_str()); 1691 1673 rc = VERR_NOT_A_DIRECTORY; 1692 1674 break; 1693 1675 } 1694 1676 } 1695 1696 LogFlowFunc(("strSrc=%s, strDst=%s\n", strSrc.c_str(), strDst.c_str()));1697 1677 1698 1678 FsList *pFsList = NULL; … … 1712 1692 1713 1693 if (RT_FAILURE(rc)) 1714 break; 1694 { 1695 delete pFsList; 1696 strErrorInfo = Utf8StrFmt(GuestSession::tr("Error adding source '%s' to list: %Rrc"), strSrc.c_str(), rc); 1697 break; 1698 } 1715 1699 1716 1700 mVecLists.push_back(pFsList); … … 1728 1712 } 1729 1713 1730 if (RT_SUCCESS(rc)) 1731 { 1732 Utf8Str strFirstOp; 1733 if (cOperations) /* Use the first element as description (if available). */ 1734 { 1735 Assert(mVecLists.size()); 1736 Assert(mVecLists[0]->mVecEntries.size()); 1737 1738 strFirstOp = mDest + mVecLists[0]->mVecEntries[0]->strPath; 1739 } 1714 if (cOperations) /* Use the first element as description (if available). */ 1715 { 1716 Assert(mVecLists.size()); 1717 Assert(mVecLists[0]->mVecEntries.size()); 1718 1719 Utf8Str strFirstOp = mDest + mVecLists[0]->mVecEntries[0]->strPath; 1740 1720 1741 1721 hr = pProgress->init(static_cast<IGuestSession*>(mSession), Bstr(mDesc).raw(), … … 1743 1723 Bstr(strFirstOp).raw()); 1744 1724 } 1745 1746 LogFlowFunc(("rc=%Rrc\n", rc)); 1725 else /* If no operations have been defined, go with an "empty" progress object when will be used for error handling. */ 1726 hr = pProgress->init(static_cast<IGuestSession*>(mSession), Bstr(mDesc).raw(), 1727 TRUE /* aCancelable */, 1 /* cOperations */, Bstr(mDesc).raw()); 1728 1729 if (RT_FAILURE(rc)) 1730 { 1731 Assert(strErrorInfo.isNotEmpty()); 1732 setProgressErrorMsg(VBOX_E_IPRT_ERROR, strErrorInfo); 1733 } 1734 1735 LogFlowFunc(("Returning %Rhrc (%Rrc)\n", hr, rc)); 1747 1736 return hr; 1748 1737 } … … 1794 1783 } 1795 1784 1796 LogFlowFunc(("Entry '%s': %s -> %s\n", pEntry->strPath.c_str(), strSrcAbs.c_str(), strDstAbs.c_str()));1797 1798 1785 switch (pEntry->fMode & RTFS_TYPE_MASK) 1799 1786 { 1800 1787 case RTFS_TYPE_DIRECTORY: 1788 LogFlowFunc(("Directory '%s': %s -> %s\n", pEntry->strPath.c_str(), strSrcAbs.c_str(), strDstAbs.c_str())); 1801 1789 if (!pList->mSourceSpec.fDryRun) 1802 1790 { 1803 1791 rc = directoryCreate(strDstAbs.c_str(), DirectoryCreateFlag_None, fDirMode, fFollowSymlinks); 1804 if ( rc == V WRN_ALREADY_EXISTS1792 if ( rc == VERR_ALREADY_EXISTS 1805 1793 && !fCopyIntoExisting) 1806 1794 { 1795 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 1796 Utf8StrFmt(GuestSession::tr("Destination directory \"%s\" already exists"), 1797 strDstAbs.c_str())); 1807 1798 break; 1808 1799 } … … 1811 1802 1812 1803 case RTFS_TYPE_FILE: 1804 LogFlowFunc(("File '%s': %s -> %s\n", pEntry->strPath.c_str(), strSrcAbs.c_str(), strDstAbs.c_str())); 1813 1805 if (!pList->mSourceSpec.fDryRun) 1814 1806 rc = fileCopyToGuest(strSrcAbs, strDstAbs, FileCopyFlag_None);
Note:
See TracChangeset
for help on using the changeset viewer.