VirtualBox

Changeset 71785 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 9, 2018 4:00:47 PM (7 years ago)
Author:
vboxsync
Message:

Guest Control/Main: Implemented GuestSession::fileOpenEx().

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r71648 r71785  
    261261    int                     i_fileUnregister(GuestFile *pFile);
    262262    int                     i_fileRemove(const Utf8Str &strPath, int *pGuestRc);
     263    int                     i_fileOpenEx(const com::Utf8Str &aPath, FileAccessMode_T aAccessMode, FileOpenAction_T aOpenAction,
     264                                         FileSharingMode_T aSharingMode, ULONG aCreationMode,
     265                                         const std::vector<FileOpenExFlag_T> &aFlags,
     266                                         ComObjPtr<GuestFile> &pFile, int *prcGuest);
    263267    int                     i_fileOpen(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc);
    264268    int                     i_fileQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r71648 r71785  
    12481248}
    12491249
    1250 int GuestSession::i_fileOpen(const GuestFileOpenInfo &openInfo,
    1251                              ComObjPtr<GuestFile> &pFile, int *prcGuest)
    1252 {
    1253     LogFlowThisFunc(("strFile=%s, enmAccessMode=%d (%s) enmOpenAction=%d (%s) uCreationMode=%RU32 mfOpenEx=%RU32\n",
    1254                      openInfo.mFileName.c_str(), openInfo.mAccessMode, openInfo.mpszAccessMode,
    1255                      openInfo.mOpenAction, openInfo.mpszOpenAction, openInfo.mCreationMode, openInfo.mfOpenEx));
     1250int GuestSession::i_fileOpenEx(const com::Utf8Str &aPath, FileAccessMode_T aAccessMode, FileOpenAction_T aOpenAction,
     1251                               FileSharingMode_T aSharingMode, ULONG aCreationMode, const std::vector<FileOpenExFlag_T> &aFlags,
     1252                               ComObjPtr<GuestFile> &pFile, int *prcGuest)
     1253{
     1254    GuestFileOpenInfo openInfo;
     1255    RT_ZERO(openInfo);
     1256
     1257    openInfo.mFileName     = aPath;
     1258    openInfo.mCreationMode = aCreationMode;
     1259    openInfo.mAccessMode   = aAccessMode;
     1260    openInfo.mOpenAction   = aOpenAction;
     1261    openInfo.mSharingMode  = aSharingMode;
     1262
     1263    /* Combine and validate flags. */
     1264    uint32_t fOpenEx = 0;
     1265    for (size_t i = 0; i < aFlags.size(); i++)
     1266        fOpenEx = aFlags[i];
     1267    if (fOpenEx)
     1268        return VERR_INVALID_PARAMETER; /* FileOpenExFlag not implemented yet. */
     1269    openInfo.mfOpenEx = fOpenEx;
     1270
     1271    return i_fileOpen(openInfo, pFile, prcGuest);
     1272}
     1273
     1274int GuestSession::i_fileOpen(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *prcGuest)
     1275{
     1276    LogFlowThisFunc(("strFile=%s, enmAccessMode=0x%x, enmOpenAction=0x%x, uCreationMode=%RU32, mfOpenEx=%RU32\n",
     1277                     openInfo.mFileName.c_str(), openInfo.mAccessMode, openInfo.mOpenAction, openInfo.mCreationMode,
     1278                     openInfo.mfOpenEx));
    12561279
    12571280    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    34273450    openInfo.mCreationMode = aCreationMode;
    34283451
    3429     /* convert + validate aAccessMode to the old format. */
    3430     openInfo.mAccessMode = aAccessMode;
     3452    /* Validate aAccessMode. */
    34313453    switch (aAccessMode)
    34323454    {
    3433         case (FileAccessMode_T)FileAccessMode_ReadOnly:  openInfo.mpszAccessMode = "r"; break;
    3434         case (FileAccessMode_T)FileAccessMode_WriteOnly: openInfo.mpszAccessMode = "w"; break;
    3435         case (FileAccessMode_T)FileAccessMode_ReadWrite: openInfo.mpszAccessMode = "r+"; break;
     3455        case (FileAccessMode_T)FileAccessMode_ReadOnly:
     3456            RT_FALL_THRU();
     3457        case (FileAccessMode_T)FileAccessMode_WriteOnly:
     3458            RT_FALL_THRU();
     3459        case (FileAccessMode_T)FileAccessMode_ReadWrite:
     3460            openInfo.mAccessMode = aAccessMode;
     3461            break;
    34363462        case (FileAccessMode_T)FileAccessMode_AppendOnly:
    34373463            RT_FALL_THRU();
     
    34423468    }
    34433469
    3444     /* convert + validate aOpenAction to the old format. */
    3445     openInfo.mOpenAction = aOpenAction;
     3470    /* Validate aOpenAction to the old format. */
    34463471    switch (aOpenAction)
    34473472    {
    3448         case (FileOpenAction_T)FileOpenAction_OpenExisting:          openInfo.mpszOpenAction = "oe"; break;
    3449         case (FileOpenAction_T)FileOpenAction_OpenOrCreate:          openInfo.mpszOpenAction = "oc"; break;
    3450         case (FileOpenAction_T)FileOpenAction_CreateNew:             openInfo.mpszOpenAction = "ce"; break;
    3451         case (FileOpenAction_T)FileOpenAction_CreateOrReplace:       openInfo.mpszOpenAction = "ca"; break;
    3452         case (FileOpenAction_T)FileOpenAction_OpenExistingTruncated: openInfo.mpszOpenAction = "ot"; break;
     3473        case (FileOpenAction_T)FileOpenAction_OpenExisting:
     3474            RT_FALL_THRU();
     3475        case (FileOpenAction_T)FileOpenAction_OpenOrCreate:
     3476            RT_FALL_THRU();
     3477        case (FileOpenAction_T)FileOpenAction_CreateNew:
     3478            RT_FALL_THRU();
     3479        case (FileOpenAction_T)FileOpenAction_CreateOrReplace:
     3480            RT_FALL_THRU();
     3481        case (FileOpenAction_T)FileOpenAction_OpenExistingTruncated:
     3482            RT_FALL_THRU();
    34533483        case (FileOpenAction_T)FileOpenAction_AppendOrCreate:
    3454             openInfo.mpszOpenAction = "oa"; /** @todo get rid of this one and implement AppendOnly/AppendRead. */
     3484            openInfo.mOpenAction = aOpenAction;
    34553485            break;
    34563486        default:
     
    34583488    }
    34593489
    3460     /* validate aSharingMode */
    3461     openInfo.mSharingMode = aSharingMode;
     3490    /* Validate aSharingMode. */
    34623491    switch (aSharingMode)
    34633492    {
    3464         case (FileSharingMode_T)FileSharingMode_All: /* OK */ break;
     3493        case (FileSharingMode_T)FileSharingMode_All:
     3494            openInfo.mSharingMode = aSharingMode;
     3495            break;
    34653496        case (FileSharingMode_T)FileSharingMode_Read:
    34663497        case (FileSharingMode_T)FileSharingMode_Write:
     
    34853516    ComObjPtr <GuestFile> pFile;
    34863517    int rcGuest;
    3487     int vrc = i_fileOpen(openInfo, pFile, &rcGuest);
     3518    int vrc = i_fileOpenEx(aPath, aAccessMode, aOpenAction, aSharingMode, aCreationMode, aFlags, pFile, &rcGuest);
    34883519    if (RT_SUCCESS(vrc))
    34893520        /* Return directory object to the caller. */
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