Changeset 85429 in vbox for trunk/src/VBox/GuestHost/DragAndDrop
- Timestamp:
- Jul 23, 2020 11:31:53 AM (4 years ago)
- Location:
- trunk/src/VBox/GuestHost/DragAndDrop
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/DragAndDrop/DnDTransferList.cpp
r85428 r85429 192 192 const bool fIsFile = RTFS_IS_FILE(fMode); 193 193 194 rc = DnDTransferObjectInit (pObj, fIsFile ? DNDTRANSFEROBJTYPE_FILE : DNDTRANSFEROBJTYPE_DIRECTORY,195 pList->pszPathRootAbs, &pcszSrcAbs[idxPathToAdd]);194 rc = DnDTransferObjectInitEx(pObj, fIsFile ? DNDTRANSFEROBJTYPE_FILE : DNDTRANSFEROBJTYPE_DIRECTORY, 195 pList->pszPathRootAbs, &pcszSrcAbs[idxPathToAdd]); 196 196 if (RT_SUCCESS(rc)) 197 197 { -
trunk/src/VBox/GuestHost/DragAndDrop/DnDTransferObject.cpp
r85372 r85429 42 42 43 43 /** 44 * Initializes the object, internal version. 45 * 46 * @returns VBox status code. 47 * @param pObj DnD transfer object to initialize. 48 */ 49 static int dndTransferObjectInitInternal(PDNDTRANSFEROBJECT pObj) 50 { 51 AssertPtrReturn(pObj, VERR_INVALID_POINTER); 52 53 pObj->enmType = DNDTRANSFEROBJTYPE_UNKNOWN; 54 pObj->idxDst = 0; 55 pObj->pszPath = NULL; 56 57 RT_ZERO(pObj->u); 58 59 return VINF_SUCCESS; 60 } 61 62 /** 63 * Initializes the object. 64 * 65 * @returns VBox status code. 66 * @param pObj DnD transfer object to initialize. 67 */ 68 int DnDTransferObjectInit(PDNDTRANSFEROBJECT pObj) 69 { 70 return dndTransferObjectInitInternal(pObj); 71 } 72 73 /** 44 74 * Initializes the object with an expected object type and file path. 45 75 * … … 51 81 * Together with \a pcszPathSrcAbs this represents the complete absolute local path. 52 82 */ 53 int DnDTransferObjectInit(PDNDTRANSFEROBJECT pObj, DNDTRANSFEROBJTYPE enmType, const char *pcszPathSrcAbs, const char *pcszPathDst) 83 int DnDTransferObjectInitEx(PDNDTRANSFEROBJECT pObj, 84 DNDTRANSFEROBJTYPE enmType, const char *pcszPathSrcAbs, const char *pcszPathDst) 54 85 { 55 86 AssertPtrReturn(pObj, VERR_INVALID_POINTER); … … 58 89 AssertPtrReturn(pcszPathDst, VERR_INVALID_POINTER); 59 90 60 switch (enmType) 61 { 62 case DNDTRANSFEROBJTYPE_FILE: 63 { 64 pObj->u.File.hFile = NIL_RTFILE; 65 break; 66 } 67 68 case DNDTRANSFEROBJTYPE_DIRECTORY: 69 { 70 pObj->u.Dir.hDir = NIL_RTDIR; 71 break; 72 } 73 74 default: 75 AssertFailedReturn(VERR_NOT_IMPLEMENTED); 76 break; /* Never reached */ 77 } 78 79 int rc = DnDPathValidate(pcszPathDst, false /* Does not need to exist */); 80 if (RT_FAILURE(rc)) 81 return rc; 91 int rc = dndTransferObjectInitInternal(pObj); 92 AssertRCReturn(rc, rc); 93 94 rc = DnDPathValidate(pcszPathDst, false /* Does not need to exist */); 95 AssertRCReturn(rc, rc); 82 96 83 97 char szPath[RTPATH_MAX + 1]; -
trunk/src/VBox/GuestHost/DragAndDrop/testcase/tstDnDTransferObject.cpp
r85382 r85429 48 48 * Paths handling. 49 49 */ 50 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_FILE, "", "/rel/path/to/dst"));51 RTTEST_CHECK_RC (hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_FILE, "", "/rel/path/to/dst"), VERR_WRONG_ORDER);50 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_FILE, "", "/rel/path/to/dst")); 51 RTTEST_CHECK_RC (hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_FILE, "", "/rel/path/to/dst"), VERR_WRONG_ORDER); 52 52 DnDTransferObjectReset(&Obj); 53 53 54 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_FILE, "/src/path1", "dst/path2"));54 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_FILE, "/src/path1", "dst/path2")); 55 55 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetSourcePath(&Obj), "/src/path1/dst/path2") == 0); 56 56 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetDestPath(&Obj), "dst/path2") == 0); … … 58 58 && RTStrCmp(szBuf, "dst\\path2") == 0); 59 59 DnDTransferObjectReset(&Obj); 60 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_FILE, "", "dst/with/ending/slash/"));60 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_FILE, "", "dst/with/ending/slash/")); 61 61 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetDestPath(&Obj), "dst/with/ending/slash/") == 0); 62 62 RTTEST_CHECK(hTest, DnDTransferObjectGetDestPathEx(&Obj, DNDTRANSFEROBJPATHSTYLE_TRANSPORT, szBuf, sizeof(szBuf)) == VINF_SUCCESS 63 63 && RTStrCmp(szBuf, "dst/with/ending/slash/") == 0); 64 64 DnDTransferObjectReset(&Obj); 65 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "", "dst/path2"));65 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "", "dst/path2")); 66 66 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetSourcePath(&Obj), "dst/path2/") == 0); 67 67 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetDestPath(&Obj), "dst/path2/") == 0); 68 68 DnDTransferObjectReset(&Obj); 69 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "", "dst\\to\\path2"));69 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "", "dst\\to\\path2")); 70 70 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetSourcePath(&Obj), "dst/to/path2/") == 0); 71 71 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetDestPath(&Obj), "dst/to/path2/") == 0); 72 72 DnDTransferObjectReset(&Obj); 73 73 /* Test that the destination does not have a beginning slash. */ 74 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "/src/path2", "/dst/to/path2/"));74 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "/src/path2", "/dst/to/path2/")); 75 75 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetSourcePath(&Obj), "/src/path2/dst/to/path2/") == 0); 76 76 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetDestPath(&Obj), "dst/to/path2/") == 0); 77 77 DnDTransferObjectReset(&Obj); 78 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "/src/path2", "//////dst/to/path2/"));78 RTTEST_CHECK_RC_OK(hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "/src/path2", "//////dst/to/path2/")); 79 79 RTTEST_CHECK(hTest, RTStrCmp(DnDTransferObjectGetDestPath(&Obj), "dst/to/path2/") == 0); 80 80 … … 83 83 */ 84 84 DnDTransferObjectReset(&Obj); 85 RTTEST_CHECK(hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "/src/path3", "../../dst/path3") == VERR_INVALID_PARAMETER);86 RTTEST_CHECK(hTest, DnDTransferObjectInit (&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "/src/../../path3", "dst/path3") == VERR_INVALID_PARAMETER);85 RTTEST_CHECK(hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "/src/path3", "../../dst/path3") == VERR_INVALID_PARAMETER); 86 RTTEST_CHECK(hTest, DnDTransferObjectInitEx(&Obj, DNDTRANSFEROBJTYPE_DIRECTORY, "/src/../../path3", "dst/path3") == VERR_INVALID_PARAMETER); 87 87 88 88 /*
Note:
See TracChangeset
for help on using the changeset viewer.