VirtualBox

Changeset 40684 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 28, 2012 2:41:08 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77138
Message:

VBoxManage/GuestCtrl: Progress handling additions, less verbose output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp

    r40398 r40684  
    401401}
    402402
    403 static int ctrlPrintProgressError(ComPtr<IProgress> progress)
    404 {
    405     int rc;
    406     BOOL fCanceled;
    407     if (   SUCCEEDED(progress->COMGETTER(Canceled(&fCanceled)))
    408         && fCanceled)
    409     {
    410         rc = VERR_CANCELLED;
    411     }
    412     else
    413     {
    414         com::ProgressErrorInfo ErrInfo(progress);
    415         rc = ctrlPrintError(ErrInfo);
    416     }
    417     return rc;
     403static int ctrlPrintProgressError(ComPtr<IProgress> pProgress)
     404{
     405    int vrc = VINF_SUCCESS;
     406    HRESULT rc;
     407
     408    do
     409    {
     410        BOOL fCanceled;
     411        CHECK_ERROR_BREAK(pProgress, COMGETTER(Canceled)(&fCanceled));
     412        if (!fCanceled)
     413        {
     414            LONG rcProc;
     415            CHECK_ERROR_BREAK(pProgress, COMGETTER(ResultCode)(&rcProc));
     416            if (FAILED(rcProc))
     417                vrc = ctrlPrintError(com::ProgressErrorInfo(pProgress));
     418        }
     419
     420    } while(0);
     421
     422    if (FAILED(rc))
     423        AssertMsgStmt(NULL, ("Could not lookup progress information\n"), vrc = VERR_COM_UNEXPECTED);
     424
     425    return vrc;
    418426}
    419427
     
    11111119
    11121120    bool fDirExists;
    1113     int rc = ctrlCopyDirExists(pContext, pContext->fHostToGuest, pszDir, &fDirExists);
    1114     if (   RT_SUCCESS(rc)
     1121    int vrc = ctrlCopyDirExists(pContext, pContext->fHostToGuest, pszDir, &fDirExists);
     1122    if (   RT_SUCCESS(vrc)
    11151123        && fDirExists)
    11161124    {
     
    11201128    }
    11211129
     1130    /* If querying for a directory existence fails there's no point of even trying
     1131     * to create such a directory. */
     1132    if (RT_FAILURE(vrc))
     1133        return vrc;
     1134
    11221135    if (pContext->fVerbose)
    11231136        RTPrintf("Creating directory \"%s\" ...\n", pszDir);
     
    11281141    if (pContext->fHostToGuest) /* We want to create directories on the guest. */
    11291142    {
    1130         HRESULT hrc = pContext->pGuest->DirectoryCreate(Bstr(pszDir).raw(),
    1131                                                         Bstr(pContext->pszUsername).raw(), Bstr(pContext->pszPassword).raw(),
    1132                                                         0700, DirectoryCreateFlag_Parents);
    1133         if (FAILED(hrc))
    1134             rc = ctrlPrintError(pContext->pGuest, COM_IIDOF(IGuest));
     1143        HRESULT rc = pContext->pGuest->DirectoryCreate(Bstr(pszDir).raw(),
     1144                                                       Bstr(pContext->pszUsername).raw(), Bstr(pContext->pszPassword).raw(),
     1145                                                       0700, DirectoryCreateFlag_Parents);
     1146        if (FAILED(rc))
     1147            vrc = ctrlPrintError(pContext->pGuest, COM_IIDOF(IGuest));
    11351148    }
    11361149    else /* ... or on the host. */
    11371150    {
    1138         rc = RTDirCreateFullPath(pszDir, 0700);
    1139         if (rc == VERR_ALREADY_EXISTS)
    1140             rc = VINF_SUCCESS;
    1141     }
    1142     return rc;
     1151        vrc = RTDirCreateFullPath(pszDir, 0700);
     1152        if (vrc == VERR_ALREADY_EXISTS)
     1153            vrc = VINF_SUCCESS;
     1154    }
     1155    return vrc;
    11431156}
    11441157
     
    13311344        else
    13321345            rc = progress->WaitForCompletion(-1 /* No timeout */);
    1333         CHECK_PROGRESS_ERROR(progress, ("File copy failed"));
    1334         if (FAILED(rc))
    1335             vrc = ctrlPrintError(pContext->pGuest, COM_IIDOF(IGuest));
     1346        if (SUCCEEDED(rc))
     1347            CHECK_PROGRESS_ERROR(progress, ("File copy failed"));
     1348        vrc = ctrlPrintProgressError(progress);
    13361349    }
    13371350
     
    22682281                if (!fExists)
    22692282                {
    2270                     RTPrintf("Cannot stat for element \"%s\": No such file or directory\n",
    2271                              it->first.c_str());
     2283                    if (fVerbose)
     2284                        RTPrintf("Cannot stat for element \"%s\": No such file or directory\n",
     2285                                 it->first.c_str());
    22722286                    rcExit = RTEXITCODE_FAILURE;
    22732287                }
     
    23682382
    23692383        HRESULT rc = S_OK;
    2370         ComPtr<IProgress> progress;
     2384        ComPtr<IProgress> pProgress;
    23712385        CHECK_ERROR(guest, UpdateGuestAdditions(Bstr(Utf8Source).raw(),
    23722386                                                /* Wait for whole update process to complete. */
    23732387                                                AdditionsUpdateFlag_None,
    2374                                                 progress.asOutParam()));
     2388                                                pProgress.asOutParam()));
    23752389        if (FAILED(rc))
    23762390            vrc = ctrlPrintError(guest, COM_IIDOF(IGuest));
     
    23782392        {
    23792393            if (fVerbose)
    2380                 rc = showProgress(progress);
     2394                rc = showProgress(pProgress);
    23812395            else
    2382                 rc = progress->WaitForCompletion(-1 /* No timeout */);
    2383             CHECK_PROGRESS_ERROR(progress, ("Guest additions update failed"));
    2384             if (FAILED(rc))
    2385                 vrc = ctrlPrintError(guest, COM_IIDOF(IGuest));
    2386             else if (   SUCCEEDED(rc)
    2387                      && fVerbose)
     2396                rc = pProgress->WaitForCompletion(-1 /* No timeout */);
     2397
     2398            if (SUCCEEDED(rc))
     2399                CHECK_PROGRESS_ERROR(pProgress, ("Guest additions update failed"));
     2400            vrc = ctrlPrintProgressError(pProgress);
     2401            if (   RT_SUCCESS(vrc)
     2402                && fVerbose)
    23882403            {
    23892404                RTPrintf("Guest Additions update successful\n");
Note: See TracChangeset for help on using the changeset viewer.

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