Changeset 57826 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 18, 2015 10:37:37 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.cpp
r56780 r57826 6 6 7 7 /* 8 * Copyright (C) 2014 Oracle Corporation8 * Copyright (C) 2014-2015 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 316 316 for (size_t i = 0; i < lstFilesURI.size(); i++) 317 317 { 318 /* Extract path from URI. */ 319 char *pszPath = RTUriPath(lstFilesURI.at(i).toAscii().constData()); 320 if ( pszPath 321 && strlen(pszPath) > 1) 318 char *pszFilePath = RTUriFilePath(lstFilesURI.at(i).toAscii().constData(), URI_FILE_FORMAT_AUTO); 319 if (pszFilePath) 322 320 { 323 pszPath++; /** @todo Skip first '/' (part of URI). Correct? */ 324 pszPath = RTPathChangeToDosSlashes(pszPath, false /* fForce */); 325 lstFiles.append(pszPath); 321 lstFiles.append(pszFilePath); 322 RTStrFree(pszFilePath); 323 } 324 else /* Unable to parse -- refuse entire request. */ 325 { 326 lstFiles.clear(); 327 rc = VERR_INVALID_PARAMETER; 328 break; 326 329 } 327 330 } 328 331 329 332 size_t cFiles = lstFiles.size(); 330 Assert(cFiles); 333 if ( RT_SUCCESS(rc) 334 && cFiles) 335 { 331 336 #ifdef DEBUG 332 LogFlowFunc(("Files (%zu)\n", cFiles));333 for (size_t i = 0; i < cFiles; i++)334 LogFlowFunc(("\tFile: %s\n", lstFiles.at(i).toAscii().constData()));337 LogFlowFunc(("Files (%zu)\n", cFiles)); 338 for (size_t i = 0; i < cFiles; i++) 339 LogFlowFunc(("\tFile: %s\n", lstFiles.at(i).toAscii().constData())); 335 340 #endif 336 size_t cchFiles = 0; /* Number of ASCII characters. */ 337 for (size_t i = 0; i < cFiles; i++) 338 { 339 cchFiles += strlen(lstFiles.at(i).toAscii().constData()); 340 cchFiles += 1; /* Terminating '\0'. */ 341 } 342 343 size_t cbBuf = sizeof(DROPFILES) + ((cchFiles + 1) * sizeof(RTUTF16)); 344 DROPFILES *pDropFiles = (DROPFILES *)RTMemAllocZ(cbBuf); 345 if (pDropFiles) 346 { 347 pDropFiles->pFiles = sizeof(DROPFILES); 348 pDropFiles->fWide = 1; /* We use unicode. Always. */ 349 350 uint8_t *pCurFile = (uint8_t *)pDropFiles + pDropFiles->pFiles; 351 AssertPtr(pCurFile); 352 341 size_t cchFiles = 0; /* Number of ASCII characters. */ 353 342 for (size_t i = 0; i < cFiles; i++) 354 343 { 355 size_t cchCurFile; 356 PRTUTF16 pwszFile; 357 rc = RTStrToUtf16(lstFiles.at(i).toAscii().constData(), &pwszFile); 344 cchFiles += strlen(lstFiles.at(i).toAscii().constData()); 345 cchFiles += 1; /* Terminating '\0'. */ 346 } 347 348 size_t cbBuf = sizeof(DROPFILES) + ((cchFiles + 1) * sizeof(RTUTF16)); 349 DROPFILES *pDropFiles = (DROPFILES *)RTMemAllocZ(cbBuf); 350 if (pDropFiles) 351 { 352 pDropFiles->pFiles = sizeof(DROPFILES); 353 pDropFiles->fWide = 1; /* We use unicode. Always. */ 354 355 uint8_t *pCurFile = (uint8_t *)pDropFiles + pDropFiles->pFiles; 356 AssertPtr(pCurFile); 357 358 for (size_t i = 0; i < cFiles; i++) 359 { 360 size_t cchCurFile; 361 PRTUTF16 pwszFile; 362 rc = RTStrToUtf16(lstFiles.at(i).toAscii().constData(), &pwszFile); 363 if (RT_SUCCESS(rc)) 364 { 365 cchCurFile = RTUtf16Len(pwszFile); 366 Assert(cchCurFile); 367 memcpy(pCurFile, pwszFile, cchCurFile * sizeof(RTUTF16)); 368 RTUtf16Free(pwszFile); 369 } 370 else 371 break; 372 373 pCurFile += cchCurFile * sizeof(RTUTF16); 374 375 /* Terminate current file name. */ 376 *pCurFile = L'\0'; 377 pCurFile += sizeof(RTUTF16); 378 } 379 358 380 if (RT_SUCCESS(rc)) 359 381 { 360 cchCurFile = RTUtf16Len(pwszFile); 361 Assert(cchCurFile); 362 memcpy(pCurFile, pwszFile, cchCurFile * sizeof(RTUTF16)); 363 RTUtf16Free(pwszFile); 364 } 365 else 366 break; 367 368 pCurFile += cchCurFile * sizeof(RTUTF16); 369 370 /* Terminate current file name. */ 371 *pCurFile = L'\0'; 372 pCurFile += sizeof(RTUTF16); 373 } 374 375 if (RT_SUCCESS(rc)) 376 { 377 *pCurFile = L'\0'; /* Final list terminator. */ 378 379 pMedium->tymed = TYMED_HGLOBAL; 380 pMedium->pUnkForRelease = NULL; 381 pMedium->hGlobal = GlobalAlloc( GMEM_ZEROINIT 382 | GMEM_MOVEABLE 383 | GMEM_DDESHARE, cbBuf); 384 if (pMedium->hGlobal) 385 { 386 LPVOID pvMem = GlobalLock(pMedium->hGlobal); 387 if (pvMem) 382 *pCurFile = L'\0'; /* Final list terminator. */ 383 384 pMedium->tymed = TYMED_HGLOBAL; 385 pMedium->pUnkForRelease = NULL; 386 pMedium->hGlobal = GlobalAlloc( GMEM_ZEROINIT 387 | GMEM_MOVEABLE 388 | GMEM_DDESHARE, cbBuf); 389 if (pMedium->hGlobal) 388 390 { 389 memcpy(pvMem, pDropFiles, cbBuf); 390 GlobalUnlock(pMedium->hGlobal); 391 392 hr = S_OK; 391 LPVOID pvMem = GlobalLock(pMedium->hGlobal); 392 if (pvMem) 393 { 394 memcpy(pvMem, pDropFiles, cbBuf); 395 GlobalUnlock(pMedium->hGlobal); 396 397 hr = S_OK; 398 } 399 else 400 rc = VERR_ACCESS_DENIED; 393 401 } 394 402 else 395 rc = VERR_ ACCESS_DENIED;403 rc = VERR_NO_MEMORY; 396 404 } 397 else 398 rc = VERR_NO_MEMORY;405 406 RTMemFree(pDropFiles); 399 407 } 400 401 RTMemFree(pDropFiles);402 408 } 403 409 }
Note:
See TracChangeset
for help on using the changeset viewer.