third_party/virtualbox/src/VBox/Main/src-client/GuestSessionImpl.cpp
/**
 * Queries information of a file system object (file, directory, ...).
 *
 * @return  IPRT status code.
 * @param   strPath             Path to file system object to query information for.
 * @param   fFollowSymlinks     Whether to follow symbolic links or not.
 * @param   objData             Where to return the file system object data, if found.
 * @param   pGuestRc            Guest rc, when returning VERR_GSTCTL_GUEST_ERROR.
 *                              Any other return code indicates some host side error.
 */
Queries information of a file system object (file, directory, ...).
@return  IPRT status code.
@param   strPath             Path to file system object to query information for.
@param   fFollowSymlinks     Whether to follow symbolic links or not.
@param   objData             Where to return the file system object data, if found.
@param   pGuestRc            Guest rc, when returning VERR_GSTCTL_GUEST_ERROR.
Any other return code indicates some host side error.
Queries information of a file system object ( file directory ... ) . @return IPRT status code . @param strPath Path to file system object to query information for . @param fFollowSymlinks Whether to follow symbolic links or not . @param objData Where to return the file system object data if found . @param pGuestRc Guest rc when returning VERR_GSTCTL_GUEST_ERROR . Any other return code indicates some host side error .
int GuestSession::i_fsQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc)
{
    LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
    GuestProcessStartupInfo procInfo;
    procInfo.mFlags      = ProcessCreateFlag_WaitForStdOut;
    try
    {
        procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_STAT);
        procInfo.mArguments.push_back(procInfo.mExecutable); 
        procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
        if (fFollowSymlinks)
            procInfo.mArguments.push_back(Utf8Str("-L"));
        procInfo.mArguments.push_back("--"); 
        procInfo.mArguments.push_back(strPath);
    }
    catch (std::bad_alloc &)
    {
        Log(("Out of memory!\n"));
        return VERR_NO_MEMORY;
    }
    int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS;
    GuestCtrlStreamObjects stdOut;
    int vrc = GuestProcessTool::i_runEx(this, procInfo,
                                        &stdOut, 1 ,
                                        &vrcGuest);
    if (!GuestProcess::i_isGuestError(vrc))
    {
        if (!stdOut.empty())
        {
            vrc = objData.FromStat(stdOut.at(0));
            if (RT_FAILURE(vrc))
            {
                vrcGuest = vrc;
                if (pGuestRc)
                    *pGuestRc = vrc;
                vrc = VERR_GSTCTL_GUEST_ERROR;
            }
        }
        else
            vrc = VERR_BROKEN_PIPE;
    }
    else if (pGuestRc)
        *pGuestRc = vrcGuest;
    LogFlowThisFunc(("Returning vrc=%Rrc, vrcGuest=%Rrc\n", vrc, vrcGuest));
    return vrc;
}
int GuestSession :: i_fsQueryInfoInternal ( const Utf8Str & strPath , bool fFollowSymlinks , GuestFsObjData & objData , int * pGuestRc ) { LogFlowThisFunc ( ( " \n " , strPath . c_str ( ) ) ) ; GuestProcessStartupInfo procInfo ; procInfo . mFlags = ProcessCreateFlag_WaitForStdOut ; try { procInfo . mExecutable = Utf8Str ( VBOXSERVICE_TOOL_STAT ) ; procInfo . mArguments . push_back ( procInfo . mExecutable ) ; procInfo . mArguments . push_back ( Utf8Str ( " " ) ) ; if ( fFollowSymlinks ) procInfo . mArguments . push_back ( Utf8Str ( " " ) ) ; procInfo . mArguments . push_back ( " " ) ; procInfo . mArguments . push_back ( strPath ) ; } catch ( std :: bad_alloc & ) { Log ( ( " \n " ) ) ; return VERR_NO_MEMORY ; } int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS ; GuestCtrlStreamObjects stdOut ; int vrc = GuestProcessTool :: i_runEx ( this , procInfo , & stdOut , 1 , & vrcGuest ) ; if ( ! GuestProcess :: i_isGuestError ( vrc ) ) { if ( ! stdOut . empty ( ) ) { vrc = objData . FromStat ( stdOut . at ( 0 ) ) ; if ( RT_FAILURE ( vrc ) ) { vrcGuest = vrc ; if ( pGuestRc ) * pGuestRc = vrc ; vrc = VERR_GSTCTL_GUEST_ERROR ; } } else vrc = VERR_BROKEN_PIPE ; } else if ( pGuestRc ) * pGuestRc = vrcGuest ; LogFlowThisFunc ( ( " \n " , vrc , vrcGuest ) ) ; return vrc ; }
Queries information of a file system object (file, directory, ...).
Queries information of a file system object ( file directory ... ) .
/** @todo Merge this with IGuestFile::queryInfo(). */ /* Set argv0. */ /* strPath could be '--help', which is a valid filename. */ /* cStrmOutObjects */