- Timestamp:
- Aug 2, 2012 10:24:28 AM (13 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r42507 r42525 9245 9245 <interface 9246 9246 name="IGuestSession" extends="$unknown" 9247 uuid=" 47a344ec-8495-49ad-bfab-8cd0ff8eb3cf"9247 uuid="89f39320-d86c-4705-a376-d083f3c5c4e3" 9248 9248 wsmap="managed" 9249 9249 > … … 9372 9372 </method> 9373 9373 9374 <method name=" DirectoryCreate">9374 <method name="directoryCreate"> 9375 9375 <desc> 9376 9376 TODO … … 9386 9386 <desc>TODO</desc> 9387 9387 </param> 9388 <param name="flags" type=" unsigned long" dir="in">9388 <param name="flags" type="DirectoryCreateFlag" dir="in" safearray="yes"> 9389 9389 <desc>TODO</desc> 9390 9390 </param> -
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r42507 r42525 268 268 struct GuestProcessInfo 269 269 { 270 /** The process' friendly name. */ 271 Utf8Str mName; 272 /** The actual command to execute. */ 270 273 Utf8Str mCommand; 271 274 ProcessArguments mArguments; … … 275 278 ProcessPriority_T mPriority; 276 279 ProcessAffinity mAffinity; 280 277 281 }; 278 282 -
trunk/src/VBox/Main/include/GuestDirectoryImpl.h
r42084 r42525 22 22 #include "VirtualBoxBase.h" 23 23 24 class GuestSession; 25 24 26 /** 25 27 * TODO … … 41 43 DECLARE_EMPTY_CTOR_DTOR(GuestDirectory) 42 44 43 HRESULT init(void);45 int init(GuestSession *aSession, const Utf8Str &strPath); 44 46 void uninit(void); 45 47 HRESULT FinalConstruct(void); … … 51 53 STDMETHOD(COMGETTER(DirectoryName))(BSTR *aName); 52 54 53 STDMETHOD(Read)(I GuestFsObjInfo **aInfo);55 STDMETHOD(Read)(IFsObjInfo **aInfo); 54 56 /** @} */ 55 57 … … 63 65 struct Data 64 66 { 67 GuestSession *mParent; 65 68 Utf8Str mName; 66 69 ComPtr<IGuestFsObjInfo> mFsObjInfo; -
trunk/src/VBox/Main/include/GuestProcessImpl.h
r42507 r42525 116 116 /** All related callbacks to this process. */ 117 117 GuestCtrlCallbacks mCallbacks; 118 /** The process' name. */119 Utf8Str mName;120 118 /** The process start information. */ 121 119 GuestProcessInfo mProcess; -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r42485 r42525 73 73 STDMETHOD(CopyFrom)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(ULONG, aFlags), IProgress **aProgress); 74 74 STDMETHOD(CopyTo)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(ULONG, aFlags), IProgress **aProgress); 75 STDMETHOD(DirectoryCreate)(IN_BSTR aPath, ULONG aMode, ULONG aFlags, IGuestDirectory **aDirectory);75 STDMETHOD(DirectoryCreate)(IN_BSTR aPath, ULONG aMode, ComSafeArrayIn(DirectoryCreateFlag_T, aFlags), IGuestDirectory **aDirectory); 76 76 STDMETHOD(DirectoryCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestDirectory **aDirectory); 77 77 STDMETHOD(DirectoryExists)(IN_BSTR aPath, BOOL *aExists); … … 124 124 * @{ */ 125 125 int directoryClose(ComObjPtr<GuestDirectory> pDirectory); 126 int directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory); 126 127 int dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData); 127 128 int fileClose(ComObjPtr<GuestFile> pFile); -
trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp
r42478 r42525 52 52 ///////////////////////////////////////////////////////////////////////////// 53 53 54 HRESULT GuestDirectory::init(void)54 int GuestDirectory::init(GuestSession *aSession, const Utf8Str &strPath) 55 55 { 56 56 /* Enclose the state transition NotReady->InInit->Ready. */ … … 58 58 AssertReturn(autoInitSpan.isOk(), E_FAIL); 59 59 60 mData.mParent = aSession; 61 mData.mName = strPath; 62 60 63 /* Confirm a successful initialization when it's the case. */ 61 64 autoInitSpan.setSucceeded(); 62 65 63 return S_OK;66 return VINF_SUCCESS; 64 67 } 65 68 … … 100 103 ///////////////////////////////////////////////////////////////////////////// 101 104 102 STDMETHODIMP GuestDirectory::Read(I GuestFsObjInfo **aInfo)105 STDMETHODIMP GuestDirectory::Read(IFsObjInfo **aInfo) 103 106 { 104 107 #ifndef VBOX_WITH_GUEST_CONTROL -
trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
r42509 r42525 266 266 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 267 267 268 mData.m Name.cloneTo(aName);268 mData.mProcess.mName.cloneTo(aName); 269 269 270 270 LogFlowFuncLeaveRC(S_OK); -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r42485 r42525 378 378 } 379 379 380 int GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory) 381 { 382 LogFlowThisFunc(("strPath=%s, uMode=%x, uFlags=%x\n", 383 strPath.c_str(), uMode, uFlags)); 384 385 GuestProcessInfo procInfo; 386 procInfo.mName = Utf8StrFmt(tr("Creating directory \"%s\"", strPath.c_str())); 387 procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKDIR); 388 389 int rc = VINF_SUCCESS; 390 391 /* Construct arguments. */ 392 if (uFlags & DirectoryCreateFlag_Parents) 393 procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */ 394 if (uMode) 395 { 396 procInfo.mArguments.push_back(Utf8Str("--mode")); /* Set the creation mode. */ 397 398 char szMode[16]; 399 if (RTStrPrintf(szMode, sizeof(szMode), "%o", uMode)) 400 { 401 procInfo.mArguments.push_back(Utf8Str(szMode)); 402 } 403 else 404 rc = VERR_INVALID_PARAMETER; 405 } 406 procInfo.mArguments.push_back(strPath); /* The directory we want to create. */ 407 408 ComObjPtr<GuestProcess> pProcess; 409 rc = processCreateExInteral(procInfo, pProcess); 410 if (RT_SUCCESS(rc)) 411 { 412 GuestProcessWaitResult waitRes; 413 rc = pProcess->waitFor(ProcessWaitForFlag_Terminate, 30 * 1000 /* Timeout */, waitRes); 414 if (RT_SUCCESS(rc)) 415 { 416 ProcessStatus_T procStatus; 417 HRESULT hr = pProcess->COMGETTER(Status)(&procStatus); 418 ComAssertComRC(hr); 419 if (procStatus == ProcessStatus_TerminatedNormally) 420 { 421 LONG lExitCode; 422 pProcess->COMGETTER(ExitCode)(&lExitCode); 423 if (lExitCode != 0) 424 return VERR_CANT_CREATE; 425 } 426 else 427 rc = VERR_BROKEN_PIPE; /** @todo Find a better rc. */ 428 } 429 } 430 431 if (RT_FAILURE(rc)) 432 return rc; 433 434 try 435 { 436 /* Create the directory object. */ 437 HRESULT hr = pDirectory.createObject(); 438 if (FAILED(hr)) throw VERR_COM_UNEXPECTED; 439 440 /* Note: There will be a race between creating and getting/initing the directory 441 object here. */ 442 rc = pDirectory->init(this /* Parent */, strPath); 443 if (RT_FAILURE(rc)) throw rc; 444 445 /* Add the created directory to our vector. */ 446 mData.mDirectories.push_back(pDirectory); 447 448 LogFlowFunc(("Added new directory (Session: %RU32) with process ID=%RU32\n", 449 mData.mId, mData.mNextProcessID)); 450 } 451 catch (int rc2) 452 { 453 rc = rc2; 454 } 455 456 LogFlowFuncLeaveRC(rc); 457 return rc; 458 } 459 380 460 int GuestSession::dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData) 381 461 { … … 504 584 break; /* Don't try too hard. */ 505 585 } 506 if (RT_FAILURE(rc)) throwrc;586 if (RT_FAILURE(rc)) return rc; 507 587 508 588 try … … 643 723 } 644 724 645 STDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode, ULONG aFlags, IGuestDirectory **aProgress) 646 { 647 #ifndef VBOX_WITH_GUEST_CONTROL 648 ReturnComNotImplemented(); 649 #else 650 LogFlowThisFuncEnter(); 651 652 AutoCaller autoCaller(this); 653 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 654 655 ReturnComNotImplemented(); 725 STDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode, 726 ComSafeArrayIn(DirectoryCreateFlag_T, aFlags), IGuestDirectory **aDirectory) 727 { 728 #ifndef VBOX_WITH_GUEST_CONTROL 729 ReturnComNotImplemented(); 730 #else 731 LogFlowThisFuncEnter(); 732 733 if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0')) 734 return setError(E_INVALIDARG, tr("No directory to create specified")); 735 /* aDirectory is optional. */ 736 737 AutoCaller autoCaller(this); 738 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 739 740 uint32_t fFlags = DirectoryCreateFlag_None; 741 if (aFlags) 742 { 743 com::SafeArray<DirectoryCreateFlag_T> flags(ComSafeArrayInArg(aFlags)); 744 for (size_t i = 0; i < flags.size(); i++) 745 fFlags |= flags[i]; 746 747 if (!(fFlags & DirectoryCreateFlag_Parents)) 748 return setError(E_INVALIDARG, tr("Unknown flags (%#x)"), fFlags); 749 } 750 751 HRESULT hr = S_OK; 752 753 ComObjPtr <GuestDirectory> pDirectory; 754 int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, (uint32_t)aFlags, pDirectory); 755 if (RT_SUCCESS(rc)) 756 { 757 if (aDirectory) 758 { 759 /* Return directory object to the caller. */ 760 hr = pDirectory.queryInterfaceTo(aDirectory); 761 } 762 else 763 { 764 rc = directoryClose(pDirectory); 765 if (RT_FAILURE(rc)) 766 hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc); 767 } 768 } 769 else 770 { 771 switch (rc) 772 { 773 case VERR_INVALID_PARAMETER: 774 hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Invalid parameters given")); 775 break; 776 777 case VERR_BROKEN_PIPE: 778 hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Unexpectedly aborted")); 779 break; 780 781 case VERR_CANT_CREATE: 782 hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Could not create directory")); 783 break; 784 785 default: 786 hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: %Rrc"), rc); 787 break; 788 } 789 } 790 791 return hr; 656 792 #endif /* VBOX_WITH_GUEST_CONTROL */ 657 793 }
Note:
See TracChangeset
for help on using the changeset viewer.