Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropTarget.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropTarget.cpp	(revision 50733)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropTarget.cpp	(revision 50734)
@@ -464,5 +464,4 @@
                                 RTCString strRoot = lstURI.RootToString();
                                 size_t cbRoot = strRoot.length() + 1; /* Include termination */
-                                Assert(cbRoot);
 
                                 mpvData = RTMemAlloc(cbRoot);
Index: /trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp	(revision 50733)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp	(revision 50734)
@@ -45,5 +45,5 @@
  * their behavior. Don't have this enabled in release builds! */
 #ifdef DEBUG
-# define VBOX_DND_DEBUG_WND
+//# define VBOX_DND_DEBUG_WND
 #endif
 
@@ -76,14 +76,12 @@
  * the data in the specified mime-type. This data is send back to the host.
  * After that we send a XdndLeave event to the source window.
- * Todo:
- * - this isn't finished, yet. Currently the mouse isn't correctly released
- *   in the guest (both, when the drop was successfully or canceled).
- * - cancel (e.g. with the ESC key) doesn't work
+ * 
+ * To-do:
+ * - Cancelling (e.g. with ESC key) doesn't work.
  *
- * Todo:
- * - XdndProxy window support
- * - INCR support
- * - make this much more robust for crashes of the other party
- * - really check for the Xdnd version and the supported features
+ * To-do:
+ * - INCR (incremental transfers) support.
+ * - Make this much more robust for crashes of the other party.
+ * - Really check for the Xdnd version and the supported features.
  */
 
@@ -390,5 +388,5 @@
     void mouseButtonSet(Window wndDest, int rx, int ry, int iButton, bool fPress) const;
     int proxyWinShow(int *piRootX = NULL, int *piRootY = NULL, bool fMouseMove = false) const;
-    int proxyWinHide(void) const;
+    int proxyWinHide(void);
     void registerForEvents(Window w) const;
 
@@ -569,4 +567,5 @@
     m_curVer = -1;
     m_state  = Initialized;
+    m_eventQueue.clear();
 }
 
@@ -740,13 +739,8 @@
         case GH:
         {
-            //if (m_state == Dropped) 
-            //{
-                LogFlowThisFunc(("Enqueuing ClientMessage\n"));
-
-                m_eventQueue.append(e);
-                rc = RTSemEventSignal(m_hEventSem);
-            //}
-
-            //rc = VINF_SUCCESS;
+            LogFlowThisFunc(("Enqueuing ClientMessage\n"));
+
+            m_eventQueue.append(e);
+            rc = RTSemEventSignal(m_hEventSem);
             break;
         }
@@ -885,9 +879,9 @@
                     memcpy(&m_eventHgSelection, &e, sizeof(XEvent));
 
-                    const char *pcszFormat = xAtomToString(e.xselectionrequest.target).c_str();
-                    AssertPtr(pcszFormat);
-                    rc = VbglR3DnDHGRequestData(m_uClientID, pcszFormat);
+                    RTCString strFormat = xAtomToString(e.xselectionrequest.target);
+                    Assert(strFormat.isNotEmpty());
+                    rc = VbglR3DnDHGRequestData(m_uClientID, strFormat.c_str());
                     LogFlowThisFunc(("Requesting data from host as \"%s\", rc=%Rrc\n", 
-                                     pcszFormat, rc));
+                                     strFormat.c_str(), rc));
                 }
             }
@@ -936,4 +930,24 @@
     switch (e.type)
     {
+        case ButtonPress:
+            LogFlowThisFunc(("ButtonPress\n")); 
+            rc = VINF_SUCCESS;
+            break;
+
+        case ButtonRelease:
+            LogFlowThisFunc(("ButtonRelease\n")); 
+            rc = VINF_SUCCESS;
+            break;
+
+        case ClientMessage:    
+            rc = onX11ClientMessage(e); 
+            break;
+
+        case SelectionClear:
+           LogFlowThisFunc(("SelectionClear\n"));
+           reset();
+           rc = VINF_SUCCESS;
+           break;
+
         case SelectionNotify:
             rc = onX11SelectionNotify(e); 
@@ -943,13 +957,4 @@
             rc = onX11SelectionRequest(e); 
             break;
-
-        case ClientMessage:    
-            rc = onX11ClientMessage(e); 
-            break;
-
-        case SelectionClear:
-           LogFlowThisFunc(("SelectionClear\n")); 
-           rc = VINF_SUCCESS;
-           break;
 
         /*case MotionNotify: 
@@ -1135,4 +1140,5 @@
                                  0, 2, False, AnyPropertyType,
                                  &atmp, &fmt, &cItems, &cbRemaining, &pcData);
+
         if (RT_UNLIKELY(xrc != Success))
             LogFlowThisFunc(("Error in getting the window property: %s\n", gX11->xErrorToString(xrc).c_str()));
@@ -1146,4 +1152,5 @@
                 LogFlowThisFunc(("wndCursor=%#x, XdndAware=%u\n", newVer));
             }
+
             XFree(pcData);
         }
@@ -1153,5 +1160,6 @@
      * Is the window under the cursor another one than our current one?
      */
-    if (wndCursor != m_wndCur && m_curVer != -1)
+    if (   wndCursor != m_wndCur 
+        && m_curVer != -1)
     {
         LogFlowThisFunc(("Leaving window=%#x\n", m_wndCur));
@@ -1212,5 +1220,5 @@
          */
         Atom pa = toX11Action(uAction);
-        LogFlowThisFunc(("strAction='%s' ", xAtomToString(pa).c_str()));
+        LogFlowThisFunc(("strAction=%s\n", xAtomToString(pa).c_str()));
 
         XClientMessageEvent m;
@@ -1231,5 +1239,6 @@
     }
 
-    if (wndCursor == None && newVer == -1)
+    if (   wndCursor == None 
+        && newVer    == -1)
     {
         /* No window to process, so send a ignore ack event to the host. */
@@ -1356,5 +1365,5 @@
             AssertPtr(pEventClient);
 
-            LogFlowThisFunc(("Next X event is: %s\n", 
+            LogFlowThisFunc(("Received event=%s\n", 
                              gX11->xAtomToString(pEventClient->message_type).c_str()));
 
@@ -1370,4 +1379,5 @@
                 m_state = Dragging;
                 m_wndCur = wndSelection;
+                Assert(m_wndCur == pEventClient->data.l[0]);
 
                 LogFlowThisFunc(("XA_XdndEnter\n"));
@@ -1438,15 +1448,14 @@
                 XClientMessageEvent m;
                 RT_ZERO(m);
-
                 m.type         = ClientMessage;
                 m.display      = m_pDisplay;
-                m.window       = pEventClient->data.l[0];
+                m.window       = m_wndCur;
                 m.message_type = xAtom(XA_XdndStatus);
                 m.format       = 32;
                 m.data.l[0]    = m_wndProxy;
-                m.data.l[1]    = 1;
-                m.data.l[4]    = xAtom(XA_XdndActionCopy);
-
-                xRc = XSendEvent(m_pDisplay, pEventClient->data.l[0], 
+                m.data.l[1]    = RT_BIT(0); /* Accept the drop. */
+                m.data.l[4]    = xAtom(XA_XdndActionCopy); /** @todo Make the accepted action configurable. */
+
+                xRc = XSendEvent(m_pDisplay, m_wndCur, 
                                  False, 0, reinterpret_cast<XEvent*>(&m));
                 if (RT_UNLIKELY(xRc == 0))
@@ -1464,12 +1473,12 @@
                 m.type         = ClientMessage;
                 m.display      = m_pDisplay;
-                m.window       = pEventClient->data.l[0];
+                m.window       = m_wndCur;
                 m.message_type = xAtom(XA_XdndStatus);
                 m.format       = 32;
                 m.data.l[0]    = m_wndProxy;
-                m.data.l[1]    = 1;
-                m.data.l[4]    = pEventClient->data.l[4];
-
-                xRc = XSendEvent(m_pDisplay, pEventClient->data.l[0], 
+                m.data.l[1]    = RT_BIT(0); /* Accept the drop. */
+                m.data.l[4]    = xAtom(XA_XdndActionCopy); /** @todo Make the accepted action configurable. */
+
+                xRc = XSendEvent(m_pDisplay, m_wndCur, 
                                  False, 0, reinterpret_cast<XEvent*>(&m));
                 if (RT_UNLIKELY(xRc == 0))
@@ -1482,6 +1491,4 @@
         }
 
-        proxyWinHide();
-
         /* Do we need to acknowledge at least one format to the host? */
         if (!m_formats.isEmpty())
@@ -1527,5 +1534,5 @@
     /* We send a fake release event to the current window, cause
      * this should have the grab. */
-    mouseButtonSet(m_wndCur, iRootX, iRootY, 
+    mouseButtonSet(m_wndCur /* Source window */, iRootX, iRootY, 
                    1 /* Button */, false /* Release button */);
 
@@ -1542,5 +1549,6 @@
         /* Request to convert the selection in the specific format and
          * place it to our proxy window as property. */
-        Window srcWin = m_wndCur;//clme->data.l[0];
+        Window wndSource = evDnDDrop.data.l[0]; /* Source window which sent the message. */
+        Assert(wndSource == m_wndCur);
         Atom aFormat  = gX11->stringToxAtom(strFormat.c_str());
 
@@ -1554,4 +1562,6 @@
         if (waitForX11Msg(evSelNotify, SelectionNotify))
         {
+            bool fCancel = false;
+
             /* Make some paranoid checks. */
             if (   evSelNotify.xselection.type      == SelectionNotify
@@ -1616,19 +1626,24 @@
                                      strFormat.c_str(), rc));
 
-                    /* Confirm the result of the transfer to the source window. */
-                    XClientMessageEvent m;
-                    RT_ZERO(m);
-                    m.type         = ClientMessage;
-                    m.display      = m_pDisplay;
-                    m.window       = srcWin;
-                    m.message_type = xAtom(XA_XdndFinished);
-                    m.format       = 32;
-                    m.data.l[0]    = m_wndProxy;
-                    m.data.l[1]    = RT_SUCCESS(rc) ? 1 : 0;                       /* Confirm or deny success */
-                    m.data.l[2]    = RT_SUCCESS(rc) ? toX11Action(uAction) : None; /* Action used on success */
-
-                    int xrc = XSendEvent(m_pDisplay, srcWin, True, NoEventMask, reinterpret_cast<XEvent*>(&m));
-                    if (RT_UNLIKELY(xrc == 0))
-                        LogFlowThisFunc(("Error sending xEvent\n"));
+                    if (RT_SUCCESS(rc))
+                    {
+                        /* Confirm the result of the transfer to the source window. */
+                        XClientMessageEvent m;
+                        RT_ZERO(m);
+                        m.type         = ClientMessage;
+                        m.display      = m_pDisplay;
+                        m.window       = m_wndProxy;
+                        m.message_type = xAtom(XA_XdndFinished);
+                        m.format       = 32;
+                        m.data.l[0]    = m_wndProxy; /* Target window. */
+                        m.data.l[1]    = 0; /* Don't accept the drop to not make the guest stuck. */
+                        m.data.l[2]    = RT_SUCCESS(rc) ? toX11Action(uAction) : None; /* Action used on success */
+
+                        int xrc = XSendEvent(m_pDisplay, wndSource, True, NoEventMask, reinterpret_cast<XEvent*>(&m));
+                        if (RT_UNLIKELY(xrc == 0))
+                            LogFlowThisFunc(("Error sending xEvent\n"));
+                    }
+                    else
+                        fCancel = true;
                 }
                 else
@@ -1642,7 +1657,15 @@
                     else
                     {
-                        AssertMsgFailed(("Not supported data type\n"));
+                        AssertMsgFailed(("Not supported data type (%s)\n", 
+                                         gX11->xAtomToString(aPropType).c_str()));
                         rc = VERR_INVALID_PARAMETER;
                     }
+
+                    fCancel = true;
+                }
+
+                if (fCancel) 
+                {
+                    LogFlowFunc(("Cancelling drop ...\n"));
 
                     /* Cancel this. */
@@ -1651,15 +1674,13 @@
                     m.type         = ClientMessage;
                     m.display      = m_pDisplay;
-                    m.window       = srcWin;
+                    m.window       = m_wndProxy;
                     m.message_type = xAtom(XA_XdndFinished);
                     m.format       = 32;
-                    m.data.l[0]    = m_wndProxy;
-                    m.data.l[1]    = 0;
-                    m.data.l[2]    = None;
-
-                    int xrc = XSendEvent(m_pDisplay, srcWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
+                    m.data.l[0]    = m_wndProxy; /* Target window. */
+                    m.data.l[1]    = 0; /* Don't accept the drop to not make the guest stuck. */
+
+                    int xrc = XSendEvent(m_pDisplay, wndSource, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
                     if (RT_UNLIKELY(xrc == 0))
-                        LogFlowThisFunc(("Error sending xEvent\n"));
-                    m_wndCur = 0;
+                        LogFlowThisFunc(("Error sending cancel event\n"));
                 }
 
@@ -1848,10 +1869,10 @@
 }
 
-int DragInstance::proxyWinHide(void) const
-{
-    LogFlowThisFuncEnter();
-    return 0;
+int DragInstance::proxyWinHide(void)
+{
+    LogFlowFuncEnter();
 
     XUnmapWindow(m_pDisplay, m_wndProxy);
+    m_eventQueue.clear();
 
     return VINF_SUCCESS; /** @todo Add error checking. */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp	(revision 50733)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp	(revision 50734)
@@ -185,5 +185,5 @@
 
 #ifndef RT_OS_WINDOWS
-bool UIDnDMimeData::eventFilter(QObject * /* pObject */, QEvent *pEvent)
+bool UIDnDMimeData::eventFilter(QObject *pObject, QEvent *pEvent)
 {
     if (pEvent)
@@ -198,5 +198,7 @@
                 LogFlowFunc(("MouseMove: x=%d, y=%d\n",
                              pMouseEvent->globalX(), pMouseEvent->globalY()));
-                break;
+                
+                return true;
+                /* Never reached. */
             }
 #endif
@@ -205,5 +207,7 @@
                 LogFlowFunc(("MouseButtonRelease\n"));
                 m_enmState = Dropped;
-                break;
+                
+                return true;
+                /* Never reached. */
             }
 
@@ -216,5 +220,7 @@
                     m_enmState = Canceled;
                 }
-                break;
+                
+                return true;
+                /* Never reached. */
             }
 
@@ -224,6 +230,5 @@
     }
 
-    /* Propagate the event further. */
-    return false;
+    return QObject::eventFilter(pObject, pEvent);
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h	(revision 50733)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h	(revision 50734)
@@ -81,5 +81,5 @@
 
 #ifndef RT_OS_WINDOWS
-    bool eventFilter(QObject * /* pObject */, QEvent *pEvent);
+    bool eventFilter(QObject *pObject, QEvent *pEvent);
 #endif
     /** @}  */
Index: /trunk/src/VBox/GuestHost/DragAndDrop/DnDURIList.cpp
===================================================================
--- /trunk/src/VBox/GuestHost/DragAndDrop/DnDURIList.cpp	(revision 50733)
+++ /trunk/src/VBox/GuestHost/DragAndDrop/DnDURIList.cpp	(revision 50734)
@@ -410,4 +410,5 @@
     AssertPtrReturn(pszURI, VERR_INVALID_POINTER);
 
+    /** @todo Check for string termination?  */
 #ifdef DEBUG_andy
     LogFlowFunc(("pszPath=%s, fFlags=0x%x\n", pszURI, fFlags));
@@ -422,20 +423,26 @@
         /* Add the path to our internal file list (recursive in
          * the case of a directory). */
-        char *pszFileName = RTPathFilename(pszFilePath);
-        if (pszFileName)
-        {
-            Assert(pszFileName >= pszFilePath);
-            char *pszRoot = &pszFilePath[pszFileName - pszFilePath];
-            m_lstRoot.append(pszRoot);
-#ifdef DEBUG_andy
-            LogFlowFunc(("pszFilePath=%s, pszFileName=%s, pszRoot=%s\n",
-                         pszFilePath, pszFileName, pszRoot));
-#endif
-            rc = appendPathRecursive(pszFilePath,
-                                     pszFileName - pszFilePath,
-                                     fFlags);
+        size_t cbPathLen = RTPathStripTrailingSlash(pszFilePath);
+        if (cbPathLen)
+        {
+            char *pszFileName = RTPathFilename(pszFilePath);
+            if (pszFileName)
+            {
+                Assert(pszFileName >= pszFilePath);
+                char *pszRoot = &pszFilePath[pszFileName - pszFilePath];
+                m_lstRoot.append(pszRoot);
+#ifdef DEBUG_andy
+                LogFlowFunc(("pszFilePath=%s, pszFileName=%s, pszRoot=%s\n",
+                             pszFilePath, pszFileName, pszRoot));
+#endif
+                rc = appendPathRecursive(pszFilePath,
+                                         pszFileName - pszFilePath,
+                                         fFlags);
+            }
+            else
+                rc = VERR_NOT_FOUND;
         }
         else
-            rc = VERR_NOT_FOUND;
+            rc = VERR_INVALID_PARAMETER;
 
         RTStrFree(pszFilePath);
Index: /trunk/src/VBox/Main/src-client/GuestDnDImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestDnDImpl.cpp	(revision 50733)
+++ /trunk/src/VBox/Main/src-client/GuestDnDImpl.cpp	(revision 50734)
@@ -204,4 +204,6 @@
     HRESULT queryProgressTo(IProgress **ppProgress);
 
+    int writeToFile(const char *pszPath, size_t cbPath, void *pvData, size_t cbData, uint32_t fMode);
+
 public:
 
@@ -223,4 +225,8 @@
     /** Dropped files directory on the host. */
     Utf8Str              m_strDropDir;
+    /** The handle of the currently opened file being written to
+     *  or read from. */
+    RTFILE               m_hFile;
+    Utf8Str              m_strFile;
 
     ComObjPtr<Guest>     m_parent;
@@ -294,4 +300,5 @@
   , m_cbDataCurrent(0)
   , m_cbDataTotal(0)
+  , m_hFile(NIL_RTFILE)
   , m_parent(pGuest)
 {
@@ -303,4 +310,5 @@
 {
     reset();
+
     int rc = RTSemEventDestroy(m_EventSem);
     AssertRC(rc);
@@ -346,4 +354,11 @@
             break;
 
+        case VERR_NOT_FOUND:
+            /* Should not happen due to file locking on the guest, but anyway ... */
+            strError += Utf8StrFmt(pGuest->tr("One or more guest files or directories selected for transferring to the host were not"
+                                              "found on the guest anymore. This can be the case if the guest files were moved and/or"
+                                              "altered while the drag'n drop operation was in progress."));
+            break;
+
         case VERR_SHARING_VIOLATION:
             strError += Utf8StrFmt(pGuest->tr("One or more guest files or directories selected for transferring to the host were locked. "
@@ -367,4 +382,9 @@
 void DnDGuestResponse::reset(void)
 {
+    LogFlowThisFuncEnter();
+
+    m_defAction = 0;
+    m_allActions = 0;
+
     m_strDropDir = "";
     m_strFormat = "";
@@ -375,8 +395,14 @@
         m_pvData = NULL;
     }
-    m_cbData = 0;
-
+    m_cbData = 0;    
     m_cbDataCurrent = 0;
     m_cbDataTotal = 0;
+
+    if (m_hFile != NIL_RTFILE)
+    {
+        RTFileClose(m_hFile);
+        m_hFile = NIL_RTFILE;
+    }
+    m_strFile = "";
 }
 
@@ -492,4 +518,57 @@
 }
 
+int DnDGuestResponse::writeToFile(const char *pszPath, size_t cbPath, 
+                                  void *pvData, size_t cbData, uint32_t fMode)
+{
+    /** @todo Support locking more than one file at a time! We
+     *        might want to have a table in DnDGuestImpl which
+     *        keeps those file pointers around, or extend the
+     *        actual protocol for explicit open calls.
+     *  
+     *        For now we only keep one file open at a time, so if
+     *        a client does alternating writes to different files
+     *        this function will close the old and re-open the new
+     *        file on every call. */
+    int rc;
+    if (   m_hFile == NIL_RTFILE
+        || m_strFile != pszPath) 
+    {
+        char *pszFile = RTPathJoinA(m_strDropDir.c_str(), pszPath);
+        if (pszFile)
+        {
+            RTFILE hFile;
+            /** @todo Respect fMode!  */
+            rc = RTFileOpen(&hFile, pszFile,
+                              RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_WRITE 
+                            | RTFILE_O_WRITE | RTFILE_O_APPEND);
+            if (RT_SUCCESS(rc))
+            {
+                LogFlowFunc(("Opening \"%s\" (fMode=0x%x) for writing ...\n", 
+                             pszFile, fMode));
+
+                m_hFile = hFile;
+                m_strFile = pszPath;
+            }
+
+            RTStrFree(pszFile);
+        }
+        else
+            rc = VERR_NO_MEMORY;
+    }
+    else
+        rc = VINF_SUCCESS;
+
+    if (RT_SUCCESS(rc))
+    {
+        rc = RTFileWrite(m_hFile, pvData, cbData,
+                         NULL /* No partial writes */);
+
+        if (RT_SUCCESS(rc))
+            rc = dataSetStatus(cbData);
+    }
+
+    return rc;
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -719,5 +798,4 @@
 
         DnDGuestResponse *pResp = d->response();
-        /* This blocks until the request is answered (or timeout). */
         if (pResp->waitForGuestResponse() == VERR_TIMEOUT)
             return S_OK;
@@ -783,5 +861,4 @@
 
         DnDGuestResponse *pResp = d->response();
-        /* This blocks until the request is answered (or timeout). */
         if (pResp->waitForGuestResponse() == VERR_TIMEOUT)
             return S_OK;
@@ -813,5 +890,4 @@
 
         DnDGuestResponse *pResp = d->response();
-        /* This blocks until the request is answered (or timeout). */
         pResp->waitForGuestResponse();
     }
@@ -873,13 +949,14 @@
 
         DnDGuestResponse *pResp = d->response();
-        /* This blocks until the request is answered (or timeout). */
         if (pResp->waitForGuestResponse() == VERR_TIMEOUT)
             return S_OK;
 
-        /* Copy the response info */
+        /* Get the resulting action from the guest. */
         *pResultAction = d->toMainAction(pResp->defAction());
+
+        LogFlowFunc(("resFormat=%s, resAction=%RU32\n", 
+                     pResp->format().c_str(), pResp->defAction()));
+
         Bstr(pResp->format()).cloneTo(pstrFormat);
-
-        LogFlowFunc(("*pResultAction=%ld\n", *pResultAction));
     }
     catch (HRESULT hr2)
@@ -957,5 +1034,4 @@
                     paParms);
 
-        /* This blocks until the request is answered (or timed out). */
         DnDGuestResponse *pResp = d->response();
         if (pResp->waitForGuestResponse() == VERR_TIMEOUT)
@@ -1167,25 +1243,5 @@
                  pszPath, cbPath, fMode));
 
-    /** @todo Add file locking between calls! */
-    int rc;
-    char *pszFile = RTPathJoinA(pResp->dropDir().c_str(), pszPath);
-    if (pszFile)
-    {
-        RTFILE hFile;
-        rc = RTFileOpen(&hFile, pszFile,
-                        RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE | RTFILE_O_WRITE);
-        if (RT_SUCCESS(rc))
-        {
-            rc = RTFileWrite(hFile, pvData, cbData,
-                             NULL /* No partial writes */);
-            RTFileClose(hFile);
-        }
-        RTStrFree(pszFile);
-    }
-    else
-        rc = VERR_NO_MEMORY;
-
-    if (RT_SUCCESS(rc))
-        rc = pResp->dataSetStatus(cbData);
+    int rc = pResp->writeToFile(pszPath, cbPath, pvData, cbData, fMode);
 
     LogFlowFuncLeaveRC(rc);
