VirtualBox

Changeset 84998 in vbox for trunk


Ignore:
Timestamp:
Jun 29, 2020 4:34:22 PM (4 years ago)
Author:
vboxsync
Message:

DnD: Greatly simplified usage / API of the DnDURIObject class.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/DragAndDrop.h

    r84983 r84998  
    130130    };
    131131
    132     /**
    133      * Enumeration for specifying an URI object view
    134      * for representing its data accordingly.
    135      */
    136     enum View
    137     {
    138         /** Unknown view, do not use. */
    139         View_Unknown = 0,
    140         /** Handle data from the source point of view. */
    141         View_Source,
    142         /** Handle data from the destination point of view. */
    143         View_Target,
    144         /** The usual 32-bit hack. */
    145         View_Dest_32Bit_Hack = 0x7fffffff
    146     };
    147 
    148132#ifdef RT_NEED_NEW_AND_DELETE
    149133    RTMEM_IMPLEMENT_NEW_AND_DELETE();
    150134#endif
    151     DnDURIObject(void);
    152     DnDURIObject(Type type,
    153                  const RTCString &strSrcPathAbs = "",
    154                  const RTCString &strDstPathAbs = "");
     135    DnDURIObject(Type enmType = Type_Unknown, const RTCString &strPathAbs = "");
     136
    155137    virtual ~DnDURIObject(void);
    156138
     
    162144     * @return  Absolute source path of the object.
    163145     */
    164     const RTCString &GetSourcePathAbs(void) const { return m_strSrcPathAbs; }
    165 
    166     /**
    167      * Returns the given, absolute destination path of the object.
    168      *
    169      * @return  Absolute destination path of the object.
    170      */
    171     const RTCString &GetDestPathAbs(void) const { return m_strTgtPathAbs; }
     146    const RTCString &GetPath(void) const { return m_strPathAbs; }
    172147
    173148    RTFMODE GetMode(void) const;
     
    184159    Type GetType(void) const { return m_enmType; }
    185160
    186     /**
    187      * Returns the object's view.
    188      *
    189      * @return  The object's view.
    190      */
    191     View GetView(void) const { return m_enmView; }
    192 
    193 public:
     161public:
     162
     163    int Init(Type enmType, const RTCString &strPathAbs = "");
    194164
    195165    int SetSize(uint64_t cbSize);
     
    200170    bool IsComplete(void) const;
    201171    bool IsOpen(void) const;
    202     int Open(View enmView, uint64_t fOpen, RTFMODE fMode = 0);
    203     int OpenEx(const RTCString &strPath, View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0, DNDURIOBJECTFLAGS = DNDURIOBJECT_FLAGS_NONE);
    204     int QueryInfo(View enmView);
     172    int Open(uint64_t fOpen, RTFMODE fMode = 0, DNDURIOBJECTFLAGS = DNDURIOBJECT_FLAGS_NONE);
     173    int QueryInfo(void);
    205174    int Read(void *pvBuf, size_t cbBuf, uint32_t *pcbRead);
    206175    void Reset(void);
     
    214183
    215184    void closeInternal(void);
    216     int queryInfoInternal(View enmView);
     185    int queryInfoInternal(void);
    217186
    218187protected:
     
    220189    /** The object's type. */
    221190    Type      m_enmType;
    222     /** The object's view. */
    223     View      m_enmView;
    224     /** Absolute path (base) for the source. */
    225     RTCString m_strSrcPathAbs;
    226     /** Absolute path (base) for the target. */
    227     RTCString m_strTgtPathAbs;
     191    /** Absolute path of the object. */
     192    RTCString m_strPathAbs;
    228193
    229194    /** Union containing data depending on the object's type. */
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDragAndDrop.cpp

    r84985 r84998  
    397397     * Enter the main loop of retieving files + directories.
    398398     */
    399     DnDURIObject objFile(DnDURIObject::Type_File);
     399    DnDURIObject objFile;
    400400
    401401    char szPathName[RTPATH_MAX] = { 0 };
     
    497497                                uint32_t fCreationMode = (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR;
    498498#endif
    499                                 rc = objFile.OpenEx(strPathAbs, DnDURIObject::View_Target, fOpen, fCreationMode);
     499                                rc = objFile.Init(DnDURIObject::Type_File, strPathAbs);
    500500                                if (RT_SUCCESS(rc))
    501501                                {
    502                                     rc = pDroppedFiles->AddFile(strPathAbs.c_str());
     502                                    rc = objFile.Open(fOpen, fCreationMode);
    503503                                    if (RT_SUCCESS(rc))
    504504                                    {
    505                                         cbFileWritten = 0;
    506                                         objFile.SetSize(cbFileSize);
     505                                        rc = pDroppedFiles->AddFile(strPathAbs.c_str());
     506                                        if (RT_SUCCESS(rc))
     507                                        {
     508                                            cbFileWritten = 0;
     509                                            objFile.SetSize(cbFileSize);
     510                                        }
    507511                                    }
    508512                                }
     
    15341538    AssertReturn(pObj->GetType() == DnDURIObject::Type_Directory, VERR_INVALID_PARAMETER);
    15351539
    1536     RTCString strPath = pObj->GetDestPathAbs();
     1540    RTCString strPath = pObj->GetPath();
    15371541    LogFlowFunc(("strDir=%s (%zu), fMode=0x%x\n",
    15381542                 strPath.c_str(), strPath.length(), pObj->GetMode()));
     
    15741578        return VERR_NO_MEMORY;
    15751579
    1576     RTCString strPath = pObj->GetDestPathAbs();
     1580    RTCString strPath = pObj->GetPath();
    15771581
    15781582    LogFlowFunc(("strFile=%s (%zu), cbSize=%RU64, fMode=0x%x\n", strPath.c_str(), strPath.length(),
  • trunk/src/VBox/GuestHost/DragAndDrop/DnDURIList.cpp

    r82968 r84998  
    6262                         pcszSource, pcszTarget, (uint64_t)objInfo.cbObject, objInfo.Attr.fMode));
    6363
    64             DnDURIObject *pObjFile = new DnDURIObject(DnDURIObject::Type_File, pcszSource, pcszTarget);
     64            DnDURIObject *pObjFile = new DnDURIObject(DnDURIObject::Type_File, pcszSource);
    6565            if (pObjFile)
    6666            {
    6767                /** @todo Add a standard fOpen mode for this list. */
    68                 rc = pObjFile->Open(DnDURIObject::View_Source, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
     68                rc = pObjFile->Open(RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
    6969                if (RT_SUCCESS(rc))
    7070                {
     
    7777                        pObjFile->Close();
    7878                }
    79                 else
     79
     80                if (RT_FAILURE(rc))
    8081                    delete pObjFile;
    8182            }
     
    8788            LogFlowFunc(("Directory '%s' -> '%s' (file mode 0x%x)\n", pcszSource, pcszTarget, objInfo.Attr.fMode));
    8889
    89             DnDURIObject *pObjDir = new DnDURIObject(DnDURIObject::Type_Directory, pcszSource, pcszTarget);
     90            DnDURIObject *pObjDir = new DnDURIObject(DnDURIObject::Type_Directory, pcszSource);
    9091            if (pObjDir)
    9192            {
     
    384385                                  : pszFileName - pszSrcPath;
    385386                char *pszDstPath = &pszSrcPath[cchDstBase];
    386                 m_lstRoot.append(pszDstPath);
    387 
    388                 LogFlowFunc(("pszSrcPath=%s, pszFileName=%s, pszRoot=%s\n",
    389                              pszSrcPath, pszFileName, pszDstPath));
    390 
    391                 rc = appendPathRecursive(pszSrcPath, pszSrcPath, pszSrcPath, cchDstBase, fFlags);
     387                rc = DnDPathSanitize(pszDstPath, strlen(pszDstPath));
     388                if (RT_SUCCESS(rc))
     389                {
     390                    m_lstRoot.append(pszDstPath);
     391
     392                    LogFlowFunc(("pszSrcPath=%s, pszFileName=%s, pszDstPath=%s\n",
     393                                 pszSrcPath, pszFileName, pszDstPath));
     394
     395                    rc = appendPathRecursive(pszSrcPath, pszSrcPath, pszSrcPath, cchDstBase, fFlags);
     396                }
    392397            }
    393398            else
  • trunk/src/VBox/GuestHost/DragAndDrop/DnDURIObject.cpp

    r82968 r84998  
    3333
    3434
    35 DnDURIObject::DnDURIObject(void)
    36     : m_enmType(Type_Unknown)
    37     , m_enmView(View_Unknown)
    38 {
    39     RT_ZERO(u);
    40 }
    41 
    42 DnDURIObject::DnDURIObject(Type enmType,
    43                            const RTCString &strSrcPathAbs /* = 0 */,
    44                            const RTCString &strDstPathAbs /* = 0 */)
    45     : m_enmType(enmType)
    46     , m_enmView(View_Unknown)
    47     , m_strSrcPathAbs(strSrcPathAbs)
    48     , m_strTgtPathAbs(strDstPathAbs)
    49 {
    50     RT_ZERO(u);
    51 
    52     switch (m_enmType)
    53     {
    54         case Type_File:
    55         {
    56             u.File.hFile = NIL_RTFILE;
    57             break;
    58         }
    59 
    60         case Type_Directory:
    61         {
    62             u.Dir.hDir = NIL_RTDIR;
    63             break;
    64         }
    65 
    66         default:
    67             break;
    68     }
     35DnDURIObject::DnDURIObject(Type enmType = /* Type_Unknown */, const RTCString &strPathAbs /* = "" */)
     36{
     37    int rc2 = Init(enmType, strPathAbs);
     38    AssertRC(rc2);
    6939}
    7040
     
    7646/**
    7747 * Closes the object's internal handles (to files / ...).
    78  *
    7948 */
    8049void DnDURIObject::closeInternal(void)
     
    168137
    169138/**
     139 * Initializes the object with an expected object type and file path.
     140 *
     141 * @returns VBox status code.
     142 * @param   enmType             Type we expect this object to be.
     143 * @param   strPathAbs          Absolute path of file this object represents. Optional.
     144 */
     145int DnDURIObject::Init(Type enmType, const RTCString &strPathAbs /* = */)
     146{
     147    AssertReturn(enmType == Type_Unknown, VERR_WRONG_ORDER);
     148
     149    int rc;
     150
     151    switch (m_enmType)
     152    {
     153        case Type_File:
     154        {
     155            u.File.hFile = NIL_RTFILE;
     156            break;
     157        }
     158
     159        case Type_Directory:
     160        {
     161            u.Dir.hDir = NIL_RTDIR;
     162            break;
     163        }
     164
     165        default:
     166            break;
     167    }
     168
     169    if (enmType != Type_Unknown)
     170    {
     171        AssertReturn(m_strPathAbs.isNotEmpty(), VERR_INVALID_PARAMETER);
     172        rc = DnDPathSanitize(m_strPathAbs.mutableRaw(), m_strPathAbs.capacity());
     173        if (RT_SUCCESS(rc))
     174        {
     175            m_enmType    = enmType;
     176            m_strPathAbs = strPathAbs;
     177        }
     178    }
     179    else
     180        rc = VERR_INVALID_PARAMETER;
     181
     182    return rc;
     183}
     184
     185/**
    170186 * Returns whether the processing of the object is complete or not.
    171187 * For file objects this means that all bytes have been processed.
     
    212228
    213229/**
    214  * (Re-)Opens the object with a specific view, open and file mode.
     230 * Open the object with a specific file type, and, depending on the type, specifying additional parameters.
    215231 *
    216232 * @return  IPRT status code.
    217  * @param   enmView             View to use for opening the object.
    218  * @param   fOpen               File open flags to use.
    219  * @param   fMode               File mode to use.
    220  */
    221 int DnDURIObject::Open(View enmView, uint64_t fOpen /* = 0 */, RTFMODE fMode /* = 0 */)
    222 {
    223     return OpenEx(  enmView == View_Source
    224                   ? m_strSrcPathAbs : m_strTgtPathAbs
    225                   , enmView, fOpen, fMode, DNDURIOBJECT_FLAGS_NONE);
    226 }
    227 
    228 /**
    229  * Open the object with a specific file type, and, depending on the type, specifying additional parameters.
    230  *
    231  * @return  IPRT status code.
    232  * @param   strPathAbs          Absolute path of the object (file / directory / ...).
    233  * @param   enmView             View of the object.
    234233 * @param   fOpen               Open mode to use; only valid for file objects.
    235  * @param   fMode               File mode to use; only valid for file objects.
     234 * @param   fMode               File mode to set; only valid for file objects. Depends on fOpen and and can be 0.
    236235 * @param   fFlags              Additional DnD URI object flags.
    237236 */
    238 int DnDURIObject::OpenEx(const RTCString &strPathAbs, View enmView,
    239                          uint64_t fOpen /* = 0 */, RTFMODE fMode /* = 0 */, DNDURIOBJECTFLAGS fFlags /* = DNDURIOBJECT_FLAGS_NONE */)
    240 {
     237int DnDURIObject::Open(uint64_t fOpen, RTFMODE fMode /* = 0 */,
     238                       DNDURIOBJECTFLAGS fFlags /* = DNDURIOBJECT_FLAGS_NONE */)
     239{
     240    AssertReturn(fOpen, VERR_INVALID_FLAGS);
     241    /* fMode is optional. */
    241242    AssertReturn(!(fFlags & ~DNDURIOBJECT_FLAGS_VALID_MASK), VERR_INVALID_FLAGS);
    242243    RT_NOREF1(fFlags);
     
    244245    int rc = VINF_SUCCESS;
    245246
    246     switch (enmView)
    247     {
    248         case View_Source:
    249             m_strSrcPathAbs = strPathAbs;
    250             break;
    251 
    252         case View_Target:
    253             m_strTgtPathAbs = strPathAbs;
    254             break;
    255 
    256         default:
    257             rc = VERR_NOT_IMPLEMENTED;
    258             break;
    259     }
    260 
    261     if (   RT_SUCCESS(rc)
    262         && fOpen) /* Opening mode specified? */
    263     {
    264         LogFlowThisFunc(("strPath=%s, enmView=%RU32, fOpen=0x%x, fMode=0x%x, fFlags=0x%x\n",
    265                          strPathAbs.c_str(), enmView, fOpen, fMode, fFlags));
     247    if (fOpen) /* Opening mode specified? */
     248    {
     249        LogFlowThisFunc(("strPath=%s, fOpen=0x%x, fMode=0x%x, fFlags=0x%x\n",
     250                         m_strPathAbs.c_str(), fOpen, fMode, fFlags));
    266251        switch (m_enmType)
    267252        {
     
    273258                 * it over.
    274259                 */
    275                 LogFlowThisFunc(("Opening ...\n"));
    276                 rc = RTFileOpen(&u.File.hFile, strPathAbs.c_str(), fOpen);
     260                rc = RTFileOpen(&u.File.hFile, m_strPathAbs.c_str(), fOpen);
    277261                if (RT_SUCCESS(rc))
    278262                {
     
    284268                    else if (fOpen & RTFILE_O_READ)
    285269                    {
    286                         rc = queryInfoInternal(enmView);
     270                        rc = queryInfoInternal();
    287271                    }
    288272                }
     
    301285            case Type_Directory:
    302286            {
    303                 rc = RTDirOpen(&u.Dir.hDir, strPathAbs.c_str());
     287                rc = RTDirOpen(&u.Dir.hDir, m_strPathAbs.c_str());
    304288                if (RT_SUCCESS(rc))
    305                     rc = queryInfoInternal(enmView);
     289                    rc = queryInfoInternal();
    306290                break;
    307291            }
     
    313297    }
    314298
    315     if (RT_SUCCESS(rc))
    316     {
    317         m_enmView = enmView;
    318     }
    319 
    320299    LogFlowFuncLeaveRC(rc);
    321300    return rc;
     
    326305 *
    327306 * @return  IPRT status code.
    328  * @param   enmView             View to use for querying information. Currently ignored.
    329  */
    330 int DnDURIObject::queryInfoInternal(View enmView)
    331 {
    332     RT_NOREF(enmView);
    333 
     307 */
     308int DnDURIObject::queryInfoInternal(void)
     309{
    334310    int rc;
    335311
     
    358334 *
    359335 * @return  IPRT status code.
    360  * @param   enmView             View to use for querying information.
    361  */
    362 int DnDURIObject::QueryInfo(View enmView)
    363 {
    364     return queryInfoInternal(enmView);
     336 */
     337int DnDURIObject::QueryInfo(void)
     338{
     339    return queryInfoInternal();
    365340}
    366341
     
    445420    /* pcbRead is optional. */
    446421
    447     AssertMsgReturn(m_enmView == View_Source, ("Cannot write to an object which is not in target view\n"),
    448                     VERR_INVALID_STATE);
    449 
    450422    size_t cbRead = 0;
    451423
     
    488460    }
    489461
    490     LogFlowFunc(("Returning strSourcePath=%s, cbRead=%zu, rc=%Rrc\n", m_strSrcPathAbs.c_str(), cbRead, rc));
     462    LogFlowFunc(("Returning strSourcePath=%s, cbRead=%zu, rc=%Rrc\n", m_strPathAbs.c_str(), cbRead, rc));
    491463    return rc;
    492464}
     
    501473    Close();
    502474
    503     m_enmType       = Type_Unknown;
    504     m_enmView       = View_Unknown;
    505     m_strSrcPathAbs = "";
    506     m_strTgtPathAbs = "";
     475    m_enmType    = Type_Unknown;
     476    m_strPathAbs = "";
    507477
    508478    RT_ZERO(u);
     
    541511    /* pcbWritten is optional. */
    542512
    543     AssertMsgReturn(m_enmView == View_Target, ("Cannot write to an object which is not in target view\n"),
    544                     VERR_INVALID_STATE);
    545 
    546513    size_t cbWritten = 0;
    547514
     
    574541    }
    575542
    576     LogFlowThisFunc(("Returning strSourcePathAbs=%s, cbWritten=%zu, rc=%Rrc\n", m_strSrcPathAbs.c_str(), cbWritten, rc));
     543    LogFlowThisFunc(("Returning strSourcePathAbs=%s, cbWritten=%zu, rc=%Rrc\n", m_strPathAbs.c_str(), cbWritten, rc));
    577544    return rc;
    578545}
  • trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp

    r82968 r84998  
    780780                && !pObj->IsComplete())
    781781            {
    782                 AssertMsgFailed(("Object '%s' not complete yet\n", pObj->GetDestPathAbs().c_str()));
     782                AssertMsgFailed(("Object '%s' not complete yet\n", pObj->GetPath().c_str()));
    783783                rc = VERR_WRONG_ORDER;
    784784                break;
     
    787787            if (pObj->IsOpen()) /* File already opened? */
    788788            {
    789                 AssertMsgFailed(("Current opened object is '%s', close this first\n", pObj->GetDestPathAbs().c_str()));
     789                AssertMsgFailed(("Current opened object is '%s', close this first\n", pObj->GetPath().c_str()));
    790790                rc = VERR_WRONG_ORDER;
    791791                break;
     
    825825            LogRel2(("DnD: Absolute file path for guest file on the host is now '%s'\n", pszPathAbs));
    826826
    827             /** @todo Add sparse file support based on fFlags? (Use Open(..., fFlags | SPARSE). */
    828             rc = pObj->OpenEx(pszPathAbs, DnDURIObject::View_Target,
    829                               RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE,
    830                               (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR);
     827            rc = pObj->Init(DnDURIObject::Type_File, pszPathAbs);
    831828            if (RT_SUCCESS(rc))
    832829            {
    833                 /* Add for having a proper rollback. */
    834                 int rc2 = pCtx->mURI.getDroppedFiles().AddFile(pszPathAbs);
    835                 AssertRC(rc2);
     830                /** @todo Add sparse file support based on fFlags? (Use Open(..., fFlags | SPARSE). */
     831                rc = pObj->Open(RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE,
     832                                (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR);
     833                if (RT_SUCCESS(rc))
     834                {
     835                    /* Add for having a proper rollback. */
     836                    int rc2 = pCtx->mURI.getDroppedFiles().AddFile(pszPathAbs);
     837                    AssertRC(rc2);
     838                }
    836839            }
    837             else
     840
     841            if (RT_FAILURE(rc))
    838842                LogRel(("DnD: Error opening/creating guest file '%s' on host, rc=%Rrc\n", pszPathAbs, rc));
    839843        }
     
    847851            /** @todo Unescape path before printing. */
    848852            LogRel2(("DnD: Transferring guest file '%s' to host (%RU64 bytes, mode 0x%x)\n",
    849                      pObj->GetDestPathAbs().c_str(), pObj->GetSize(), pObj->GetMode()));
     853                     pObj->GetPath().c_str(), pObj->GetSize(), pObj->GetMode()));
    850854
    851855            /** @todo Set progress object title to current file being transferred? */
     
    853857            if (pObj->IsComplete()) /* 0-byte file? We're done already. */
    854858            {
    855                 /** @todo Sanitize path. */
    856                 LogRel2(("DnD: Transferring guest file '%s' (0 bytes) to host complete\n", pObj->GetDestPathAbs().c_str()));
     859                LogRel2(("DnD: Transferring guest file '%s' (0 bytes) to host complete\n", pObj->GetPath().c_str()));
    857860
    858861                pCtx->mURI.processObject(*pObj);
     
    902905        if (pObj->IsComplete())
    903906        {
    904             LogFlowFunc(("Warning: Object '%s' already completed\n", pObj->GetDestPathAbs().c_str()));
     907            LogFlowFunc(("Warning: Object '%s' already completed\n", pObj->GetPath().c_str()));
    905908            rc = VERR_WRONG_ORDER;
    906909            break;
     
    909912        if (!pObj->IsOpen()) /* File opened on host? */
    910913        {
    911             LogFlowFunc(("Warning: Object '%s' not opened\n", pObj->GetDestPathAbs().c_str()));
     914            LogFlowFunc(("Warning: Object '%s' not opened\n", pObj->GetPath().c_str()));
    912915            rc = VERR_WRONG_ORDER;
    913916            break;
     
    921924            if (cbWritten < cbData)
    922925            {
    923                 /** @todo What to do when the host's disk is full? */
    924                 rc = VERR_DISK_FULL;
     926                LogRel(("DnD: Only written %RU32 of %RU32 bytes of guest file '%s' -- disk full?\n",
     927                        cbWritten, cbData, pObj->GetPath().c_str()));
     928                rc = VERR_IO_GEN_FAILURE; /** @todo Find a better rc. */
    925929            }
    926930
     
    929933        }
    930934        else
    931             LogRel(("DnD: Error writing guest file data for '%s', rc=%Rrc\n", pObj->GetDestPathAbs().c_str(), rc));
     935            LogRel(("DnD: Error writing guest file data for '%s', rc=%Rrc\n", pObj->GetPath().c_str(), rc));
    932936
    933937        if (RT_SUCCESS(rc))
     
    936940            {
    937941                /** @todo Sanitize path. */
    938                 LogRel2(("DnD: Transferring guest file '%s' to host complete\n", pObj->GetDestPathAbs().c_str()));
     942                LogRel2(("DnD: Transferring guest file '%s' to host complete\n", pObj->GetPath().c_str()));
    939943                pCtx->mURI.processObject(*pObj);
    940944                objCtx.reset();
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r82968 r84998  
    882882    AssertPtr(pObj);
    883883
    884     RTCString strPath = pObj->GetDestPathAbs();
     884    RTCString strPath = pObj->GetPath();
    885885    if (strPath.isEmpty())
    886886        return VERR_INVALID_PARAMETER;
     
    909909    AssertPtr(pObj);
    910910
    911     RTCString strPathSrc = pObj->GetSourcePathAbs();
     911    RTCString strPathSrc = pObj->GetPath();
    912912    if (strPathSrc.isEmpty())
    913913        return VERR_INVALID_PARAMETER;
     
    922922    {
    923923        LogRel2(("DnD: Opening host file '%s' for transferring to guest\n", strPathSrc.c_str()));
    924         rc = pObj->OpenEx(strPathSrc, DnDURIObject::View_Source,
    925                           RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
     924        rc = pObj->Init(DnDURIObject::Type_File, strPathSrc);
     925        if (RT_SUCCESS(rc))
     926            rc = pObj->Open(RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
     927
    926928        if (RT_FAILURE(rc))
    927929            LogRel(("DnD: Opening host file '%s' failed, rc=%Rrc\n", strPathSrc.c_str(), rc));
     
    943945                pMsg->setType(HOST_DND_HG_SND_FILE_HDR);
    944946                pMsg->setNextUInt32(0); /** @todo ContextID not used yet. */
    945                 pMsg->setNextString(pObj->GetDestPathAbs().c_str());                  /* pvName */
    946                 pMsg->setNextUInt32((uint32_t)(pObj->GetDestPathAbs().length() + 1)); /* cbName */
    947                 pMsg->setNextUInt32(0);                                            /* uFlags */
    948                 pMsg->setNextUInt32(pObj->GetMode());                              /* fMode */
    949                 pMsg->setNextUInt64(pObj->GetSize());                              /* uSize */
     947                pMsg->setNextString(pObj->GetPath().c_str());                  /* pvName */
     948                pMsg->setNextUInt32((uint32_t)(pObj->GetPath().length() + 1)); /* cbName */
     949                pMsg->setNextUInt32(0);                                        /* uFlags */
     950                pMsg->setNextUInt32(pObj->GetMode());                          /* fMode */
     951                pMsg->setNextUInt64(pObj->GetSize());                          /* uSize */
    950952
    951953                LogFlowFunc(("Sending file header ...\n"));
    952                 LogRel2(("DnD: Transferring host file to guest: %s (%RU64 bytes, mode 0x%x)\n",
    953                          strPathSrc.c_str(), pObj->GetSize(), pObj->GetMode()));
     954                LogRel2(("DnD: Transferring host file '%s' to guest (%RU64 bytes, mode 0x%x)\n",
     955                         pObj->GetPath().c_str(), pObj->GetSize(), pObj->GetMode()));
    954956
    955957                /** @todo Set progress object title to current file being transferred? */
     
    10071009    if (mDataBase.m_uProtocolVersion <= 1)
    10081010    {
    1009         pMsg->setNextString(pObj->GetDestPathAbs().c_str());                  /* pvName */
    1010         pMsg->setNextUInt32((uint32_t)(pObj->GetDestPathAbs().length() + 1)); /* cbName */
     1011        pMsg->setNextString(pObj->GetPath().c_str());                  /* pvName */
     1012        pMsg->setNextUInt32((uint32_t)(pObj->GetPath().length() + 1)); /* cbName */
    10111013    }
    10121014    else if (mDataBase.m_uProtocolVersion >= 2)
     
    10441046        if (pObj->IsComplete()) /* Done reading? */
    10451047        {
    1046             LogRel2(("DnD: Transferring file '%s' to guest complete\n", pObj->GetSourcePathAbs().c_str()));
    1047             LogFlowFunc(("File '%s' complete\n", pObj->GetSourcePathAbs().c_str()));
     1048            LogRel2(("DnD: Transferring file '%s' to guest complete\n", pObj->GetPath().c_str()));
     1049            LogFlowFunc(("File '%s' complete\n", pObj->GetPath().c_str()));
    10481050
    10491051            /* DnDURIObject::Read() returns VINF_EOF when finished reading the entire fire,
     
    10541056
    10551057    if (RT_FAILURE(rc))
    1056         LogRel(("DnD: Reading from host file '%s' failed, rc=%Rrc\n", pObj->GetSourcePathAbs().c_str(), rc));
     1058        LogRel(("DnD: Reading from host file '%s' failed, rc=%Rrc\n", pObj->GetPath().c_str(), rc));
    10571059
    10581060    LogFlowFuncLeaveRC(rc);
     
    14491451    AssertPtr(pCurObj);
    14501452
    1451     DnDURIObject::Type enmType = pCurObj->GetType();
     1453    const DnDURIObject::Type enmType = pCurObj->GetType();
     1454
    14521455    LogRel3(("DnD: Processing: srcPath=%s, dstPath=%s, enmType=%RU32, cbSize=%RU32\n",
    1453              pCurObj->GetSourcePathAbs().c_str(), pCurObj->GetDestPathAbs().c_str(),
     1456             pCurObj->GetPath().c_str(), pCurObj->GetPath().c_str(),
    14541457             enmType, pCurObj->GetSize()));
    14551458
     
    14651468    {
    14661469        AssertMsgFailed(("enmType=%RU32 is not supported for srcPath=%s, dstPath=%s\n",
    1467                          enmType, pCurObj->GetSourcePathAbs().c_str(), pCurObj->GetDestPathAbs().c_str()));
     1470                         enmType, pCurObj->GetPath().c_str(), pCurObj->GetPath().c_str()));
    14681471        rc = VERR_NOT_SUPPORTED;
    14691472    }
     
    14781481    if (fRemove)
    14791482    {
    1480         LogFlowFunc(("Removing \"%s\" from list, rc=%Rrc\n", pCurObj->GetSourcePathAbs().c_str(), rc));
     1483        LogFlowFunc(("Removing \"%s\" from list, rc=%Rrc\n", pCurObj->GetPath().c_str(), rc));
    14811484        pCtx->mURI.removeObjCurrent();
    14821485    }
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