Changeset 33793 in vbox
- Timestamp:
- Nov 5, 2010 2:21:25 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r33792 r33793 612 612 * directory; needed for recursion. 613 613 * @param pszFilter Search filter (e.g. *.pdf). 614 * @param pszDest Destination directory. 614 615 * @param uFlags Copy flags. 615 616 * @param pcObjects Where to store the overall objects to … … 617 618 * @param pList Pointer to the object list to use. 618 619 */ 619 int ctrlCopyDirectoryRead(const char *pszRootDir, const char *pszSubDir, const char *pszFilter, 620 int ctrlCopyDirectoryRead(const char *pszRootDir, const char *pszSubDir, 621 const char *pszFilter, const char *pszDest, 620 622 uint32_t uFlags, uint32_t *pcObjects, PRTLISTNODE pList) 621 623 { … … 623 625 /* Sub directory is optional. */ 624 626 /* Filter directory is optional. */ 627 AssertPtrReturn(pszDest, VERR_INVALID_POINTER); 625 628 AssertPtrReturn(pcObjects, VERR_INVALID_POINTER); 626 629 AssertPtrReturn(pList, VERR_INVALID_POINTER); … … 673 676 if (pszNewSub) 674 677 { 675 rc = ctrlCopyDirectoryRead(pszRootDir, pszNewSub, pszFilter, 678 rc = ctrlCopyDirectoryRead(pszRootDir, pszNewSub, 679 pszFilter, pszDest, 676 680 uFlags, pcObjects, pList); 677 681 RTStrFree(pszNewSub); … … 707 711 DirEntry.szName) >= 0) 708 712 { 709 if (RTStrAPrintf(&pszFileDest, "%s%s ",710 psz SubDir ? pszSubDir : "",713 if (RTStrAPrintf(&pszFileDest, "%s%s%s", 714 pszDest, pszSubDir ? pszSubDir : "", 711 715 DirEntry.szName) <= 0) 712 716 { … … 771 775 && RTFileExists(pszSourceAbs)) /* We have a single file ... */ 772 776 { 773 RTListInit(pList); 774 rc = ctrlCopyDirectoryEntryAppend(pszSourceAbs, pszDest, pList); 775 *pcObjects = 1; 777 char *pszDestAbs = RTStrDup(pszDest); 778 if (pszDestAbs) 779 { 780 RTPathStripFilename(pszDestAbs); 781 rc = RTStrAAppend(&pszDestAbs, RTPATH_SLASH_STR); 782 if (RT_SUCCESS(rc)) 783 rc = RTStrAAppend(&pszDestAbs, RTPathFilename(pszSourceAbs)); 784 785 RTListInit(pList); 786 rc = ctrlCopyDirectoryEntryAppend(pszSourceAbs, pszDestAbs, pList); 787 *pcObjects = 1; 788 789 RTStrFree(pszDestAbs); 790 } 791 else 792 rc = VERR_NO_MEMORY; 776 793 } 777 794 else /* ... or a directory. */ … … 784 801 char *pszFilter = RTPathFilename(pszSourceAbs); 785 802 char *pszSourceAbsRoot = RTStrDup(pszSourceAbs); 786 if (pszSourceAbsRoot) 803 char *pszDestAbs = RTStrDup(pszDest); 804 if ( pszSourceAbsRoot 805 && pszDestAbs) 787 806 { 788 807 if (pszFilter) … … 809 828 if (RT_SUCCESS(rc)) 810 829 { 830 /* 831 * Make sure we have a valid destination path. All we can do 832 * here is to check whether we have a trailing slash -- the rest 833 * (i.e. path creation, rights etc.) needs to be done inside the guest. 834 */ 835 size_t cch = strlen(pszDestAbs); 836 if ( cch > 1 837 && !RTPATH_IS_SLASH(pszDestAbs[cch - 1]) 838 && !RTPATH_IS_SLASH(pszDestAbs[cch - 2])) 839 { 840 rc = RTStrAAppend(&pszDestAbs, RTPATH_SLASH_STR); 841 } 842 } 843 844 if (RT_SUCCESS(rc)) 845 { 811 846 RTListInit(pList); 812 847 rc = ctrlCopyDirectoryRead(pszSourceAbsRoot, NULL /* Sub directory */, 813 pszFilter, 848 pszFilter, pszDestAbs, 814 849 uFlags, pcObjects, pList); 815 850 if (RT_SUCCESS(rc) && *pcObjects == 0) … … 817 852 } 818 853 819 RTStrFree(pszSourceAbsRoot); 854 if (pszDestAbs) 855 RTStrFree(pszDestAbs); 856 if (pszSourceAbsRoot) 857 RTStrFree(pszSourceAbsRoot); 820 858 } 821 859 else … … 1174 1212 { 1175 1213 if (fVerbose) 1214 #ifndef DEBUG 1176 1215 RTPrintf("Copying \"%s\" (%u/%u) ...\n", 1177 1216 pNode->pszSourcePath, uCurObject, cObjects); 1178 1217 #else 1218 RTPrintf("Copying \"%s\" to \"%s\" (%u/%u) ...\n", 1219 pNode->pszSourcePath, pNode->pszDestPath, uCurObject, cObjects); 1220 #endif 1179 1221 /* Finally copy the desired file (if no dry run selected). */ 1180 1222 if (!fDryRun)
Note:
See TracChangeset
for help on using the changeset viewer.

