VirtualBox

Changeset 42808 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Aug 14, 2012 2:01:11 PM (12 years ago)
Author:
vboxsync
Message:

Guest Control 2.0: Update.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r42787 r42808  
    3838
    3939
     40/*
     41 * If the following define is enabled the Guest Additions update code also
     42 * checks for locations which were not supposed to happen due to not resolving
     43 * environment variables in VBoxService toolbox arguments. So a file copied
     44 * to "%TEMP%\foo.exe" became "C:\Windows\EMPfoo.exe".
     45 */
    4046#define VBOX_SERVICE_ENVARG_BUG
    4147
     
    14221428}
    14231429
    1424 int GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory)
     1430int GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags)
    14251431{
    14261432    LogFlowThisFunc(("strPath=%s, uMode=%x, uFlags=%x\n",
     
    14761482    }
    14771483
    1478     if (RT_FAILURE(rc))
    1479         return rc;
    1480 
    1481     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1482 
    1483     /* Create the directory object. */
    1484     HRESULT hr = pDirectory.createObject();
    1485     if (FAILED(hr))
    1486         return VERR_COM_UNEXPECTED;
    1487 
    1488     /* Note: There will be a race between creating and getting/initing the directory
    1489              object here. */
    1490     rc = pDirectory->init(this /* Parent */, strPath);
    1491     if (RT_FAILURE(rc))
    1492         return rc;
    1493 
    1494     /* Add the created directory to our vector. */
    1495     mData.mDirectories.push_back(pDirectory);
    1496 
    1497     LogFlowFunc(("Added new directory \"%s\" (Session: %RU32)\n",
    1498                  strPath.c_str(), mData.mId));
     1484    LogFlowFuncLeaveRC(rc);
     1485    return rc;
     1486}
     1487
     1488int GuestSession::directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData)
     1489{
     1490    LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
     1491
     1492    int rc = fsQueryInfoInternal(strPath, objData);
     1493    if (RT_SUCCESS(rc))
     1494    {
     1495        rc = objData.mType == FsObjType_Directory
     1496           ? VINF_SUCCESS : VERR_NOT_A_DIRECTORY;
     1497    }
    14991498
    15001499    LogFlowFuncLeaveRC(rc);
     
    17951794}
    17961795
    1797 /* Note: Will work on directories and others, too. */
    17981796int GuestSession::fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData)
     1797{
     1798    LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
     1799
     1800    int rc = fsQueryInfoInternal(strPath, objData);
     1801    if (RT_SUCCESS(rc))
     1802    {
     1803        rc = objData.mType == FsObjType_File
     1804           ? VINF_SUCCESS : VERR_NOT_A_FILE;
     1805    }
     1806
     1807    LogFlowFuncLeaveRC(rc);
     1808    return rc;
     1809}
     1810
     1811int GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize)
     1812{
     1813    AssertPtrReturn(pllSize, VERR_INVALID_POINTER);
     1814
     1815    GuestFsObjData objData;
     1816    int rc = fileQueryInfoInternal(strPath, objData);
     1817    if (RT_SUCCESS(rc))
     1818    {
     1819        if (objData.mType == FsObjType_File)
     1820            *pllSize = objData.mObjectSize;
     1821        else
     1822            rc = VERR_NOT_A_FILE;
     1823    }
     1824
     1825    return rc;
     1826}
     1827
     1828int GuestSession::fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData)
    17991829{
    18001830    LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
     
    18681898}
    18691899
    1870 int GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize)
    1871 {
    1872     AssertPtrReturn(pllSize, VERR_INVALID_POINTER);
    1873 
    1874     GuestFsObjData objData;
    1875     int rc = fileQueryInfoInternal(strPath, objData);
    1876     if (RT_SUCCESS(rc))
    1877     {
    1878         if (objData.mType == FsObjType_File)
    1879             *pllSize = objData.mObjectSize;
    1880         else
    1881             rc = VERR_NOT_A_FILE;
    1882     }
    1883 
    1884     return rc;
    1885 }
    1886 
    18871900const GuestCredentials& GuestSession::getCredentials(void)
    18881901{
     
    22382251
    22392252STDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode,
    2240                                            ComSafeArrayIn(DirectoryCreateFlag_T, aFlags), IGuestDirectory **aDirectory)
     2253                                           ComSafeArrayIn(DirectoryCreateFlag_T, aFlags))
    22412254{
    22422255#ifndef VBOX_WITH_GUEST_CONTROL
     
    22472260    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
    22482261        return setError(E_INVALIDARG, tr("No directory to create specified"));
    2249     /* aDirectory is optional. */
    22502262
    22512263    AutoCaller autoCaller(this);
     
    22692281
    22702282    ComObjPtr <GuestDirectory> pDirectory;
    2271     int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, fFlags, pDirectory);
    2272     if (RT_SUCCESS(rc))
    2273     {
    2274         if (aDirectory)
    2275         {
    2276             /* Return directory object to the caller. */
    2277             hr = pDirectory.queryInterfaceTo(aDirectory);
    2278         }
    2279         else
    2280         {
    2281             rc = directoryClose(pDirectory);
    2282             if (RT_FAILURE(rc))
    2283                 hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc);
    2284         }
    2285     }
    2286     else
     2283    int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, fFlags);
     2284    if (RT_FAILURE(rc))
    22872285    {
    22882286        switch (rc)
     
    24622460    LogFlowThisFuncEnter();
    24632461
    2464     AutoCaller autoCaller(this);
    2465     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    2466 
    2467     ReturnComNotImplemented();
     2462    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
     2463        return setError(E_INVALIDARG, tr("No directory to query information for specified"));
     2464    CheckComArgOutPointerValid(aInfo);
     2465
     2466    AutoCaller autoCaller(this);
     2467    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     2468
     2469    HRESULT hr = S_OK;
     2470
     2471    GuestFsObjData objData;
     2472    int rc = directoryQueryInfoInternal(Utf8Str(aPath), objData);
     2473    if (RT_SUCCESS(rc))
     2474    {
     2475        if (objData.mType == FsObjType_Directory)
     2476        {
     2477            ComObjPtr<GuestFsObjInfo> pFsObjInfo;
     2478            hr = pFsObjInfo.createObject();
     2479            if (FAILED(hr))
     2480                return VERR_COM_UNEXPECTED;
     2481
     2482            rc = pFsObjInfo->init(objData);
     2483            if (RT_SUCCESS(rc))
     2484                hr = pFsObjInfo.queryInterfaceTo(aInfo);
     2485        }
     2486    }
     2487
     2488    if (RT_FAILURE(rc))
     2489    {
     2490        switch (rc)
     2491        {
     2492            /** @todo Add more errors here! */
     2493
     2494            case VERR_NOT_A_DIRECTORY:
     2495                hr = setError(VBOX_E_IPRT_ERROR, tr("Element exists but is not a directory"));
     2496                break;
     2497
     2498            default:
     2499                hr = setError(VBOX_E_IPRT_ERROR, tr("Querying directory information failed: %Rrc"), rc);
     2500                break;
     2501        }
     2502    }
     2503
     2504    return hr;
    24682505#endif /* VBOX_WITH_GUEST_CONTROL */
    24692506}
     
    27532790    LogFlowThisFuncEnter();
    27542791
    2755     AutoCaller autoCaller(this);
    2756     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    2757 
    2758     ReturnComNotImplemented();
     2792    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
     2793        return setError(E_INVALIDARG, tr("No file to query information for specified"));
     2794    CheckComArgOutPointerValid(aInfo);
     2795
     2796    AutoCaller autoCaller(this);
     2797    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     2798
     2799    HRESULT hr = S_OK;
     2800
     2801    GuestFsObjData objData;
     2802    int rc = fileQueryInfoInternal(Utf8Str(aPath), objData);
     2803    if (RT_SUCCESS(rc))
     2804    {
     2805        ComObjPtr<GuestFsObjInfo> pFsObjInfo;
     2806        hr = pFsObjInfo.createObject();
     2807        if (FAILED(hr))
     2808            return VERR_COM_UNEXPECTED;
     2809
     2810        rc = pFsObjInfo->init(objData);
     2811        if (RT_SUCCESS(rc))
     2812            hr = pFsObjInfo.queryInterfaceTo(aInfo);
     2813    }
     2814
     2815    if (RT_FAILURE(rc))
     2816    {
     2817        switch (rc)
     2818        {
     2819            /** @todo Add more errors here! */
     2820
     2821            case VERR_NOT_A_FILE:
     2822                hr = setError(VBOX_E_IPRT_ERROR, tr("Element exists but is not a file"));
     2823                break;
     2824
     2825            default:
     2826               hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file information failed: %Rrc"), rc);
     2827               break;
     2828        }
     2829    }
     2830
     2831    return hr;
    27592832#endif /* VBOX_WITH_GUEST_CONTROL */
    27602833}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette