VirtualBox

Ignore:
Timestamp:
Aug 8, 2012 1:41:32 PM (12 years ago)
Author:
vboxsync
Message:

Main/GuestCtrl: fixes to FileDelete and DirectoryCreateTemp.

File:
1 edited

Legend:

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

    r42673 r42682  
    17531753                                       strTemplate.c_str()));
    17541754        procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKTEMP);
     1755        procInfo.mFlags   =   ProcessCreateFlag_Hidden
     1756                            | ProcessCreateFlag_WaitForStdOut;
    17551757        /* Construct arguments. */
    17561758        procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
     
    17751777                                   30 * 1000 /* Timeout */, waitRes);
    17761778            if (   RT_FAILURE(rc)
    1777                 || waitRes.mResult != ProcessWaitResult_StdOut)
     1779                || waitRes.mResult == ProcessWaitResult_Terminate
     1780                || waitRes.mResult == ProcessWaitResult_Error
     1781                || waitRes.mResult == ProcessWaitResult_Timeout)
    17781782            {
    17791783                break;
     
    17861790                break;
    17871791
    1788             rc = streamOut.AddData(byBuf, cbRead);
    1789             if (RT_FAILURE(rc))
    1790                 break;
     1792            if (cbRead)
     1793            {
     1794                rc = streamOut.AddData(byBuf, cbRead);
     1795                if (RT_FAILURE(rc))
     1796                    break;
     1797            }
    17911798        }
    17921799
     
    17941801                         rc, cbRead, streamOut.GetSize()));
    17951802    }
    1796 
     1803    else
     1804        return setError(E_FAIL, tr("Error while starting temporary directory creation tool on guest: %Rrc"), rc);
    17971805    if (RT_FAILURE(rc))
    1798         return setError(E_FAIL, tr("Error while creating temporary directory: %Rrc"), rc);
     1806        return setError(E_FAIL, tr("Error while running temporary directory creation tool: %Rrc"), rc);
    17991807    if (!streamOut.GetSize())
    18001808        return setError(E_FAIL, tr("No return code after creating temporary directory"));
     
    18071815        if (RT_FAILURE(streamBlock.GetInt64Ex("rc", &i64rc)))
    18081816            return setError(E_FAIL, tr("No return code after creating temporary directory"));
    1809         // *aReturnCode = (LONG)i64rc;
     1817        if (RT_FAILURE((int)i64rc))
     1818            return setError(VBOX_E_IPRT_ERROR, tr("File deletion failed: %Rrc"), rc);
    18101819    }
    18111820    else
     
    21522161                                       strPath.c_str()));
    21532162        procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_RM);
     2163        procInfo.mFlags   =   ProcessCreateFlag_Hidden
     2164                            | ProcessCreateFlag_WaitForStdOut;
    21542165        /* Construct arguments. */
    21552166        procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
     
    21642175    rc = processCreateExInteral(procInfo, pProcess);
    21652176    if (RT_SUCCESS(rc))
     2177        rc = pProcess->startProcess();
     2178    if (RT_SUCCESS(rc))
    21662179    {
    21672180        GuestProcessWaitResult waitRes;
     
    21742187                                   30 * 1000 /* Timeout */, waitRes);
    21752188            if (   RT_FAILURE(rc)
    2176                 || waitRes.mResult != ProcessWaitResult_StdOut)
     2189                || waitRes.mResult == ProcessWaitResult_Terminate
     2190                || waitRes.mResult == ProcessWaitResult_Error
     2191                || waitRes.mResult == ProcessWaitResult_Timeout)
    21772192            {
    21782193                break;
     
    21852200                break;
    21862201
    2187             rc = streamOut.AddData(byBuf, cbRead);
    2188             if (RT_FAILURE(rc))
    2189                 break;
     2202            if (cbRead)
     2203            {
     2204                rc = streamOut.AddData(byBuf, cbRead);
     2205                if (RT_FAILURE(rc))
     2206                    break;
     2207            }
    21902208        }
    21912209
     
    21932211                         rc, cbRead, streamOut.GetSize()));
    21942212    }
    2195 
     2213    else
     2214        return setError(E_FAIL, tr("Error while starting delete tool on guest: %Rrc"), rc);
    21962215    if (RT_FAILURE(rc))
    2197         return setError(E_FAIL, tr("Error while deleting file: %Rrc"), rc);
     2216        return setError(E_FAIL, tr("Error while running delete tool on guest: %Rrc"), rc);
    21982217    if (!streamOut.GetSize())
    21992218        return setError(E_FAIL, tr("No return code after deleting file"));
     
    22062225        if (RT_FAILURE(streamBlock.GetInt64Ex("rc", &i64rc)))
    22072226            return setError(E_FAIL, tr("No return code after deleting file"));
     2227        if (RT_FAILURE((int)i64rc))
     2228            return setError(VBOX_E_IPRT_ERROR, tr("File deletion failed: %Rrc"), rc);
    22082229    }
    22092230    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