Changeset 75380 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Nov 9, 2018 10:25:30 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 126515
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r75361 r75380 49 49 // funcs 50 50 /////////////////////////////////////////////////////////////////////////////// 51 52 /** 53 * Helper for formatting an indexed name or some such thing. 54 */ 55 static const char *FmtNm(char psz[80], const char *pszFormat, ...) 56 { 57 va_list va; 58 va_start(va, pszFormat); 59 RTStrPrintfV(psz, 80, pszFormat, va); 60 va_end(va); 61 return psz; 62 } 51 63 52 64 HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot, … … 368 380 } 369 381 382 /** Shows a shared folder. */ 383 static HRESULT showSharedFolder(ComPtr<ISharedFolder> &sf, VMINFO_DETAILS details, const char *pszDesc, 384 const char *pszMrInfix, size_t idxMr, bool fFirst) 385 { 386 Bstr name, hostPath, bstrAutoMountPoint; 387 BOOL writable = FALSE, fAutoMount = FALSE; 388 CHECK_ERROR2I_RET(sf, COMGETTER(Name)(name.asOutParam()), hrcCheck); 389 CHECK_ERROR2I_RET(sf, COMGETTER(HostPath)(hostPath.asOutParam()), hrcCheck); 390 CHECK_ERROR2I_RET(sf, COMGETTER(Writable)(&writable), hrcCheck); 391 CHECK_ERROR2I_RET(sf, COMGETTER(AutoMount)(&fAutoMount), hrcCheck); 392 CHECK_ERROR2I_RET(sf, COMGETTER(AutoMountPoint)(bstrAutoMountPoint.asOutParam()), hrcCheck); 393 394 if (fFirst && details != VMINFO_MACHINEREADABLE) 395 RTPrintf("\n\n"); 396 if (details == VMINFO_MACHINEREADABLE) 397 { 398 char szNm[80]; 399 outputMachineReadableString(FmtNm(szNm, "SharedFolderName%s%zu", pszMrInfix, idxMr), &name); 400 outputMachineReadableString(FmtNm(szNm, "SharedFolderPath%s%zu", pszMrInfix, idxMr), &hostPath); 401 } 402 else 403 { 404 RTPrintf("Name: '%ls', Host path: '%ls' (%s), %s%s%", 405 name.raw(), hostPath.raw(), pszDesc, writable ? "writable" : "readonly", fAutoMount ? ", auto-mount" : ""); 406 if (bstrAutoMountPoint.isNotEmpty()) 407 RTPrintf(", mount-point: '%ls'\n", bstrAutoMountPoint.raw()); 408 else 409 RTPrintf("\n"); 410 } 411 return S_OK; 412 } 413 414 370 415 static const char *paravirtProviderToString(ParavirtProvider_T provider, VMINFO_DETAILS details) 371 416 { … … 407 452 return "Unknown"; 408 453 } 409 }410 411 /**412 * Helper for formatting an indexed name or some such thing.413 */414 static const char *FmtNm(char psz[80], const char *pszFormat, ...)415 {416 va_list va;417 va_start(va, pszFormat);418 RTStrPrintfV(psz, 80, pszFormat, va);419 va_end(va);420 return psz;421 454 } 422 455 … … 2218 2251 { 2219 2252 ComPtr<ISharedFolder> sf = sfColl[i]; 2220 Bstr name, hostPath; 2221 sf->COMGETTER(Name)(name.asOutParam()); 2222 sf->COMGETTER(HostPath)(hostPath.asOutParam()); 2223 RTPrintf("Name: '%ls', Host path: '%ls' (global mapping)\n", name.raw(), hostPath.raw()); 2253 showSharedFolder(sf, details, "global mapping", "GlobalMapping", i + 1, numSharedFolders == 0); 2224 2254 ++numSharedFolders; 2225 2255 } … … 2229 2259 { 2230 2260 com::SafeIfaceArray <ISharedFolder> folders; 2231 2232 2261 CHECK_ERROR_RET(machine, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc); 2233 2234 2262 for (size_t i = 0; i < folders.size(); ++i) 2235 2263 { 2236 2264 ComPtr<ISharedFolder> sf = folders[i]; 2237 2238 Bstr name, hostPath; 2239 BOOL writable; 2240 sf->COMGETTER(Name)(name.asOutParam()); 2241 sf->COMGETTER(HostPath)(hostPath.asOutParam()); 2242 sf->COMGETTER(Writable)(&writable); 2243 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE) 2244 RTPrintf("\n\n"); 2245 if (details == VMINFO_MACHINEREADABLE) 2246 { 2247 outputMachineReadableString(FmtNm(szNm, "SharedFolderNameMachineMapping%zu", i + 1), &name); 2248 outputMachineReadableString(FmtNm(szNm, "SharedFolderPathMachineMapping%zu", i + 1), &hostPath); 2249 } 2250 else 2251 RTPrintf("Name: '%ls', Host path: '%ls' (machine mapping), %s\n", 2252 name.raw(), hostPath.raw(), writable ? "writable" : "readonly"); 2265 showSharedFolder(sf, details, "machine mapping", "MachineMapping", i + 1, numSharedFolders == 0); 2253 2266 ++numSharedFolders; 2254 2267 } … … 2258 2271 { 2259 2272 com::SafeIfaceArray <ISharedFolder> folders; 2260 2261 2273 CHECK_ERROR_RET(pConsole, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc); 2262 2263 2274 for (size_t i = 0; i < folders.size(); ++i) 2264 2275 { 2265 2276 ComPtr<ISharedFolder> sf = folders[i]; 2266 2267 Bstr name, hostPath; 2268 sf->COMGETTER(Name)(name.asOutParam()); 2269 sf->COMGETTER(HostPath)(hostPath.asOutParam()); 2270 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE) 2271 RTPrintf("\n\n"); 2272 if (details == VMINFO_MACHINEREADABLE) 2273 { 2274 outputMachineReadableString(FmtNm(szNm, "SharedFolderNameTransientMapping%zu", i + 1), &name); 2275 outputMachineReadableString(FmtNm(szNm, "SharedFolderPathTransientMapping%zu", i + 1), &hostPath); 2276 } 2277 else 2278 RTPrintf("Name: '%ls', Host path: '%ls' (transient mapping)\n", name.raw(), hostPath.raw()); 2277 showSharedFolder(sf, details, "transient mapping", "TransientMapping", i + 1, numSharedFolders == 0); 2279 2278 ++numSharedFolders; 2280 2279 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r74431 r75380 1096 1096 bool fWritable = true; 1097 1097 bool fAutoMount = false; 1098 char *pszAutoMountPoint = ""; 1098 1099 1099 1100 for (int i = 2; i < a->argc; i++) … … 1130 1131 fAutoMount = true; 1131 1132 } 1133 else if (!strcmp(a->argv[i], "--auto-mount-point")) 1134 { 1135 if (a->argc <= i + 1 || !*a->argv[i+1]) 1136 return errorArgument("Missing argument to '%s'", a->argv[i]); 1137 i++; 1138 pszAutoMountPoint = a->argv[i]; 1139 } 1132 1140 else 1133 1141 return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str()); … … 1160 1168 "Machine '%s' is not currently running.\n", pszMachineName); 1161 1169 1162 CHECK_ERROR(console, CreateSharedFolder(Bstr(name).raw(), 1163 Bstr(hostpath).raw(), 1164 fWritable, fAutoMount)); 1170 CHECK_ERROR(console, CreateSharedFolder(Bstr(name).raw(), Bstr(hostpath).raw(), 1171 fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw())); 1165 1172 a->session->UnlockMachine(); 1166 1173 } … … 1174 1181 a->session->COMGETTER(Machine)(sessionMachine.asOutParam()); 1175 1182 1176 CHECK_ERROR(sessionMachine, CreateSharedFolder(Bstr(name).raw(), 1177 Bstr(hostpath).raw(), 1178 fWritable, fAutoMount)); 1183 CHECK_ERROR(sessionMachine, CreateSharedFolder(Bstr(name).raw(), Bstr(hostpath).raw(), 1184 fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw())); 1179 1185 if (SUCCEEDED(rc)) 1180 1186 CHECK_ERROR(sessionMachine, SaveSettings());
Note:
See TracChangeset
for help on using the changeset viewer.