- Timestamp:
- Apr 30, 2015 2:27:39 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 99923
- Location:
- trunk/src/VBox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
r55549 r55556 1318 1318 1319 1319 uint32_t cbBuf = _64K; /** @todo Make this configurable? */ 1320 void *pvBuf = RTMemAlloc(cbBuf); 1320 void *pvBuf = RTMemAlloc(cbBuf); /** @todo Make this buffer part of PVBGLR3GUESTDNDCMDCTX? */ 1321 1321 if (!pvBuf) 1322 1322 return VERR_NO_MEMORY; 1323 1323 1324 1324 RTCString strPath = obj.GetDestPath(); 1325 LogFlowFunc(("strFile=%s (%zu), fMode=0x%x\n", strPath.c_str(), strPath.length(), obj.GetMode()));1326 1325 1327 1326 int rc = obj.Open(DnDURIObject::Source, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE); … … 1332 1331 } 1333 1332 1334 LogFlowFunc(("cbSize=%RU64, uProtocol=%RU32, uClientID=%RU32\n", obj.GetSize(), pCtx->uProtocol, pCtx->uClientID)); 1333 LogFlowFunc(("strFile=%s (%zu), cbSize=%RU64, fMode=0x%x\n", strPath.c_str(), strPath.length(), obj.GetSize(), obj.GetMode())); 1334 LogFlowFunc(("uProtocol=%RU32, uClientID=%RU32\n", pCtx->uProtocol, pCtx->uClientID)); 1335 1335 1336 1336 if (pCtx->uProtocol >= 2) /* Protocol version 2 and up sends a file header first. */ … … 1431 1431 } 1432 1432 1433 obj.Close(); 1434 1433 1435 RTMemFree(pvBuf); 1434 1436 -
trunk/src/VBox/GuestHost/DragAndDrop/DnDURIList.cpp
r55512 r55556 82 82 m_cbTotal += cbSize; 83 83 #ifdef DEBUG_andy 84 LogFlowFunc(("strSrcPath=%s, strDstPath=%s, fMode=0x%x, cbSize=%RU64, cbTotal=%zu\n", 85 pcszPath, &pcszPath[cbBaseLen], objInfo.Attr.fMode, cbSize, m_cbTotal)); 86 #endif 87 88 PRTDIR hDir; 84 LogFlowFunc(("strSrcPath=%s, strDstPath=%s, fMode=0x%x, cbSize=%RU64, cTotal=%RU32, cbTotal=%zu\n", 85 pcszPath, &pcszPath[cbBaseLen], objInfo.Attr.fMode, cbSize, m_cTotal, m_cbTotal)); 86 #endif 87 89 88 /* We have to try to open even symlinks, cause they could 90 89 * be symlinks to directories. */ 90 PRTDIR hDir; 91 91 rc = RTDirOpen(&hDir, pcszPath); 92 92 93 /* The following error happens when this was a symlink 93 * to a nfile or a regular file. */94 * to a file or a regular file. */ 94 95 if ( rc == VERR_PATH_NOT_FOUND 95 96 || rc == VERR_NOT_A_DIRECTORY) … … 150 151 pszNewFile, &pszNewFile[cbBaseLen], 151 152 objInfo1.Attr.fMode, cbSize)); 153 m_cTotal++; 152 154 m_cbTotal += cbSize; 155 #ifdef DEBUG_andy 156 LogFlowFunc(("strSrcPath=%s, strDstPath=%s, fMode=0x%x, cbSize=%RU64, cTotal=%RU32, cbTotal=%zu\n", 157 pszNewFile, &pszNewFile[cbBaseLen], objInfo1.Attr.fMode, cbSize, m_cTotal, m_cbTotal)); 158 #endif 153 159 } 154 160 else /* Handle symlink directories. */ 155 161 rc = appendPathRecursive(pszNewFile, cbBaseLen, fFlags); 156 #ifdef DEBUG_andy 157 LogFlowFunc(("strSrcPath=%s, strDstPath=%s, fMode=0x%x, cbSize=%RU64, cbTotal=%zu\n", 158 pszNewFile, &pszNewFile[cbBaseLen], objInfo1.Attr.fMode, cbSize, m_cbTotal)); 159 #endif 162 160 163 RTStrFree(pszNewFile); 161 164 } … … 166 169 167 170 default: 171 /* Just ignore the rest. */ 168 172 break; 169 173 } -
trunk/src/VBox/GuestHost/DragAndDrop/DnDURIObject.cpp
r55549 r55556 37 37 DnDURIObject::DnDURIObject(void) 38 38 : m_Type(Unknown) 39 , m_f Mode(0)39 , m_fCreationMode(0) 40 40 , m_cbSize(0) 41 41 , m_cbProcessed(0) … … 51 51 , m_strSrcPath(strSrcPath) 52 52 , m_strTgtPath(strDstPath) 53 , m_f Mode(fMode)53 , m_fCreationMode(fMode) 54 54 , m_cbSize(cbSize) 55 55 , m_cbProcessed(0) … … 199 199 rc = RTFileGetSize(u.m_hFile, &m_cbSize); 200 200 if (RT_SUCCESS(rc)) 201 { 202 LogFlowFunc(("cbSize=%RU64, fMode=%RU32\n", m_cbSize, m_fCreationMode)); 201 203 m_cbProcessed = 0; 204 } 202 205 } 203 206 else … … 345 348 Close(); 346 349 347 m_Type = Unknown;348 m_strSrcPath = "";349 m_strTgtPath = "";350 m_f Mode= 0;351 m_cbSize = 0;352 m_cbProcessed = 0;350 m_Type = Unknown; 351 m_strSrcPath = ""; 352 m_strTgtPath = ""; 353 m_fCreationMode = 0; 354 m_cbSize = 0; 355 m_cbProcessed = 0; 353 356 } 354 357 -
trunk/src/VBox/Main/include/GuestDnDPrivate.h
r55549 r55556 20 20 #define ____H_GUESTDNDPRIVATE 21 21 22 #include <iprt/dir.h> 23 #include <iprt/file.h> 24 22 25 #include "VBox/hgcmsvc.h" /* For PVBOXHGCMSVCPARM. */ 23 26 #include "VBox/GuestHost/DragAndDrop.h" … … 66 69 typedef struct GuestDnDData 67 70 { 71 GuestDnDData(void) 72 : cbToProcess(0) 73 , cbProcessed(0) { } 74 75 void Reset(void) 76 { 77 vecData.clear(); 78 cbToProcess = 0; 79 cbProcessed = 0; 80 } 81 68 82 /** Array (vector) of guest DnD data. This might be an URI list, according 69 83 * to the format being set. */ … … 73 87 /** Overall size (in bytes) of processed file data. */ 74 88 uint64_t cbProcessed; 89 75 90 } GuestDnDData; 91 92 /** 93 * Structure for keeping around URI (list) data. 94 */ 95 typedef struct GuestDnDURIData 96 { 97 GuestDnDURIData(void) 98 : pvScratchBuf(NULL) 99 , cbScratchBuf(0) { } 100 101 virtual ~GuestDnDURIData(void) 102 { 103 Reset(); 104 } 105 106 void Reset(void) 107 { 108 strDropDir = ""; 109 lstURI.Clear(); 110 lstDirs.clear(); 111 lstFiles.clear(); 112 if (pvScratchBuf) 113 { 114 RTMemFree(pvScratchBuf); 115 pvScratchBuf = NULL; 116 } 117 cbScratchBuf = 0; 118 } 119 120 int Rollback(void) 121 { 122 if (strDropDir.isEmpty()) 123 return VINF_SUCCESS; 124 125 int rc = VINF_SUCCESS; 126 int rc2; 127 128 /* Rollback by removing any stuff created. 129 * Note: Only remove empty directories, never ever delete 130 * anything recursive here! Steam (tm) knows best ... :-) */ 131 for (size_t i = 0; i < lstFiles.size(); i++) 132 { 133 rc2 = RTFileDelete(lstFiles.at(i).c_str()); 134 if (RT_SUCCESS(rc)) 135 rc = rc2; 136 } 137 138 for (size_t i = 0; i < lstDirs.size(); i++) 139 { 140 rc2 = RTDirRemove(lstDirs.at(i).c_str()); 141 if (RT_SUCCESS(rc)) 142 rc = rc2; 143 } 144 145 rc2 = RTDirRemove(strDropDir.c_str()); 146 if (RT_SUCCESS(rc)) 147 rc = rc2; 148 149 return rc; 150 } 151 152 /** Temporary drop directory on the host where to 153 * put the files sent from the guest. */ 154 com::Utf8Str strDropDir; 155 /** (Non-recursive) List of root URI objects to receive. */ 156 DnDURIList lstURI; 157 /** Current object to receive. */ 158 DnDURIObject objURI; 159 /** List for holding created directories in the case of a rollback. */ 160 RTCList<RTCString> lstDirs; 161 /** List for holding created files in the case of a rollback. */ 162 RTCList<RTCString> lstFiles; 163 /** Pointer to an optional scratch buffer to use for 164 * doing the actual chunk transfers. */ 165 void *pvScratchBuf; 166 /** Size (in bytes) of scratch buffer. */ 167 size_t cbScratchBuf; 168 169 } GuestDnDURIData; 76 170 77 171 /** … … 94 188 * This can be arbitrary data or an URI list. */ 95 189 GuestDnDData mData; 190 /** URI data structure. */ 191 GuestDnDURIData mURI; 96 192 /** Callback event to use. */ 97 193 GuestDnDCallbackEvent mCallback; 98 /** Struct for keeping data required for URI list processing. */99 struct100 {101 /** List of all URI objects to send. */102 DnDURIList lstURI;103 /** Pointer to scratch buffer to use for104 * doing the actual chunk transfers. */105 void *pvScratchBuf;106 /** Size (in bytes) of scratch buffer. */107 size_t cbScratchBuf;108 } mURI;109 194 110 195 } SENDDATACTX, *PSENDDATACTX; … … 131 216 * This can be arbitrary data or an URI list. */ 132 217 GuestDnDData mData; 218 /** URI data structure. */ 219 GuestDnDURIData mURI; 133 220 /** Callback event to use. */ 134 221 GuestDnDCallbackEvent mCallback; 135 /** Struct for keeping data required for URI list processing. */136 struct137 {138 /** Temporary drop directory on the host where to139 * put the files sent from the guest. */140 com::Utf8Str strDropDir;141 /** (Non-recursive) List of root URI objects to receive. */142 DnDURIList lstURI;143 /** Current object to receive. */144 DnDURIObject objURI;145 /** List for holding created directories in the case of a rollback. */146 RTCList<RTCString> lstDirs;147 /** List for holding created files in the case of a rollback. */148 RTCList<RTCString> lstFiles;149 150 } mURI;151 222 152 223 } RECVDATACTX, *PRECVDATACTX; -
trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp
r55549 r55556 317 317 uStatus, uPercentage, rcOp)); 318 318 319 int vrc = VINF_SUCCESS;319 int rc = VINF_SUCCESS; 320 320 if (!m_progress.isNull()) 321 321 { … … 383 383 } 384 384 385 LogFlowFuncLeaveRC( vrc);386 return vrc;385 LogFlowFuncLeaveRC(rc); 386 return rc; 387 387 } 388 388 -
trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp
r55549 r55556 593 593 if (RT_SUCCESS(rc)) 594 594 { 595 /** @todo Unescpae path before printing. */596 LogRel2(("DnD: Transferring guest file to host: %s\n", pCtx->mURI.objURI.GetDestPath().c_str()));597 598 595 /* Note: Protocol v1 does not send any file sizes, so always 0. */ 599 596 if (mDataBase.mProtocolVersion >= 2) 600 597 rc = pCtx->mURI.objURI.SetSize(cbSize); 598 599 /** @todo Unescpae path before printing. */ 600 LogRel2(("DnD: Transferring guest file to host: %s (%RU64 bytes, mode 0x%x)\n", 601 pCtx->mURI.objURI.GetDestPath().c_str(), pCtx->mURI.objURI.GetSize(), pCtx->mURI.objURI.GetMode())); 602 603 /** @todo Set progress object title to current file being transferred? */ 601 604 602 605 if (!cbSize) /* 0-byte file? Close again. */ … … 737 740 * Reset any old data. 738 741 */ 739 pCtx->mData.vecData.clear(); 740 pCtx->mData.cbToProcess = 0; 741 pCtx->mData.cbProcessed = 0; 742 743 pResp->reset(); 744 pResp->resetProgress(m_pGuest); 742 pCtx->mData.Reset(); 743 pCtx->mURI.Reset(); 745 744 746 745 /* Set the format we are going to retrieve to have it around 747 746 * when retrieving the data later. */ 747 pResp->reset(); 748 748 pResp->setFormat(pCtx->mFormat); 749 749 … … 876 876 return VERR_INVALID_POINTER; 877 877 878 #define REGISTER_CALLBACK(x) \878 #define REGISTER_CALLBACK(x) \ 879 879 rc = pResp->setCallback(x, i_receiveURIDataCallback, pCtx); \ 880 if (RT_FAILURE(rc)) \880 if (RT_FAILURE(rc)) \ 881 881 return rc; 882 882 883 #define UNREGISTER_CALLBACK(x) \ 884 rc = pResp->setCallback(x, NULL); \ 885 AssertRC(rc); 883 #define UNREGISTER_CALLBACK(x) \ 884 { \ 885 int rc2 = pResp->setCallback(x, NULL); \ 886 AssertRC(rc2); \ 887 } 886 888 887 889 /* … … 927 929 rc = pCtx->mCallback.Wait(msTimeout); 928 930 LogFlowFunc(("URI callback done, rc=%Rrc\n", rc)); 931 if (RT_SUCCESS(rc)) 932 { 933 rc = pCtx->mCallback.Result(); 934 LogFlowFunc(("Callback result is %Rrc\n", rc)); 935 } 929 936 } 930 937 … … 946 953 if (RT_FAILURE(rc)) 947 954 { 948 LogFlowFunc(("Rolling back ...\n")); 949 950 /* Rollback by removing any stuff created. */ 951 for (size_t i = 0; i < pCtx->mURI.lstFiles.size(); ++i) 952 RTFileDelete(pCtx->mURI.lstFiles.at(i).c_str()); 953 for (size_t i = 0; i < pCtx->mURI.lstDirs.size(); ++i) 954 RTDirRemove(pCtx->mURI.lstDirs.at(i).c_str()); 955 } 956 957 /* Try removing (hopefully) empty drop directory in any case. */ 958 if (pCtx->mURI.strDropDir.isNotEmpty()) 959 RTDirRemove(pCtx->mURI.strDropDir.c_str()); 955 int rc2 = pCtx->mURI.Rollback(); /** @todo Inform user on rollback failure? */ 956 LogFlowFunc(("Rolling back ended with rc=%Rrc\n", rc2)); 957 } 960 958 961 959 LogFlowFuncLeaveRC(rc); … … 1121 1119 } 1122 1120 1123 LogFlowFunc(("cbProcessed=%RU64, cbToProcess=%RU64, fNotify=%RTbool \n",1124 pCtx->mData.cbProcessed, pCtx->mData.cbToProcess, fNotify ));1121 LogFlowFunc(("cbProcessed=%RU64, cbToProcess=%RU64, fNotify=%RTbool, rc=%Rrc\n", 1122 pCtx->mData.cbProcessed, pCtx->mData.cbToProcess, fNotify, rc)); 1125 1123 1126 1124 if (fNotify) -
trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
r55549 r55556 737 737 LogRel2(("DnD: Transferring host file to guest: %s (%RU64 bytes, mode 0x%x)\n", 738 738 strPathSrc.c_str(), aFile.GetSize(), aFile.GetMode())); 739 740 /** @todo Set progress object title to current file being transferred? */ 739 741 } 740 742 else
Note:
See TracChangeset
for help on using the changeset viewer.