Changeset 69753 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Nov 19, 2017 2:27:58 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r69500 r69753 2223 2223 * cannot handle sub directories so we have to do the filtering ourselves. 2224 2224 */ 2225 PRTDIR pDir = NULL;2226 2225 if (RT_SUCCESS(vrc)) 2227 2226 { 2228 vrc = RTDirOpen(&pDir, szCurDir); 2229 if (RT_FAILURE(vrc)) 2230 pDir = NULL; 2231 } 2232 if (RT_SUCCESS(vrc)) 2233 { 2234 /* 2235 * Enumerate the directory tree. 2236 */ 2237 while (RT_SUCCESS(vrc)) 2238 { 2239 RTDIRENTRY DirEntry; 2240 vrc = RTDirRead(pDir, &DirEntry, NULL); 2241 if (RT_FAILURE(vrc)) 2227 RTDIR hDir; 2228 vrc = RTDirOpen(&hDir, szCurDir); 2229 if (RT_SUCCESS(vrc)) 2230 { 2231 /* 2232 * Enumerate the directory tree. 2233 */ 2234 while (RT_SUCCESS(vrc)) 2242 2235 { 2243 if (vrc == VERR_NO_MORE_FILES) 2244 vrc = VINF_SUCCESS; 2245 break; 2246 } 2247 /** @todo r=bird: This ain't gonna work on most UNIX file systems because 2248 * enmType is RTDIRENTRYTYPE_UNKNOWN. This is clearly documented in 2249 * RTDIRENTRY::enmType. For trunk, RTDirQueryUnknownType can be used. */ 2250 switch (DirEntry.enmType) 2251 { 2252 case RTDIRENTRYTYPE_DIRECTORY: 2236 RTDIRENTRY DirEntry; 2237 vrc = RTDirRead(hDir, &DirEntry, NULL); 2238 if (RT_FAILURE(vrc)) 2253 2239 { 2254 /* Skip "." and ".." entries. */ 2255 if ( !strcmp(DirEntry.szName, ".") 2256 || !strcmp(DirEntry.szName, "..")) 2240 if (vrc == VERR_NO_MORE_FILES) 2241 vrc = VINF_SUCCESS; 2242 break; 2243 } 2244 /** @todo r=bird: This ain't gonna work on most UNIX file systems because 2245 * enmType is RTDIRENTRYTYPE_UNKNOWN. This is clearly documented in 2246 * RTDIRENTRY::enmType. For trunk, RTDirQueryUnknownType can be used. */ 2247 switch (DirEntry.enmType) 2248 { 2249 case RTDIRENTRYTYPE_DIRECTORY: 2250 { 2251 /* Skip "." and ".." entries. */ 2252 if ( !strcmp(DirEntry.szName, ".") 2253 || !strcmp(DirEntry.szName, "..")) 2254 break; 2255 2256 if (pContext->pCmdCtx->cVerbose) 2257 RTPrintf("Directory: %s\n", DirEntry.szName); 2258 2259 if (enmFlags & kGctlCopyFlags_Recursive) 2260 { 2261 char *pszNewSub = NULL; 2262 if (pszSubDir) 2263 pszNewSub = RTPathJoinA(pszSubDir, DirEntry.szName); 2264 else 2265 { 2266 pszNewSub = RTStrDup(DirEntry.szName); 2267 RTPathStripTrailingSlash(pszNewSub); 2268 } 2269 2270 if (pszNewSub) 2271 { 2272 vrc = gctlCopyDirToGuest(pContext, 2273 pszSource, pszFilter, 2274 pszDest, enmFlags, pszNewSub); 2275 RTStrFree(pszNewSub); 2276 } 2277 else 2278 vrc = VERR_NO_MEMORY; 2279 } 2257 2280 break; 2258 2259 if (pContext->pCmdCtx->cVerbose) 2260 RTPrintf("Directory: %s\n", DirEntry.szName); 2261 2262 if (enmFlags & kGctlCopyFlags_Recursive) 2263 { 2264 char *pszNewSub = NULL; 2265 if (pszSubDir) 2266 pszNewSub = RTPathJoinA(pszSubDir, DirEntry.szName); 2267 else 2281 } 2282 2283 case RTDIRENTRYTYPE_SYMLINK: 2284 if ( (enmFlags & kGctlCopyFlags_Recursive) 2285 && (enmFlags & kGctlCopyFlags_FollowLinks)) 2268 2286 { 2269 pszNewSub = RTStrDup(DirEntry.szName); 2270 RTPathStripTrailingSlash(pszNewSub); 2271 } 2272 2273 if (pszNewSub) 2274 { 2275 vrc = gctlCopyDirToGuest(pContext, 2276 pszSource, pszFilter, 2277 pszDest, enmFlags, pszNewSub); 2278 RTStrFree(pszNewSub); 2287 /* Fall through to next case is intentional. */ 2279 2288 } 2280 2289 else 2281 vrc = VERR_NO_MEMORY; 2282 } 2283 break; 2284 } 2285 2286 case RTDIRENTRYTYPE_SYMLINK: 2287 if ( (enmFlags & kGctlCopyFlags_Recursive) 2288 && (enmFlags & kGctlCopyFlags_FollowLinks)) 2290 break; 2291 2292 case RTDIRENTRYTYPE_FILE: 2289 2293 { 2290 /* Fall through to next case is intentional. */ 2291 } 2292 else 2293 break; 2294 2295 case RTDIRENTRYTYPE_FILE: 2296 { 2297 if ( pszFilter 2298 && !RTStrSimplePatternMatch(pszFilter, DirEntry.szName)) 2299 { 2300 break; /* Filter does not match. */ 2301 } 2302 2303 if (pContext->pCmdCtx->cVerbose) 2304 RTPrintf("File: %s\n", DirEntry.szName); 2305 2306 if (!fDirCreated) 2307 { 2308 char *pszDestDir; 2309 vrc = gctlCopyTranslatePath(pszSource, szCurDir, 2310 pszDest, &pszDestDir); 2294 if ( pszFilter 2295 && !RTStrSimplePatternMatch(pszFilter, DirEntry.szName)) 2296 { 2297 break; /* Filter does not match. */ 2298 } 2299 2300 if (pContext->pCmdCtx->cVerbose) 2301 RTPrintf("File: %s\n", DirEntry.szName); 2302 2303 if (!fDirCreated) 2304 { 2305 char *pszDestDir; 2306 vrc = gctlCopyTranslatePath(pszSource, szCurDir, 2307 pszDest, &pszDestDir); 2308 if (RT_SUCCESS(vrc)) 2309 { 2310 vrc = gctlCopyDirCreate(pContext, pszDestDir); 2311 RTStrFree(pszDestDir); 2312 2313 fDirCreated = true; 2314 } 2315 } 2316 2311 2317 if (RT_SUCCESS(vrc)) 2312 2318 { 2313 vrc = gctlCopyDirCreate(pContext, pszDestDir); 2314 RTStrFree(pszDestDir); 2315 2316 fDirCreated = true; 2319 char *pszFileSource = RTPathJoinA(szCurDir, DirEntry.szName); 2320 if (pszFileSource) 2321 { 2322 char *pszFileDest; 2323 vrc = gctlCopyTranslatePath(pszSource, pszFileSource, 2324 pszDest, &pszFileDest); 2325 if (RT_SUCCESS(vrc)) 2326 { 2327 vrc = gctlCopyFileToDest(pContext, pszFileSource, 2328 pszFileDest, kGctlCopyFlags_None); 2329 RTStrFree(pszFileDest); 2330 } 2331 RTStrFree(pszFileSource); 2332 } 2317 2333 } 2334 break; 2318 2335 } 2319 2336 2320 if (RT_SUCCESS(vrc)) 2321 { 2322 char *pszFileSource = RTPathJoinA(szCurDir, DirEntry.szName); 2323 if (pszFileSource) 2324 { 2325 char *pszFileDest; 2326 vrc = gctlCopyTranslatePath(pszSource, pszFileSource, 2327 pszDest, &pszFileDest); 2328 if (RT_SUCCESS(vrc)) 2329 { 2330 vrc = gctlCopyFileToDest(pContext, pszFileSource, 2331 pszFileDest, kGctlCopyFlags_None); 2332 RTStrFree(pszFileDest); 2333 } 2334 RTStrFree(pszFileSource); 2335 } 2336 } 2337 break; 2337 default: 2338 break; 2338 2339 } 2339 2340 default: 2340 if (RT_FAILURE(vrc)) 2341 2341 break; 2342 2342 } 2343 if (RT_FAILURE(vrc)) 2344 break; 2345 } 2346 2347 RTDirClose(pDir); 2343 2344 RTDirClose(hDir); 2345 } 2348 2346 } 2349 2347 return vrc;
Note:
See TracChangeset
for help on using the changeset viewer.