VirtualBox

Changeset 42765 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Aug 10, 2012 8:12:35 PM (12 years ago)
Author:
vboxsync
Message:

Main: GuestSession::DirectoryCreateTemp() (untested).

File:
1 edited

Legend:

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

    r42759 r42765  
    22032203}
    22042204
    2205 STDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, BOOL aSecure, BSTR *aDirectory)
     2205STDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, BSTR *aDirectory)
    22062206{
    22072207#ifndef VBOX_WITH_GUEST_CONTROL
     
    22232223    {
    22242224        Utf8Str strTemplate(aTemplate);
     2225        Utf8Str strPath(aPath);
    22252226        procInfo.mName    = Utf8StrFmt(tr("Creating temporary directory from template \"%s\"",
    22262227                                       strTemplate.c_str()));
     
    22302231        /* Construct arguments. */
    22312232        procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
    2232         procInfo.mArguments.push_back(Bstr(aTemplate)); /* The template we want to use. */
     2233        if (strPath.length())  /* Otherwise use /tmp or equivalent. */
     2234        {
     2235            procInfo.mArguments.push_back(Utf8Str("-d"));
     2236            procInfo.mArguments.push_back(strPath);
     2237        }
     2238        procInfo.mArguments.push_back(strTemplate);
    22332239    }
    22342240    catch (...)
     
    22842290    if (RT_SUCCESS(rc))
    22852291    {
    2286         streamBlock.GetString("name");
     2292        const char *pcszName = streamBlock.GetString("name");
     2293        if (!pcszName)
     2294            return setError(E_FAIL, tr("No name returned after creating temporary directory"));
    22872295        int64_t i64rc;
    22882296        if (RT_FAILURE(streamBlock.GetInt64Ex("rc", &i64rc)))
    22892297            return setError(E_FAIL, tr("No return code after creating temporary directory"));
    22902298        if (RT_FAILURE((int)i64rc))
    2291             return setError(VBOX_E_IPRT_ERROR, tr("File deletion failed: %Rrc"), rc);
     2299        {
     2300            HRESULT hrc =   i64rc == VERR_INVALID_PARAMETER ? E_INVALIDARG
     2301                          : i64rc == VERR_NOT_SUPPORTED ? VBOX_E_NOT_SUPPORTED
     2302                          : VBOX_E_IPRT_ERROR;
     2303            return setError(hrc, tr("Temporary directory creation failed: %Rrc"),
     2304                            (int)i64rc);
     2305        }
     2306        try
     2307        {
     2308            Bstr(pcszName).cloneTo(aDirectory);
     2309        }
     2310        catch (...)
     2311        {
     2312            return E_OUTOFMEMORY;
     2313        }
    22922314    }
    22932315    else
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