Changeset 81143 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Oct 8, 2019 11:13:29 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r79257 r81143 2298 2298 HRESULT rc = S_OK; 2299 2299 2300 /* Destination must be a directory when specifying multiple sources. */ 2300 2301 if (cSources > 1) 2301 2302 { 2302 BOOL fExists = FALSE; 2303 rc = pCtx->pGuestSession->DirectoryExists(Bstr(pszDst).raw(), FALSE /*followSymlinks*/, &fExists); 2304 if (FAILED(rc) || !fExists) 2305 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Destination must be a directory when specifying multiple sources\n"); 2303 ComPtr<IGuestFsObjInfo> pFsObjInfo; 2304 rc = pCtx->pGuestSession->FsObjQueryInfo(Bstr(pszDst).raw(), FALSE /*followSymlinks*/, pFsObjInfo.asOutParam()); 2305 if (FAILED(rc)) 2306 { 2307 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Destination does not exist\n"); 2308 } 2309 else 2310 { 2311 FsObjType_T enmObjType = FsObjType_Unknown; /* Shut up MSC */ 2312 rc = pFsObjInfo->COMGETTER(Type)(&enmObjType); 2313 if (SUCCEEDED(rc)) 2314 { 2315 if (enmObjType != FsObjType_Directory) 2316 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Destination must be a directory when specifying multiple sources\n"); 2317 } 2318 else 2319 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Unable to determine destination type: %Rhrc\n", rc); 2320 } 2306 2321 } 2307 2322 … … 2310 2325 */ 2311 2326 if (pCtx->cVerbose) 2312 RTPrintf("Renaming %RU32 %s ...\n", cSources, cSources > 1 ? " entries" : "entry");2327 RTPrintf("Renaming %RU32 %s ...\n", cSources, cSources > 1 ? "sources" : "source"); 2313 2328 2314 2329 std::vector< Utf8Str >::iterator it = vecSources.begin(); … … 2316 2331 && !g_fGuestCtrlCanceled) 2317 2332 { 2318 Utf8Str str CurSource= (*it);2333 Utf8Str strSrcCur = (*it); 2319 2334 2320 2335 ComPtr<IGuestFsObjInfo> pFsObjInfo; 2321 2336 FsObjType_T enmObjType = FsObjType_Unknown; /* Shut up MSC */ 2322 rc = pCtx->pGuestSession->FsObjQueryInfo(Bstr(str CurSource).raw(), FALSE /*followSymlinks*/, pFsObjInfo.asOutParam());2337 rc = pCtx->pGuestSession->FsObjQueryInfo(Bstr(strSrcCur).raw(), FALSE /*followSymlinks*/, pFsObjInfo.asOutParam()); 2323 2338 if (SUCCEEDED(rc)) 2324 2339 rc = pFsObjInfo->COMGETTER(Type)(&enmObjType); 2325 2340 if (FAILED(rc)) 2326 2341 { 2327 if (pCtx->cVerbose) 2328 RTPrintf("Warning: Cannot stat for element \"%s\": No such file or directory\n", strCurSource.c_str()); 2342 RTPrintf("Cannot stat \"%s\": No such file or directory\n", strSrcCur.c_str()); 2329 2343 ++it; 2330 2344 continue; /* Skip. */ 2331 2345 } 2346 2347 char *pszDstCur = NULL; 2348 2349 if (cSources > 1) 2350 { 2351 pszDstCur = RTPathJoinA(pszDst, RTPathFilename(strSrcCur.c_str())); 2352 } 2353 else 2354 pszDstCur = RTStrDup(pszDst); 2355 2356 AssertPtrBreakStmt(pszDstCur, VERR_NO_MEMORY); 2332 2357 2333 2358 if (pCtx->cVerbose) 2334 2359 RTPrintf("Renaming %s \"%s\" to \"%s\" ...\n", 2335 2360 enmObjType == FsObjType_Directory ? "directory" : "file", 2336 str CurSource.c_str(), pszDst);2361 strSrcCur.c_str(), pszDstCur); 2337 2362 2338 2363 if (!fDryrun) 2339 2364 { 2340 if (enmObjType == FsObjType_Directory) 2341 { 2342 CHECK_ERROR_BREAK(pCtx->pGuestSession, FsObjRename(Bstr(strCurSource).raw(), 2343 Bstr(pszDst).raw(), 2344 ComSafeArrayAsInParam(aRenameFlags))); 2345 2346 /* Break here, since it makes no sense to rename mroe than one source to 2347 * the same directory. */ 2348 /** @todo r=bird: You are being kind of windowsy (or just DOSish) about the 'sense' part here, 2349 * while being totaly buggy about the behavior. 'VBoxManage guestcontrol ren dir1 dir2 dstdir' will 2350 * stop after 'dir1' and SILENTLY ignore dir2. If you tried this on Windows, you'd see an error 2351 * being displayed. If you 'man mv' on a nearby unixy system, you'd see that they've made perfect 2352 * sense out of any situation with more than one source. */ 2353 it = vecSources.end(); 2354 break; 2355 } 2356 else 2357 CHECK_ERROR_BREAK(pCtx->pGuestSession, FsObjRename(Bstr(strCurSource).raw(), 2358 Bstr(pszDst).raw(), 2359 ComSafeArrayAsInParam(aRenameFlags))); 2360 } 2365 CHECK_ERROR(pCtx->pGuestSession, FsObjRename(Bstr(strSrcCur).raw(), 2366 Bstr(pszDstCur).raw(), 2367 ComSafeArrayAsInParam(aRenameFlags))); 2368 /* Keep going with next item in case of errors. */ 2369 } 2370 2371 RTStrFree(pszDstCur); 2361 2372 2362 2373 ++it;
Note:
See TracChangeset
for help on using the changeset viewer.