- Timestamp:
- Oct 25, 2010 11:34:00 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/GuestImpl.cpp
r33411 r33412 1851 1851 try 1852 1852 { 1853 /*ULONG cObjectsToCopy = 0;1854 RTLISTNODE listEntries;*/1855 1856 1853 Utf8Str Utf8Source(aSource); 1857 1854 Utf8Str Utf8Dest(aDest); … … 1958 1955 RTFileClose(fileSource); 1959 1956 } 1960 #if 01961 /*1962 * Does the source directory exist?1963 */1964 if (RTDirExists(pszSourceAbs))1965 {1966 /* If no trailing slash is present, append. */1967 size_t cch = strlen(pszSourceAbs);1968 if ( cch > 11969 && !RTPATH_IS_SLASH(pszSourceAbs[cch - 1])1970 && !RTPATH_IS_SLASH(pszSourceAbs[cch - 2]))1971 {1972 int vrc = RTStrAAppend(&pszSourceAbs, RTPATH_SLASH_STR);1973 if (RT_FAILURE(vrc))1974 rc = setError(VBOX_E_IPRT_ERROR,1975 tr("Failed to extend source path, rc=%Rrc\n"), vrc);1976 }1977 }1978 1979 if (SUCCEEDED(rc))1980 {1981 #endif1982 #if 01983 /*1984 * Create progress object. Note that this is a multi operation1985 * object to perform an operation per file object we just gathered1986 * in our list above.1987 *1988 * Stages:1989 * - 0: Starting copy process1990 * - 1: Copying file1991 * - 2: Finished1992 */1993 ComObjPtr <Progress> progress;1994 rc = progress.createObject();1995 if (SUCCEEDED(rc))1996 {1997 rc = progress->init(static_cast<IGuest*>(this),1998 Bstr(tr("Copying to guest")).raw(),1999 TRUE,2000 3, /* Number of stages. */2001 Bstr(tr("Starting ...")).raw()); /* Description of first stage. */2002 }2003 if (FAILED(rc)) return rc;2004 2005 rc = guest->ExecuteProcess(Bstr(Utf8Cmd).raw(), uFlags,2006 ComSafeArrayAsInParam(args),2007 ComSafeArrayAsInParam(env),2008 Bstr(Utf8UserName).raw(),2009 Bstr(Utf8Password).raw(), u32TimeoutMS,2010 &uPID, progress.asOutParam());2011 if (SUCCEEDED(rc))2012 {2013 2014 }2015 #endif2016 #if 02017 }2018 2019 if (SUCCEEDED(rc))2020 {2021 LogRel(("Copying \"%s\" to guest into \"%s\" ...\n",2022 pszSourceAbs, Utf8Dest.c_str()));2023 2024 /*2025 * Count objects to copy and build file list.2026 */2027 RTListInit(&listEntries);2028 int vrc = directoryRead(pszSourceAbs, NULL /* Filter */,2029 aFlags, &cObjectsToCopy, &listEntries);2030 if (RT_FAILURE(vrc))2031 {2032 if (vrc != VERR_FILE_NOT_FOUND) /* If no files found, this is no error! */2033 rc = setError(VBOX_E_IPRT_ERROR,2034 tr("Error reading source directory \"%s\", rc=%Rrc"),2035 pszSourceAbs, vrc);2036 }2037 }2038 RTStrFree(pszSourceAbs);2039 }2040 2041 if (SUCCEEDED(rc))2042 {2043 if (cObjectsToCopy) /* Do we have some objects to copy? */2044 {2045 /*2046 * Create progress object. Note that this is a multi operation2047 * object to perform an operation per file object we just gathered2048 * in our list above.2049 */2050 ComObjPtr <Progress> progress;2051 rc = progress.createObject();2052 if (SUCCEEDED(rc))2053 {2054 rc = progress->init(static_cast<IGuest*>(this),2055 Bstr(tr("Copying to guest")).raw(),2056 TRUE,2057 cObjectsToCopy, /* Number of operations. */2058 Bstr(tr("Copying ...")).raw()); /* Description of first stage. */2059 }2060 if (FAILED(rc)) return rc;2061 #endif2062 #if 02063 /*2064 * Now copy all files in the list ...2065 */2066 for (ULONG l=0; l < cObjectsToCopy; l++)2067 {2068 rc = guest->ExecuteProcess(Bstr(Utf8Cmd).raw(), uFlags,2069 ComSafeArrayAsInParam(args),2070 ComSafeArrayAsInParam(env),2071 Bstr(Utf8UserName).raw(),2072 Bstr(Utf8Password).raw(), u32TimeoutMS,2073 &uPID, progress.asOutParam());2074 }2075 #endif2076 #if 02077 if (SUCCEEDED(rc))2078 {2079 PCALLBACKDATAEXECSTATUS pData = (PCALLBACKDATAEXECSTATUS)RTMemAlloc(sizeof(CALLBACKDATAEXECSTATUS));2080 AssertReturn(pData, VBOX_E_IPRT_ERROR);2081 RT_ZERO(*pData);2082 uContextID = addCtrlCallbackContext(VBOXGUESTCTRLCALLBACKTYPE_EXEC_START,2083 pData, sizeof(CALLBACKDATAEXECSTATUS), progress);2084 Assert(uContextID > 0);2085 2086 VBOXHGCMSVCPARM paParms[15];2087 int i = 0;2088 paParms[i++].setUInt32(uContextID);2089 paParms[i++].setPointer((void*)Utf8Command.c_str(), (uint32_t)Utf8Command.length() + 1);2090 paParms[i++].setUInt32(aFlags);2091 paParms[i++].setUInt32(uNumArgs);2092 paParms[i++].setPointer((void*)pszArgs, cbArgs);2093 paParms[i++].setUInt32(uNumEnv);2094 paParms[i++].setUInt32(cbEnv);2095 paParms[i++].setPointer((void*)pvEnv, cbEnv);2096 paParms[i++].setPointer((void*)Utf8UserName.c_str(), (uint32_t)Utf8UserName.length() + 1);2097 paParms[i++].setPointer((void*)Utf8Password.c_str(), (uint32_t)Utf8Password.length() + 1);2098 paParms[i++].setUInt32(aTimeoutMS);2099 2100 VMMDev *vmmDev;2101 {2102 /* Make sure mParent is valid, so set the read lock while using.2103 * Do not keep this lock while doing the actual call, because in the meanwhile2104 * another thread could request a write lock which would be a bad idea ... */2105 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);2106 2107 /* Forward the information to the VMM device. */2108 AssertPtr(mParent);2109 vmmDev = mParent->getVMMDev();2110 }2111 2112 if (vmmDev)2113 {2114 LogFlowFunc(("hgcmHostCall numParms=%d\n", i));2115 vrc = vmmDev->hgcmHostCall("VBoxGuestControlSvc", HOST_EXEC_CMD,2116 i, paParms);2117 }2118 else2119 vrc = VERR_INVALID_VM_HANDLE;2120 }2121 #endif2122 #if 02123 /* Destroy file list. */2124 VBoxGuestDirEntry *pNode = RTListNodeGetFirst(&listEntries, VBoxGuestDirEntry, Node);2125 while (pNode)2126 {2127 VBoxGuestDirEntry *pNext = RTListNodeGetNext(&pNode->Node, VBoxGuestDirEntry, Node);2128 bool fLast = RTListNodeIsLast(&listEntries, &pNode->Node);2129 2130 if (pNode->pszPath)2131 RTStrFree(pNode->pszPath);2132 RTListNodeRemove(&pNode->Node);2133 RTMemFree(pNode);2134 2135 if (fLast)2136 break;2137 2138 pNode = pNext;2139 }2140 }2141 #endif2142 1957 } 2143 1958 }
Note:
See TracChangeset
for help on using the changeset viewer.