- Timestamp:
- Aug 6, 2012 1:31:38 PM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r42611 r42618 9381 9381 <interface 9382 9382 name="IGuestSession" extends="$unknown" 9383 uuid=" a8bbf136-3f0d-42cd-9fd3-c5816adb10a0"9383 uuid="9233c0b5-8f0d-48b2-9b90-b730880f1e35" 9384 9384 wsmap="managed" 9385 9385 > … … 9763 9763 <param name="exists" type="boolean" dir="return"> 9764 9764 <desc>TODO</desc> 9765 </param> 9766 </method> 9767 9768 <method name="fileRemove"> 9769 <desc> 9770 Remove a single file on the guest. 9771 9772 </desc> 9773 <param name="path" type="wstring" dir="in"> 9774 <desc>Path to the file to remove.</desc> 9775 </param> 9776 <param name="returnCode" type="long" dir="return"> 9777 <desc>The IPRT status code returned by the operation.</desc> 9765 9778 </param> 9766 9779 </method> -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r42611 r42618 167 167 STDMETHOD(FileCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestFile **aFile); 168 168 STDMETHOD(FileExists)(IN_BSTR aPath, BOOL *aExists); 169 STDMETHOD(FileRemove)(IN_BSTR aPath, LONG *aResultCode); 169 170 STDMETHOD(FileOpen)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile); 170 171 STDMETHOD(FileQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo); -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r42611 r42618 1928 1928 } 1929 1929 1930 STDMETHODIMP GuestSession::FileRemove(IN_BSTR aPath, LONG *aReturnCode) 1931 { 1932 #ifndef VBOX_WITH_GUEST_CONTROL 1933 ReturnComNotImplemented(); 1934 #else 1935 LogFlowThisFuncEnter(); 1936 1937 if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0')) 1938 return setError(E_INVALIDARG, tr("No file to remove specified")); 1939 1940 AutoCaller autoCaller(this); 1941 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1942 1943 GuestProcessStartupInfo procInfo; 1944 GuestProcessStream streamOut; 1945 int rc = VINF_SUCCESS; 1946 1947 try /* Can this be done without exceptions? */ 1948 { 1949 Utf8Str strPath(aPath); 1950 procInfo.mName = Utf8StrFmt(tr("Removing file \"%s\"", 1951 strPath.c_str())); 1952 procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_RM); 1953 /* Construct arguments. */ 1954 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 1955 procInfo.mArguments.push_back(Bstr(aPath)); /* The directory we want to create. */ 1956 } 1957 catch (...) 1958 { 1959 return E_OUTOFMEMORY; 1960 } 1961 1962 ComObjPtr<GuestProcess> pProcess; 1963 rc = processCreateExInteral(procInfo, pProcess); 1964 if (RT_SUCCESS(rc)) 1965 { 1966 GuestProcessWaitResult waitRes; 1967 BYTE byBuf[_64K]; 1968 size_t cbRead; 1969 1970 for (;;) 1971 { 1972 rc = pProcess->waitFor(ProcessWaitForFlag_StdOut, 1973 30 * 1000 /* Timeout */, waitRes); 1974 if ( RT_FAILURE(rc) 1975 || waitRes.mResult != ProcessWaitResult_StdOut) 1976 { 1977 break; 1978 } 1979 1980 rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf), 1981 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf), 1982 &cbRead); 1983 if (RT_FAILURE(rc)) 1984 break; 1985 1986 rc = streamOut.AddData(byBuf, cbRead); 1987 if (RT_FAILURE(rc)) 1988 break; 1989 } 1990 1991 LogFlowThisFunc(("rc=%Rrc, cbRead=%RU32, cbStreamOut=%RU32\n", 1992 rc, cbRead, streamOut.GetSize())); 1993 } 1994 1995 if (RT_FAILURE(rc)) 1996 return setError(E_FAIL, tr("Error while deleting file: %Rrc"), rc); 1997 if (!streamOut.GetSize()) 1998 return setError(E_FAIL, tr("No return code after deleting file")); 1999 GuestProcessStreamBlock streamBlock; 2000 rc = streamOut.ParseBlock(streamBlock); 2001 if (RT_SUCCESS(rc)) 2002 { 2003 streamBlock.GetString("fname"); 2004 int64_t i64rc; 2005 if (RT_FAILURE(streamBlock.GetInt64Ex("rc", &i64rc))) 2006 return setError(E_FAIL, tr("No return code after deleting file")); 2007 *aReturnCode = (LONG)i64rc; 2008 } 2009 else 2010 return setError(E_FAIL, tr("Error while getting return code from deleting file: %Rrc"), rc); 2011 return S_OK; 2012 #endif /* VBOX_WITH_GUEST_CONTROL */ 2013 } 2014 1930 2015 STDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile) 1931 2016 {
Note:
See TracChangeset
for help on using the changeset viewer.