~ubuntu-branches/ubuntu/quantal/virtualbox/quantal

« back to all changes in this revision

Viewing changes to src/VBox/Main/src-client/GuestCtrlImplDir.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-04-05 12:41:55 UTC
  • mfrom: (3.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120405124155-i7b39tv5ddwhubbe
Tags: 4.1.12-dfsg-2
* Upstream has replaced the 4.1.12 tarball with a new one that fixes a
  crash when creating host only interfaces. (Closes: #667460)
  - Add 36-tarball-respin.patch which contains the diff between the old
    and the new tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
        }
99
99
    }
100
100
 
101
 
    HRESULT rc = S_OK;
 
101
    HRESULT hr;
102
102
    try
103
103
    {
104
104
        Utf8Str Utf8Directory(aDirectory);
121
121
        }
122
122
        args.push_back(Bstr(Utf8Directory).raw());  /* The directory we want to create. */
123
123
 
124
 
        rc = executeAndWaitForTool(Bstr(VBOXSERVICE_TOOL_MKDIR).raw(), Bstr("Creating directory").raw(),
 
124
        ULONG uPID;
 
125
        ComPtr<IProgress> pProgress;
 
126
        hr = executeAndWaitForTool(Bstr(VBOXSERVICE_TOOL_MKDIR).raw(), Bstr("Creating directory").raw(),
125
127
                                   ComSafeArrayAsInParam(args),
126
128
                                   ComSafeArrayAsInParam(env),
127
129
                                   aUsername, aPassword,
128
130
                                   ExecuteProcessFlag_None,
129
131
                                   NULL, NULL,
130
 
                                   NULL /* Progress */, NULL /* PID */);
 
132
                                   pProgress.asOutParam(), &uPID);
 
133
        if (SUCCEEDED(hr))
 
134
        {
 
135
            hr = setErrorFromProgress(pProgress);
 
136
            pProgress.setNull();
 
137
        }
131
138
    }
132
139
    catch (std::bad_alloc &)
133
140
    {
134
 
        rc = E_OUTOFMEMORY;
 
141
        hr = E_OUTOFMEMORY;
135
142
    }
136
 
    return rc;
 
143
    return hr;
137
144
}
138
145
 
139
146
/**
298
305
    if (it != mGuestDirectoryMap.end())
299
306
    {
300
307
#ifdef DEBUG
301
 
        it->second.mStream.Dump("/tmp/stream.txt");
 
308
        it->second.mStream.Dump("c:\\temp\\stream.txt");
302
309
#endif
303
310
        return executeStreamGetNextBlock(it->second.mPID,
304
311
                                         ProcessOutputFlag_None /* StdOut */,
481
488
         * Execute guest process.
482
489
         */
483
490
        ULONG uPID;
 
491
        ComPtr<IProgress> pProgress;
484
492
        GuestCtrlStreamObjects stdOut;
485
493
        hr = executeAndWaitForTool(Bstr(VBOXSERVICE_TOOL_STAT).raw(), Bstr("Querying directory information").raw(),
486
494
                                   ComSafeArrayAsInParam(args),
488
496
                                   aUsername, aPassword,
489
497
                                   ExecuteProcessFlag_WaitForStdOut,
490
498
                                   &stdOut, NULL /* stdErr */,
491
 
                                   NULL /* Progress */, &uPID);
 
499
                                   pProgress.asOutParam(), &uPID);
492
500
        if (SUCCEEDED(hr))
493
501
        {
494
 
            int rc = VINF_SUCCESS;
495
 
            if (stdOut.size())
 
502
            hr = setErrorFromProgress(pProgress);
 
503
            if (SUCCEEDED(hr))
496
504
            {
497
 
                const char *pszFsType = stdOut[0].GetString("ftype");
498
 
                if (!pszFsType) /* Attribute missing? */
499
 
                     rc = VERR_PATH_NOT_FOUND;
500
 
                if (   RT_SUCCESS(rc)
501
 
                    && strcmp(pszFsType, "d")) /* Directory? */
502
 
                {
503
 
                     rc = VERR_PATH_NOT_FOUND;
504
 
                     /* This is not critical for Main, so don't set hr --
505
 
                      * we will take care of rc then. */
506
 
                }
507
 
                if (   RT_SUCCESS(rc)
508
 
                    && aObjInfo) /* Do we want object details? */
509
 
                {
510
 
                    rc = executeStreamQueryFsObjInfo(aDirectory, stdOut[0],
511
 
                                                     aObjInfo, enmAddAttribs);
512
 
                }
 
505
                int rc = VINF_SUCCESS;
 
506
                if (stdOut.size())
 
507
                {
 
508
                    const char *pszFsType = stdOut[0].GetString("ftype");
 
509
                    if (!pszFsType) /* Attribute missing? */
 
510
                         rc = VERR_PATH_NOT_FOUND;
 
511
                    if (   RT_SUCCESS(rc)
 
512
                        && strcmp(pszFsType, "d")) /* Directory? */
 
513
                    {
 
514
                         rc = VERR_PATH_NOT_FOUND;
 
515
                         /* This is not critical for Main, so don't set hr --
 
516
                          * we will take care of rc then. */
 
517
                    }
 
518
                    if (   RT_SUCCESS(rc)
 
519
                        && aObjInfo) /* Do we want object details? */
 
520
                    {
 
521
                        rc = executeStreamQueryFsObjInfo(aDirectory, stdOut[0],
 
522
                                                         aObjInfo, enmAddAttribs);
 
523
                    }
 
524
                }
 
525
                else
 
526
                    rc = VERR_NO_DATA;
 
527
 
 
528
                if (pRC)
 
529
                    *pRC = rc;
513
530
            }
514
 
            else
515
 
                rc = VERR_NO_DATA;
516
531
 
517
 
            if (pRC)
518
 
                *pRC = rc;
 
532
            pProgress.setNull();
519
533
        }
520
534
    }
521
535
    catch (std::bad_alloc &)