- Timestamp:
- Apr 1, 2025 3:16:47 PM (2 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168259
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/DragAndDrop/DnDTransferList.cpp
r106061 r108813 769 769 AssertReturn(!(fFlags & ~DNDTRANSFERLIST_FLAGS_VALID_MASK), VERR_INVALID_FLAGS); 770 770 771 int rc = VINF_SUCCESS;772 773 771 if (!cPaths) /* Nothing to add? Bail out. */ 774 772 return VINF_SUCCESS; 775 773 776 char **papszPathsTmp = NULL; 777 778 /* If URI data is being handed in, extract the paths first. */ 779 if (enmFmt == DNDTRANSFERLISTFMT_URI) 780 { 781 papszPathsTmp = (char **)RTMemAlloc(sizeof(char *) * cPaths); 782 if (papszPathsTmp) 783 { 774 char **papszPathsConverted = NULL; 775 776 int rc = VINF_SUCCESS; 777 778 switch (enmFmt) 779 { 780 /* If URI data is being handed in, extract the paths first. */ 781 case DNDTRANSFERLISTFMT_URI: 782 { 783 papszPathsConverted = (char **)RTMemAllocZ(sizeof(char *) * cPaths); 784 AssertPtrReturn(papszPathsConverted, VERR_NO_MEMORY); 784 785 for (size_t i = 0; i < cPaths; i++) 785 papszPathsTmp[i] = RTUriFilePath(papcszPaths[i]); 786 } 787 else 788 rc = VERR_NO_MEMORY; 789 } 790 791 if (RT_FAILURE(rc)) 792 return rc; 786 { 787 papszPathsConverted[i] = RTUriFilePath(papcszPaths[i]); 788 AssertPtrBreakStmt(papszPathsConverted[i], rc = VERR_INVALID_PARAMETER); 789 } 790 791 papcszPaths = papszPathsConverted; 792 break; 793 } 794 795 case DNDTRANSFERLISTFMT_NATIVE: 796 /* Use original paths handed-in. */ 797 break; 798 799 default: 800 AssertFailedStmt(rc = VERR_NOT_SUPPORTED); 801 break; 802 } 793 803 794 804 /* If we don't have a root path set, try to find the common path of all handed-in paths. */ 795 if (!pList->pszPathRootAbs) 796 { 797 /* Can we work on the unmodified, handed-in data or do we need to use our temporary paths? */ 798 const char * const *papszPathTmp = enmFmt == DNDTRANSFERLISTFMT_NATIVE 799 ? papcszPaths : papszPathsTmp; 800 805 if ( RT_SUCCESS(rc) 806 && !pList->pszPathRootAbs) 807 { 801 808 size_t cchRootPath = 0; /* Length of root path in chars. */ 802 809 if (cPaths > 1) 803 { 804 cchRootPath = RTPathFindCommon(cPaths, papszPathTmp); 805 } 810 cchRootPath = RTPathFindCommon(cPaths, papcszPaths); 806 811 else 807 cchRootPath = RTPathParentLength(papszPathTmp[0]); 808 812 cchRootPath = RTPathParentLength(papcszPaths[0]); 809 813 if (cchRootPath) 810 814 { 811 815 /* Just use the first path in the array as the reference. */ 812 char *pszRootPath = RTStrDupN(pap szPathTmp[0], cchRootPath);816 char *pszRootPath = RTStrDupN(papcszPaths[0], cchRootPath); 813 817 if (pszRootPath) 814 818 { … … 826 830 { 827 831 /* 828 * Add all paths to the list.832 * Add all paths (as native paths) to the list. 829 833 */ 830 834 for (size_t i = 0; i < cPaths; i++) 831 835 { 832 const char *pcszPath = enmFmt == DNDTRANSFERLISTFMT_NATIVE 833 ? papcszPaths[i] : papszPathsTmp[i]; 834 rc = DnDTransferListAppendPath(pList, DNDTRANSFERLISTFMT_NATIVE, pcszPath, fFlags); 836 rc = DnDTransferListAppendPath(pList, DNDTRANSFERLISTFMT_NATIVE, papcszPaths[i], fFlags); 835 837 if (RT_FAILURE(rc)) 836 838 { 837 839 LogRel(("DnD: Adding path '%s' (format %#x, root '%s') to transfer list failed with %Rrc\n", 838 p cszPath, enmFmt, pList->pszPathRootAbs ? pList->pszPathRootAbs : "<None>", rc));840 papcszPaths[i], enmFmt, pList->pszPathRootAbs ? pList->pszPathRootAbs : "<None>", rc)); 839 841 break; 840 842 } … … 842 844 } 843 845 844 if (papszPaths Tmp)846 if (papszPathsConverted) 845 847 { 846 848 for (size_t i = 0; i < cPaths; i++) 847 RTStrFree(papszPaths Tmp[i]);848 RTMemFree(papszPaths Tmp);849 RTStrFree(papszPathsConverted[i]); 850 RTMemFree(papszPathsConverted); 849 851 } 850 852
Note:
See TracChangeset
for help on using the changeset viewer.