Changeset 42808 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Aug 14, 2012 2:01:11 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r42787 r42808 38 38 39 39 40 /* 41 * If the following define is enabled the Guest Additions update code also 42 * checks for locations which were not supposed to happen due to not resolving 43 * environment variables in VBoxService toolbox arguments. So a file copied 44 * to "%TEMP%\foo.exe" became "C:\Windows\EMPfoo.exe". 45 */ 40 46 #define VBOX_SERVICE_ENVARG_BUG 41 47 … … 1422 1428 } 1423 1429 1424 int GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags , ComObjPtr<GuestDirectory> &pDirectory)1430 int GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags) 1425 1431 { 1426 1432 LogFlowThisFunc(("strPath=%s, uMode=%x, uFlags=%x\n", … … 1476 1482 } 1477 1483 1478 if (RT_FAILURE(rc)) 1479 return rc; 1480 1481 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1482 1483 /* Create the directory object. */ 1484 HRESULT hr = pDirectory.createObject(); 1485 if (FAILED(hr)) 1486 return VERR_COM_UNEXPECTED; 1487 1488 /* Note: There will be a race between creating and getting/initing the directory 1489 object here. */ 1490 rc = pDirectory->init(this /* Parent */, strPath); 1491 if (RT_FAILURE(rc)) 1492 return rc; 1493 1494 /* Add the created directory to our vector. */ 1495 mData.mDirectories.push_back(pDirectory); 1496 1497 LogFlowFunc(("Added new directory \"%s\" (Session: %RU32)\n", 1498 strPath.c_str(), mData.mId)); 1484 LogFlowFuncLeaveRC(rc); 1485 return rc; 1486 } 1487 1488 int GuestSession::directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData) 1489 { 1490 LogFlowThisFunc(("strPath=%s\n", strPath.c_str())); 1491 1492 int rc = fsQueryInfoInternal(strPath, objData); 1493 if (RT_SUCCESS(rc)) 1494 { 1495 rc = objData.mType == FsObjType_Directory 1496 ? VINF_SUCCESS : VERR_NOT_A_DIRECTORY; 1497 } 1499 1498 1500 1499 LogFlowFuncLeaveRC(rc); … … 1795 1794 } 1796 1795 1797 /* Note: Will work on directories and others, too. */1798 1796 int GuestSession::fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData) 1797 { 1798 LogFlowThisFunc(("strPath=%s\n", strPath.c_str())); 1799 1800 int rc = fsQueryInfoInternal(strPath, objData); 1801 if (RT_SUCCESS(rc)) 1802 { 1803 rc = objData.mType == FsObjType_File 1804 ? VINF_SUCCESS : VERR_NOT_A_FILE; 1805 } 1806 1807 LogFlowFuncLeaveRC(rc); 1808 return rc; 1809 } 1810 1811 int GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize) 1812 { 1813 AssertPtrReturn(pllSize, VERR_INVALID_POINTER); 1814 1815 GuestFsObjData objData; 1816 int rc = fileQueryInfoInternal(strPath, objData); 1817 if (RT_SUCCESS(rc)) 1818 { 1819 if (objData.mType == FsObjType_File) 1820 *pllSize = objData.mObjectSize; 1821 else 1822 rc = VERR_NOT_A_FILE; 1823 } 1824 1825 return rc; 1826 } 1827 1828 int GuestSession::fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData) 1799 1829 { 1800 1830 LogFlowThisFunc(("strPath=%s\n", strPath.c_str())); … … 1868 1898 } 1869 1899 1870 int GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize)1871 {1872 AssertPtrReturn(pllSize, VERR_INVALID_POINTER);1873 1874 GuestFsObjData objData;1875 int rc = fileQueryInfoInternal(strPath, objData);1876 if (RT_SUCCESS(rc))1877 {1878 if (objData.mType == FsObjType_File)1879 *pllSize = objData.mObjectSize;1880 else1881 rc = VERR_NOT_A_FILE;1882 }1883 1884 return rc;1885 }1886 1887 1900 const GuestCredentials& GuestSession::getCredentials(void) 1888 1901 { … … 2238 2251 2239 2252 STDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode, 2240 ComSafeArrayIn(DirectoryCreateFlag_T, aFlags) , IGuestDirectory **aDirectory)2253 ComSafeArrayIn(DirectoryCreateFlag_T, aFlags)) 2241 2254 { 2242 2255 #ifndef VBOX_WITH_GUEST_CONTROL … … 2247 2260 if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0')) 2248 2261 return setError(E_INVALIDARG, tr("No directory to create specified")); 2249 /* aDirectory is optional. */2250 2262 2251 2263 AutoCaller autoCaller(this); … … 2269 2281 2270 2282 ComObjPtr <GuestDirectory> pDirectory; 2271 int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, fFlags, pDirectory); 2272 if (RT_SUCCESS(rc)) 2273 { 2274 if (aDirectory) 2275 { 2276 /* Return directory object to the caller. */ 2277 hr = pDirectory.queryInterfaceTo(aDirectory); 2278 } 2279 else 2280 { 2281 rc = directoryClose(pDirectory); 2282 if (RT_FAILURE(rc)) 2283 hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc); 2284 } 2285 } 2286 else 2283 int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, fFlags); 2284 if (RT_FAILURE(rc)) 2287 2285 { 2288 2286 switch (rc) … … 2462 2460 LogFlowThisFuncEnter(); 2463 2461 2464 AutoCaller autoCaller(this); 2465 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2466 2467 ReturnComNotImplemented(); 2462 if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0')) 2463 return setError(E_INVALIDARG, tr("No directory to query information for specified")); 2464 CheckComArgOutPointerValid(aInfo); 2465 2466 AutoCaller autoCaller(this); 2467 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2468 2469 HRESULT hr = S_OK; 2470 2471 GuestFsObjData objData; 2472 int rc = directoryQueryInfoInternal(Utf8Str(aPath), objData); 2473 if (RT_SUCCESS(rc)) 2474 { 2475 if (objData.mType == FsObjType_Directory) 2476 { 2477 ComObjPtr<GuestFsObjInfo> pFsObjInfo; 2478 hr = pFsObjInfo.createObject(); 2479 if (FAILED(hr)) 2480 return VERR_COM_UNEXPECTED; 2481 2482 rc = pFsObjInfo->init(objData); 2483 if (RT_SUCCESS(rc)) 2484 hr = pFsObjInfo.queryInterfaceTo(aInfo); 2485 } 2486 } 2487 2488 if (RT_FAILURE(rc)) 2489 { 2490 switch (rc) 2491 { 2492 /** @todo Add more errors here! */ 2493 2494 case VERR_NOT_A_DIRECTORY: 2495 hr = setError(VBOX_E_IPRT_ERROR, tr("Element exists but is not a directory")); 2496 break; 2497 2498 default: 2499 hr = setError(VBOX_E_IPRT_ERROR, tr("Querying directory information failed: %Rrc"), rc); 2500 break; 2501 } 2502 } 2503 2504 return hr; 2468 2505 #endif /* VBOX_WITH_GUEST_CONTROL */ 2469 2506 } … … 2753 2790 LogFlowThisFuncEnter(); 2754 2791 2755 AutoCaller autoCaller(this); 2756 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2757 2758 ReturnComNotImplemented(); 2792 if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0')) 2793 return setError(E_INVALIDARG, tr("No file to query information for specified")); 2794 CheckComArgOutPointerValid(aInfo); 2795 2796 AutoCaller autoCaller(this); 2797 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2798 2799 HRESULT hr = S_OK; 2800 2801 GuestFsObjData objData; 2802 int rc = fileQueryInfoInternal(Utf8Str(aPath), objData); 2803 if (RT_SUCCESS(rc)) 2804 { 2805 ComObjPtr<GuestFsObjInfo> pFsObjInfo; 2806 hr = pFsObjInfo.createObject(); 2807 if (FAILED(hr)) 2808 return VERR_COM_UNEXPECTED; 2809 2810 rc = pFsObjInfo->init(objData); 2811 if (RT_SUCCESS(rc)) 2812 hr = pFsObjInfo.queryInterfaceTo(aInfo); 2813 } 2814 2815 if (RT_FAILURE(rc)) 2816 { 2817 switch (rc) 2818 { 2819 /** @todo Add more errors here! */ 2820 2821 case VERR_NOT_A_FILE: 2822 hr = setError(VBOX_E_IPRT_ERROR, tr("Element exists but is not a file")); 2823 break; 2824 2825 default: 2826 hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file information failed: %Rrc"), rc); 2827 break; 2828 } 2829 } 2830 2831 return hr; 2759 2832 #endif /* VBOX_WITH_GUEST_CONTROL */ 2760 2833 }
Note:
See TracChangeset
for help on using the changeset viewer.