- Timestamp:
- Dec 16, 2013 9:39:13 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
r49923 r49924 393 393 { 394 394 case DragAndDropSvc::HOST_DND_HG_SND_DIR: 395 { 396 uint32_t fMode = 0; 397 rc = vbglR3DnDHGProcessSendDirMessage(uClientId, 398 pszPathname, 399 sizeof(pszPathname), 400 &cbPathname, 401 &fMode); 402 if (RT_SUCCESS(rc)) 403 rc = vbglR3DnDPathSanitize(pszPathname, sizeof(pszPathname)); 404 if (RT_SUCCESS(rc)) 395 405 { 396 uint32_t fMode = 0; 397 rc = vbglR3DnDHGProcessSendDirMessage(uClientId, 398 pszPathname, 399 sizeof(pszPathname), 400 &cbPathname, 401 &fMode); 402 if (RT_SUCCESS(rc)) 403 rc = vbglR3DnDPathSanitize(pszPathname, sizeof(pszPathname)); 404 if (RT_SUCCESS(rc)) 406 char *pszNewDir = RTPathJoinA(pszDropDir, pszPathname); 407 if (pszNewDir) 405 408 { 406 char *pszNewDir = RTPathJoinA(pszDropDir, pszPathname); 407 if (pszNewDir) 409 rc = RTDirCreate(pszNewDir, (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRWXU, 0); 410 if (!guestDirList.contains(pszNewDir)) 411 guestDirList.append(pszNewDir); 412 413 RTStrFree(pszNewDir); 414 } 415 else 416 rc = VERR_NO_MEMORY; 417 } 418 break; 419 } 420 case DragAndDropSvc::HOST_DND_HG_SND_FILE: 421 { 422 uint32_t cbDataRecv; 423 uint32_t fMode = 0; 424 rc = vbglR3DnDHGProcessSendFileMessage(uClientId, 425 pszPathname, 426 sizeof(pszPathname), 427 &cbPathname, 428 pvTmpData, 429 cbTmpData, 430 &cbDataRecv, 431 &fMode); 432 if (RT_SUCCESS(rc)) 433 rc = vbglR3DnDPathSanitize(pszPathname, sizeof(pszPathname)); 434 if (RT_SUCCESS(rc)) 435 { 436 char *pszNewFile = RTPathJoinA(pszDropDir, pszPathname); 437 if (pszNewFile) 438 { 439 RTFILE hFile; 440 /** @todo r=andy Keep the file open and locked during the actual file transfer. Otherwise this will 441 * create all sorts of funny races because we don't know if the guest has 442 * modified the file in between the file data send calls. */ 443 rc = RTFileOpen(&hFile, pszNewFile, 444 RTFILE_O_WRITE | RTFILE_O_APPEND | RTFILE_O_DENY_ALL | RTFILE_O_OPEN_CREATE); 445 if (RT_SUCCESS(rc)) 408 446 { 409 rc = RTDirCreate(pszNewDir, (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRWXU, 0); 410 if (!guestDirList.contains(pszNewDir)) 411 guestDirList.append(pszNewDir); 412 413 RTStrFree(pszNewDir); 414 } 415 else 416 rc = VERR_NO_MEMORY; 417 } 418 break; 419 } 420 case DragAndDropSvc::HOST_DND_HG_SND_FILE: 421 { 422 uint32_t cbDataRecv; 423 uint32_t fMode = 0; 424 rc = vbglR3DnDHGProcessSendFileMessage(uClientId, 425 pszPathname, 426 sizeof(pszPathname), 427 &cbPathname, 428 pvTmpData, 429 cbTmpData, 430 &cbDataRecv, 431 &fMode); 432 if (RT_SUCCESS(rc)) 433 rc = vbglR3DnDPathSanitize(pszPathname, sizeof(pszPathname)); 434 if (RT_SUCCESS(rc)) 435 { 436 char *pszNewFile = RTPathJoinA(pszDropDir, pszPathname); 437 if (pszNewFile) 438 { 439 RTFILE hFile; 440 /** @todo r=andy Keep the file open and locked during the actual file transfer. Otherwise this will 441 * create all sorts of funny races because we don't know if the guest has 442 * modified the file in between the file data send calls. */ 443 rc = RTFileOpen(&hFile, pszNewFile, RTFILE_O_WRITE | RTFILE_O_APPEND | RTFILE_O_DENY_ALL | RTFILE_O_OPEN_CREATE); 447 rc = RTFileSeek(hFile, 0, RTFILE_SEEK_END, NULL); 444 448 if (RT_SUCCESS(rc)) 445 449 { 446 rc = RTFileSeek(hFile, 0, RTFILE_SEEK_END, NULL); 447 if (RT_SUCCESS(rc)) 448 { 449 rc = RTFileWrite(hFile, pvTmpData, cbDataRecv, 0); 450 /* Valid UNIX mode? */ 451 if (RT_SUCCESS(rc) 452 && (fMode & RTFS_UNIX_MASK)) rc = RTFileSetMode(hFile, (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR); 453 } 454 RTFileClose(hFile); 455 if (!guestFileList.contains(pszNewFile)) 456 guestFileList.append(pszNewFile); 450 rc = RTFileWrite(hFile, pvTmpData, cbDataRecv, 0); 451 /* Valid UNIX mode? */ 452 if ( RT_SUCCESS(rc) 453 && (fMode & RTFS_UNIX_MASK)) 454 rc = RTFileSetMode(hFile, (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR); 457 455 } 458 459 RTStrFree(pszNewFile); 456 RTFileClose(hFile); 457 if (!guestFileList.contains(pszNewFile)) 458 guestFileList.append(pszNewFile); 460 459 } 461 else 462 rc = VERR_NO_MEMORY;460 461 RTStrFree(pszNewFile); 463 462 } 464 break; 463 else 464 rc = VERR_NO_MEMORY; 465 465 } 466 break; 467 } 466 468 case DragAndDropSvc::HOST_DND_HG_EVT_CANCEL: 467 { 468 rc = vbglR3DnDHGProcessCancelMessage(uClientId); 469 if (RT_SUCCESS(rc)) rc = VERR_CANCELLED; 470 /* Break out of the loop. */ 471 } 469 { 470 rc = vbglR3DnDHGProcessCancelMessage(uClientId); 471 if (RT_SUCCESS(rc)) 472 rc = VERR_CANCELLED; 473 /* Break out of the loop. */ 474 } 472 475 default: 473 476 fLoop = false; … … 477 480 else 478 481 { 479 if (rc == VERR_NO_DATA) rc = VINF_SUCCESS; 482 if (rc == VERR_NO_DATA) 483 rc = VINF_SUCCESS; 480 484 break; 481 485 }
Note:
See TracChangeset
for help on using the changeset viewer.