Changeset 80318 in vbox for trunk/src/VBox/GuestHost/SharedClipboard
- Timestamp:
- Aug 16, 2019 9:13:49 AM (5 years ago)
- Location:
- trunk/src/VBox/GuestHost/SharedClipboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp
r80283 r80318 222 222 } 223 223 224 /* static */ 224 /** 225 * Reads (handles) a specific directory reursively and inserts its entry into the 226 * objects's entry list. 227 * 228 * @returns VBox status code. 229 * @param pTransfer URI transfer object to handle. 230 * @param strDir Directory path to handle. 231 */ 232 int VBoxClipboardWinDataObject::readDir(PSHAREDCLIPBOARDURITRANSFER pTransfer, const Utf8Str &strDir) 233 { 234 LogFlowFunc(("strDir=%s\n", strDir.c_str())); 235 236 VBOXCLIPBOARDLISTOPENPARMS openParmsList; 237 int rc = SharedClipboardURIListOpenParmsInit(&openParmsList); 238 if (RT_SUCCESS(rc)) 239 { 240 rc = RTStrCopy(openParmsList.pszPath, openParmsList.cbPath, strDir.c_str()); 241 if (RT_SUCCESS(rc)) 242 { 243 SHAREDCLIPBOARDLISTHANDLE hList; 244 rc = SharedClipboardURITransferListOpen(pTransfer, &openParmsList, &hList); 245 if (RT_SUCCESS(rc)) 246 { 247 LogFlowFunc(("strDir=%s -> hList=%RU64\n", strDir.c_str(), hList)); 248 249 VBOXCLIPBOARDLISTHDR hdrList; 250 rc = SharedClipboardURITransferListGetHeader(pTransfer, hList, &hdrList); 251 if (RT_SUCCESS(rc)) 252 { 253 LogFlowFunc(("cTotalObjects=%RU64, cbTotalSize=%RU64\n\n", 254 hdrList.cTotalObjects, hdrList.cbTotalSize)); 255 256 for (uint64_t o = 0; o < hdrList.cTotalObjects; o++) 257 { 258 VBOXCLIPBOARDLISTENTRY entryList; 259 rc = SharedClipboardURITransferListRead(pTransfer, hList, &entryList); 260 if (RT_SUCCESS(rc)) 261 { 262 PSHAREDCLIPBOARDFSOBJINFO pFsObjInfo = (PSHAREDCLIPBOARDFSOBJINFO)entryList.pvInfo; 263 Assert(entryList.cbInfo == sizeof(SHAREDCLIPBOARDFSOBJINFO)); 264 265 Utf8Str strPath = strDir + Utf8Str("\\") + Utf8Str(entryList.pszName); 266 267 LogFlowFunc(("\t%s (%RU64 bytes) -> %s\n", 268 entryList.pszName, pFsObjInfo->cbObject, strPath.c_str())); 269 270 if (RTFS_IS_DIRECTORY(pFsObjInfo->Attr.fMode)) 271 { 272 FSOBJENTRY objEntry = { strPath.c_str(), *pFsObjInfo }; 273 274 m_lstEntries.push_back(objEntry); /** @todo Can this throw? */ 275 276 rc = readDir(pTransfer, strPath.c_str()); 277 } 278 else if (RTFS_IS_FILE(pFsObjInfo->Attr.fMode)) 279 { 280 FSOBJENTRY objEntry = { strPath.c_str(), *pFsObjInfo }; 281 282 m_lstEntries.push_back(objEntry); /** @todo Can this throw? */ 283 } 284 285 /** @todo Handle symlinks. */ 286 } 287 288 if ( RT_FAILURE(rc) 289 && pTransfer->Thread.fStop) 290 break; 291 } 292 } 293 294 SharedClipboardURITransferListClose(pTransfer, hList); 295 } 296 } 297 298 SharedClipboardURIListOpenParmsDestroy(&openParmsList); 299 } 300 301 LogFlowFuncLeaveRC(rc); 302 return rc; 303 } 225 304 226 305 /** … … 233 312 * @param pvUser Pointer to user-provided data. Of type VBoxClipboardWinDataObject. 234 313 */ 314 /* static */ 235 315 DECLCALLBACK(int) VBoxClipboardWinDataObject::readThread(RTTHREAD ThreadSelf, void *pvUser) 236 316 { … … 258 338 if (RT_SUCCESS(rc)) 259 339 { 340 LogFlowFunc(("cRoots=%RU32\n\n", pRootList->Hdr.cRoots)); 341 260 342 for (uint32_t i = 0; i < pRootList->Hdr.cRoots; i++) 261 343 { … … 270 352 if (RTFS_IS_DIRECTORY(pFsObjInfo->Attr.fMode)) 271 353 { 272 VBOXCLIPBOARDLISTOPENPARMS openParmsList; 273 rc = SharedClipboardURIListOpenParmsInit(&openParmsList); 274 if (RT_FAILURE(rc)) 275 break; 276 277 rc = RTStrCopy(openParmsList.pszPath, openParmsList.cbPath, pRootEntry->pszName); 278 if (RT_FAILURE(rc)) 279 break; 280 281 SHAREDCLIPBOARDLISTHANDLE hList; 282 rc = SharedClipboardURITransferListOpen(pTransfer, &openParmsList, &hList); 283 if (RT_SUCCESS(rc)) 284 { 285 LogFlowFunc(("hList=%RU64\n", hList)); 286 287 VBOXCLIPBOARDLISTHDR hdrList; 288 rc = SharedClipboardURITransferListGetHeader(pTransfer, hList, &hdrList); 289 if (RT_SUCCESS(rc)) 290 { 291 LogFlowFunc(("cTotalObjects=%RU64, cbTotalSize=%RU64\n\n", 292 hdrList.cTotalObjects, hdrList.cbTotalSize)); 293 294 do 295 { 296 VBOXCLIPBOARDLISTENTRY entryList; 297 rc = SharedClipboardURITransferListRead(pTransfer, hList, &entryList); 298 if (RT_SUCCESS(rc)) 299 { 300 PSHAREDCLIPBOARDFSOBJINFO pObjInfo = (PSHAREDCLIPBOARDFSOBJINFO)entryList.pvInfo; 301 Assert(entryList.cbInfo == sizeof(SHAREDCLIPBOARDFSOBJINFO)); 302 303 LogFlowFunc(("\t%s (%RU64 bytes)\n", entryList.pszName, pObjInfo->cbObject)); 304 305 FSOBJENTRY objEntry = { entryList.pszName, *pObjInfo }; 306 pThis->m_lstRootEntries.push_back(objEntry); /** @todo Can this throw? */ 307 } 308 else 309 { 310 if (rc == VERR_NO_MORE_FILES) /* End of list has been reached. */ 311 rc = VINF_SUCCESS; 312 break; 313 } 314 315 if (pTransfer->Thread.fStop) 316 break; 317 318 } while (RT_SUCCESS(rc)); 319 } 320 321 SharedClipboardURITransferListClose(pTransfer, hList); 322 } 323 324 SharedClipboardURIListOpenParmsDestroy(&openParmsList); 354 FSOBJENTRY objEntry = { pRootEntry->pszName, *pFsObjInfo }; 355 356 pThis->m_lstEntries.push_back(objEntry); /** @todo Can this throw? */ 357 358 rc = pThis->readDir(pTransfer, pRootEntry->pszName); 325 359 } 326 360 else if (RTFS_IS_FILE(pFsObjInfo->Attr.fMode)) … … 328 362 FSOBJENTRY objEntry = { pRootEntry->pszName, *pFsObjInfo }; 329 363 330 pThis->m_lst RootEntries.push_back(objEntry); /** @todo Can this throw? */364 pThis->m_lstEntries.push_back(objEntry); /** @todo Can this throw? */ 331 365 } 332 366 … … 383 417 const size_t cbFileDescriptor = fUnicode ? sizeof(FILEDESCRIPTORW) : sizeof(FILEDESCRIPTORA); 384 418 385 const UINT cItems = (UINT)m_lst RootEntries.size(); /** UINT vs. size_t. */419 const UINT cItems = (UINT)m_lstEntries.size(); /** UINT vs. size_t. */ 386 420 if (!cItems) 387 421 return VERR_NOT_FOUND; … … 403 437 char *pszFileSpec = NULL; 404 438 405 FsObjEntryList::const_iterator itRoot = m_lst RootEntries.begin();406 while (itRoot != m_lst RootEntries.end())439 FsObjEntryList::const_iterator itRoot = m_lstEntries.begin(); 440 while (itRoot != m_lstEntries.end()) 407 441 { 408 442 FILEDESCRIPTOR *pFD = &pFGD->fgd[curIdx]; … … 570 604 { 571 605 if ( pFormatEtc->lindex >= 0 572 && (ULONG)pFormatEtc->lindex < m_lst RootEntries.size())606 && (ULONG)pFormatEtc->lindex < m_lstEntries.size()) 573 607 { 574 608 m_uObjIdx = pFormatEtc->lindex; /* lIndex of FormatEtc contains the actual index to the object being handled. */ 575 609 576 FSOBJENTRY &fsObjEntry = m_lst RootEntries.at(m_uObjIdx);610 FSOBJENTRY &fsObjEntry = m_lstEntries.at(m_uObjIdx); 577 611 578 612 LogFlowFunc(("FormatIndex_FileContents: m_uObjIdx=%u (entry '%s')\n", m_uObjIdx, fsObjEntry.strPath.c_str())); … … 737 771 RT_NOREF(rc); 738 772 739 LogFlowFunc(("m_uObjIdx=%RU32 (total: %zu)\n", m_uObjIdx, m_lst RootEntries.size()));740 741 const bool fComplete = m_uObjIdx == m_lst RootEntries.size() - 1 /* Object index is zero-based */;773 LogFlowFunc(("m_uObjIdx=%RU32 (total: %zu)\n", m_uObjIdx, m_lstEntries.size())); 774 775 const bool fComplete = m_uObjIdx == m_lstEntries.size() - 1 /* Object index is zero-based */; 742 776 if (fComplete) 743 777 { -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-uri.cpp
r80285 r80318 952 952 if (RTFS_IS_DIRECTORY(objInfo.Attr.fMode)) 953 953 { 954 pHdr->cTotalObjects++; /* Add directory itself. */ 955 954 pHdr->cTotalObjects++; 955 956 RTDIR hDir; 957 rc = RTDirOpen(&hDir, pcszSrcPath); 956 958 if (RT_SUCCESS(rc)) 957 959 { 958 RTDIR hDir;959 rc = RTDirOpen(&hDir, pcszSrcPath);960 if (RT_SUCCESS(rc))960 size_t cbDirEntry = 0; 961 PRTDIRENTRYEX pDirEntry = NULL; 962 do 961 963 { 962 size_t cbDirEntry = 0;963 PRTDIRENTRYEX pDirEntry = NULL;964 do964 /* Retrieve the next directory entry. */ 965 rc = RTDirReadExA(hDir, &pDirEntry, &cbDirEntry, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK); 966 if (RT_FAILURE(rc)) 965 967 { 966 /* Retrieve the next directory entry. */ 967 rc = RTDirReadExA(hDir, &pDirEntry, &cbDirEntry, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK); 968 if (RT_FAILURE(rc)) 968 if (rc == VERR_NO_MORE_FILES) 969 rc = VINF_SUCCESS; 970 break; 971 } 972 973 switch (pDirEntry->Info.Attr.fMode & RTFS_TYPE_MASK) 974 { 975 #if 0 /* No recursion here (yet). */ 976 case RTFS_TYPE_DIRECTORY: 969 977 { 970 if (rc == VERR_NO_MORE_FILES) 971 rc = VINF_SUCCESS; 972 break; 973 } 974 975 switch (pDirEntry->Info.Attr.fMode & RTFS_TYPE_MASK) 976 { 977 #if 0 /* No recursion here (yet). */ 978 case RTFS_TYPE_DIRECTORY: 978 /* Skip "." and ".." entries. */ 979 if (RTDirEntryExIsStdDotLink(pDirEntry)) 980 break; 981 982 char *pszSrc = RTPathJoinA(pcszSrcPath, pDirEntry->szName); 983 if (pszSrc) 979 984 { 980 /* Skip "." and ".." entries. */ 981 if (RTDirEntryExIsStdDotLink(pDirEntry)) 982 break; 983 984 char *pszSrc = RTPathJoinA(pcszSrcPath, pDirEntry->szName); 985 if (pszSrc) 985 char *pszDst = RTPathJoinA(pcszDstPath, pDirEntry->szName); 986 if (pszDst) 986 987 { 987 char *pszDst = RTPathJoinA(pcszDstPath, pDirEntry->szName); 988 if (pszDst) 989 { 990 rc = sharedClipboardURITransferListHdrFromDir(pHdr, pszSrc, pszDst, 991 pcszDstBase, cchDstBase); 992 RTStrFree(pszDst); 993 } 994 else 995 rc = VERR_NO_MEMORY; 996 997 RTStrFree(pszSrc); 988 rc = sharedClipboardURITransferListHdrFromDir(pHdr, pszSrc, pszDst, 989 pcszDstBase, cchDstBase); 990 RTStrFree(pszDst); 998 991 } 999 992 else 1000 993 rc = VERR_NO_MEMORY; 1001 break; 994 995 RTStrFree(pszSrc); 1002 996 } 1003 #endif 1004 case RTFS_TYPE_FILE: 997 else 998 rc = VERR_NO_MEMORY; 999 break; 1000 } 1001 #endif 1002 case RTFS_TYPE_FILE: 1003 { 1004 char *pszSrc = RTPathJoinA(pcszSrcPath, pDirEntry->szName); 1005 if (pszSrc) 1005 1006 { 1006 char *pszSrc = RTPathJoinA(pcszSrcPath, pDirEntry->szName); 1007 if (pszSrc) 1008 { 1009 rc = sharedClipboardURITransferListHdrAddFile(pHdr, pszSrc); 1010 RTStrFree(pszSrc); 1011 } 1012 else 1013 rc = VERR_NO_MEMORY; 1014 break; 1007 rc = sharedClipboardURITransferListHdrAddFile(pHdr, pszSrc); 1008 RTStrFree(pszSrc); 1015 1009 } 1016 case RTFS_TYPE_SYMLINK: 1017 { 1018 /** @todo Not implemented yet. */ 1019 } 1020 1021 default: 1022 break; 1010 else 1011 rc = VERR_NO_MEMORY; 1012 break; 1023 1013 } 1024 1025 } while (RT_SUCCESS(rc)); 1026 1027 RTDirReadExAFree(&pDirEntry, &cbDirEntry); 1028 RTDirClose(hDir); 1029 } 1014 case RTFS_TYPE_SYMLINK: 1015 { 1016 /** @todo Not implemented yet. */ 1017 } 1018 1019 default: 1020 break; 1021 } 1022 1023 } while (RT_SUCCESS(rc)); 1024 1025 RTDirReadExAFree(&pDirEntry, &cbDirEntry); 1026 RTDirClose(hDir); 1030 1027 } 1031 1028 } … … 1125 1122 AssertFailedStmt(rc = VERR_NOT_SUPPORTED); 1126 1123 } 1124 1125 LogFlowFunc(("cTotalObj=%RU64, cbTotalSize=%RU64\n", pHdr->cTotalObjects, pHdr->cbTotalSize)); 1127 1126 } 1128 1127 else
Note:
See TracChangeset
for help on using the changeset viewer.