Changeset 38437 in vbox
- Timestamp:
- Aug 12, 2011 3:05:41 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/string.h
r36527 r38437 505 505 } 506 506 507 bool operator<(const RTCString &that) const { return RTCString::operator<(that); } 508 507 509 RTMEMEF_NEW_AND_DELETE_OPERATORS(); 508 510 … … 563 565 */ 564 566 static const Utf8Str Empty; 565 566 567 protected: 567 568 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExecThread.cpp
r38180 r38437 373 373 { 374 374 #ifdef DEBUG_andy 375 VBoxServiceVerbose(4, "ControlExec: [PID %u]: Waiting for pipe buffer %u \n",376 uPID, pPipeBuf->uPipeId );375 VBoxServiceVerbose(4, "ControlExec: [PID %u]: Waiting for pipe buffer %u (%ums)\n", 376 uPID, pPipeBuf->uPipeId, uTimeout); 377 377 #endif 378 378 rc = VBoxServicePipeBufWaitForEvent(pPipeBuf, uTimeout); … … 385 385 { 386 386 if (fEnabled && !cbRead) 387 AssertMsgFailed((" Waited for pipe buffer %u, but nothing read!\n",388 pPipeBuf->uPipeId));387 AssertMsgFailed(("[PID %u]: Waited (%ums) for pipe buffer %u (%u bytes left) , but nothing read!\n", 388 uPID, uTimeout, pPipeBuf->uPipeId, pPipeBuf->cbSize - pPipeBuf->cbOffset)); 389 389 if (pcbRead) 390 390 *pcbRead = cbRead; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServicePipeBuf.cpp
r38113 r38437 111 111 pBuf->cbOffset += cbToRead; 112 112 113 #ifdef DEBUG_andy 114 VBoxServiceVerbose(4, "Pipe [%u %u 0x%p %s] read pcbToRead=%u, cbSize=%u, cbAlloc=%u, cbOff=%u\n", 115 pBuf->uPID, pBuf->uPipeId, pBuf, pBuf->fEnabled ? "EN" : "DIS", cbToRead, pBuf->cbSize, pBuf->cbAllocated, pBuf->cbOffset); 116 #endif 113 117 if (pBuf->hEventSem != NIL_RTSEMEVENT) 114 118 { … … 117 121 } 118 122 119 #ifdef DEBUG_andy120 VBoxServiceVerbose(4, "Pipe [%u %u 0x%p %s] read pcbToRead=%u, cbSize=%u, cbAlloc=%u, cbOff=%u\n",121 pBuf->uPID, pBuf->uPipeId, pBuf, pBuf->fEnabled ? "EN" : "DIS", cbToRead, pBuf->cbSize, pBuf->cbAllocated, pBuf->cbOffset);122 #endif123 123 *pcbToRead = cbToRead; 124 124 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r38403 r38437 940 940 { 941 941 BOOL fDirExists = FALSE; 942 #if 0 943 HRESULT hr = pContext->pGuest-> DirectoryExists(Bstr(pszDir).raw(),944 945 942 /** @todo Replace with DirectoryExists as soon as API is in place. */ 943 HRESULT hr = pContext->pGuest->FileExists(Bstr(pszDir).raw(), 944 Bstr(pContext->pszUsername).raw(), 945 Bstr(pContext->pszPassword).raw(), &fDirExists); 946 946 if (FAILED(hr)) 947 947 rc = ctrlPrintError(pContext->pGuest, COM_IIDOF(IGuest)); 948 948 else 949 #endif950 949 *fExists = fDirExists ? true : false; 951 950 } … … 1557 1556 const char *pszSource = vecSources[s].mSource.c_str(); 1558 1557 const char *pszFilter = vecSources[s].mFilter.c_str(); 1558 if (!strlen(pszFilter)) 1559 pszFilter = NULL; /* If empty filter then there's no filter :-) */ 1559 1560 1560 1561 char *pszSourceRoot; … … 1570 1571 1571 1572 /** @todo Files with filter?? */ 1573 bool fIsFile = false; 1572 1574 bool fExists; 1573 vrc = ctrlCopyFileExistsOnSource(pContext, pszSource, &fExists); 1575 Utf8Str Utf8CurSource(pszSource); 1576 if ( Utf8CurSource.endsWith("/") 1577 || Utf8CurSource.endsWith("\\")) 1578 { 1579 if (pszFilter) /* Directory with filter. */ 1580 vrc = ctrlCopyDirExistsOnSource(pContext, pszSourceRoot, &fExists); 1581 else /* Regular directory without filter. */ 1582 vrc = ctrlCopyDirExistsOnSource(pContext, pszSource, &fExists); 1583 } 1584 else 1585 { 1586 vrc = ctrlCopyFileExistsOnSource(pContext, pszSource, &fExists); 1587 if ( RT_SUCCESS(vrc) 1588 && fExists) 1589 fIsFile = true; 1590 } 1591 1574 1592 if (RT_SUCCESS(vrc)) 1575 1593 { 1576 if (f Exists)1594 if (fIsFile) 1577 1595 { 1578 1596 /* Single file. */ … … 1594 1612 else 1595 1613 { 1596 if (!pContext->fHostToGuest) 1597 { 1598 RTMsgError("Copying of guest directories to the host is not supported yet!\n"); 1599 vrc = VERR_NOT_IMPLEMENTED; 1600 } 1601 else 1602 { 1603 if ( (RT_SUCCESS(ctrlCopyDirExistsOnSource(pContext, pszSource, &fExists)) 1604 && fExists) 1605 || ( RT_SUCCESS(ctrlCopyDirExistsOnSource(pContext, pszSourceRoot, &fExists)) 1606 && fExists 1607 && pszFilter) 1608 ) 1609 { 1610 /* Directory (with filter?). */ 1611 vrc = ctrlCopyDirToTarget(pContext, pszSource, pszFilter, 1612 Utf8Dest.c_str(), fFlags, NULL /* Subdir */); 1613 } 1614 } 1614 /* Directory (with filter?). */ 1615 vrc = ctrlCopyDirToTarget(pContext, pszSource, pszFilter, 1616 Utf8Dest.c_str(), fFlags, NULL /* Subdir */); 1615 1617 } 1616 1618 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r38400 r38437 9061 9061 Reads the next directory entry of an opened guest directory. 9062 9062 9063 <result name="E_ABORT"> 9064 When the end of the directory has been reached. 9065 </result> 9066 9063 9067 <result name="VBOX_E_IPRT_ERROR"> 9064 9068 Error while opening / reading directory. … … 9081 9085 <desc> 9082 9086 Checks if the specified file name exists and is a regular file. 9087 9088 If the file name ends with a slash or backslash, the function assumes 9089 it's a directory and will check if the specified directory exists and 9090 is a regular directory. 9083 9091 9084 9092 <result name="VBOX_E_IPRT_ERROR"> -
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r38395 r38437 37 37 38 38 /** Structure representing the "value" side of a "key=value" pair. */ 39 typedef struct VBOXGUESTCTRL_STREAMPAIR 39 class VBOXGUESTCTRL_STREAMVALUE 40 40 { 41 VBOXGUESTCTRL_STREAMPAIR(const char *pszValue) 41 public: 42 43 VBOXGUESTCTRL_STREAMVALUE() { } 44 VBOXGUESTCTRL_STREAMVALUE(const char *pszValue) 42 45 : mValue(pszValue) {} 43 46 47 VBOXGUESTCTRL_STREAMVALUE(const VBOXGUESTCTRL_STREAMVALUE& aThat) 48 : mValue(aThat.mValue) {} 49 44 50 Utf8Str mValue; 45 } VBOXGUESTCTRL_STREAMPAIR, *PVBOXGUESTCTRL_STREAM_PAIR;51 }; 46 52 47 53 /** Map containing "key=value" pairs of a guest process stream. */ 48 typedef std::map< Utf8Str, VBOXGUESTCTRL_STREAMPAIR > GuestCtrlStreamPairs; 49 typedef std::map< Utf8Str, VBOXGUESTCTRL_STREAMPAIR >::iterator GuestCtrlStreamPairsIter; 50 typedef std::map< Utf8Str, VBOXGUESTCTRL_STREAMPAIR >::const_iterator GuestCtrlStreamPairsIterConst; 54 typedef std::pair< Utf8Str, VBOXGUESTCTRL_STREAMVALUE > GuestCtrlStreamPair; 55 typedef std::map < Utf8Str, VBOXGUESTCTRL_STREAMVALUE > GuestCtrlStreamPairMap; 56 typedef std::map < Utf8Str, VBOXGUESTCTRL_STREAMVALUE >::iterator GuestCtrlStreamPairMapIter; 57 typedef std::map < Utf8Str, VBOXGUESTCTRL_STREAMVALUE >::const_iterator GuestCtrlStreamPairMapIterConst; 51 58 52 59 /** … … 85 92 protected: 86 93 87 GuestCtrlStreamPair sm_mapPairs;94 GuestCtrlStreamPairMap m_mapPairs; 88 95 }; 89 96 90 97 /** Vector containing multiple allocated stream pair objects. */ 91 typedef std::vector< GuestProcessStreamBlock *> GuestCtrlStreamObjects;92 typedef std::vector< GuestProcessStreamBlock *>::iterator GuestCtrlStreamObjectsIter;93 typedef std::vector< GuestProcessStreamBlock *>::const_iterator GuestCtrlStreamObjectsIterConst;98 typedef std::vector< GuestProcessStreamBlock > GuestCtrlStreamObjects; 99 typedef std::vector< GuestProcessStreamBlock >::iterator GuestCtrlStreamObjectsIter; 100 typedef std::vector< GuestProcessStreamBlock >::const_iterator GuestCtrlStreamObjectsIterConst; 94 101 95 102 /** … … 132 139 }; 133 140 134 structGuestTask141 class GuestTask 135 142 { 143 144 public: 145 136 146 enum TaskType 137 147 { -
trunk/src/VBox/Main/include/GuestImpl.h
r38400 r38437 159 159 ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress, int *pRC); 160 160 HRESULT executeProcessResult(const char *pszCommand, const char *pszUser, ULONG ulTimeout, PCALLBACKDATAEXECSTATUS pExecStatus, ULONG *puPID); 161 HRESULT executeStreamQueryFsObjInfo(IN_BSTR aObjName,GuestProcessStreamBlock *pStreamBlock, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttribs);161 HRESULT executeStreamQueryFsObjInfo(IN_BSTR aObjName,GuestProcessStreamBlock &streamBlock, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttribs); 162 162 int executeStreamDrain(ULONG aPID, GuestProcessStream &stream); 163 163 void executeStreamFree(GuestCtrlStreamObjects &streamObjects); -
trunk/src/VBox/Main/src-client/GuestCtrlIO.cpp
r38395 r38437 121 121 try 122 122 { 123 GuestCtrlStreamPair sIterConst itPairs = m_mapPairs.find(Utf8Str(pszKey));123 GuestCtrlStreamPairMapIterConst itPairs = m_mapPairs.find(Utf8Str(pszKey)); 124 124 if (itPairs != m_mapPairs.end()) 125 125 return itPairs->second.mValue.c_str(); … … 186 186 if (!m_mapPairs.empty()) 187 187 { 188 GuestCtrlStreamPair sIter it = m_mapPairs.find(Utf8Key);188 GuestCtrlStreamPairMapIter it = m_mapPairs.find(Utf8Key); 189 189 if (it != m_mapPairs.end()) 190 190 m_mapPairs.erase(it); … … 193 193 if (pszValue) 194 194 { 195 m_mapPairs.insert(196 std::pair<Utf8Str, VBOXGUESTCTRL_STREAMPAIR>(Utf8Key, VBOXGUESTCTRL_STREAMPAIR(pszValue)));195 VBOXGUESTCTRL_STREAMVALUE val(pszValue); 196 m_mapPairs[Utf8Key] = val; 197 197 } 198 198 } -
trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp
r38399 r38437 1247 1247 */ 1248 1248 HRESULT Guest::executeStreamQueryFsObjInfo(IN_BSTR aObjName, 1249 GuestProcessStreamBlock *pStreamBlock,1249 GuestProcessStreamBlock &streamBlock, 1250 1250 PRTFSOBJINFO pObjInfo, 1251 1251 RTFSOBJATTRADD enmAddAttribs) 1252 1252 { 1253 AssertPtrReturn(pStreamBlock, E_INVALIDARG);1254 1255 1253 HRESULT rc = S_OK; 1256 1254 Utf8Str Utf8ObjName(aObjName); 1257 1255 1258 1256 int64_t iVal; 1259 int vrc = pStreamBlock->GetInt64Ex("st_size", &iVal);1257 int vrc = streamBlock.GetInt64Ex("st_size", &iVal); 1260 1258 if (RT_SUCCESS(vrc)) 1261 1259 pObjInfo->cbObject = iVal; … … 1310 1308 void Guest::executeStreamFree(GuestCtrlStreamObjects &streamObjects) 1311 1309 { 1312 for (GuestCtrlStreamObjectsIter it = streamObjects.begin();1310 /*for (GuestCtrlStreamObjectsIter it = streamObjects.begin(); 1313 1311 it != streamObjects.end(); it++) 1314 1312 { 1315 1313 executeStreamFreeBlock(*it); 1316 } 1314 }*/ 1317 1315 streamObjects.clear(); 1318 1316 } … … 1345 1343 int rc = executeStreamDrain(aPID, stream); 1346 1344 if (RT_SUCCESS(rc)) 1347 rc = stream.ParseBlock(streamBlock); 1345 { 1346 do 1347 { 1348 rc = stream.ParseBlock(streamBlock); 1349 if (streamBlock.GetCount()) 1350 break; /* We got a block, bail out! */ 1351 } while (RT_SUCCESS(rc)); 1352 1353 /* In case this was the last block, VERR_NO_DATA is returned. 1354 * Overwrite this to get a proper return value for the last block. */ 1355 if( streamBlock.GetCount() 1356 && rc == VERR_NO_DATA) 1357 { 1358 rc = VINF_SUCCESS; 1359 } 1360 } 1348 1361 1349 1362 return rc; … … 1370 1383 /* Try to parse the stream output we gathered until now. If we still need more 1371 1384 * data the parsing routine will tell us and we just do another poll round. */ 1372 GuestProcessStreamBlock *pCurBlock = (GuestProcessStreamBlock*) 1373 RTMemAlloc(sizeof(GuestProcessStreamBlock)); 1374 if (!pCurBlock) 1375 { 1376 hr = setError(VBOX_E_IPRT_ERROR, 1377 tr("No memory for allocating stream block")); 1378 break; 1379 } 1380 int vrc = guestStream.ParseBlock(*pCurBlock); 1385 GuestProcessStreamBlock curBlock; 1386 int vrc = guestStream.ParseBlock(curBlock); 1381 1387 if (RT_SUCCESS(vrc)) 1382 1388 { 1383 if ( pCurBlock->GetCount())1389 if (curBlock.GetCount()) 1384 1390 { 1385 streamObjects.push_back( pCurBlock);1391 streamObjects.push_back(curBlock); 1386 1392 } 1387 1393 else 1388 {1389 GuestProcessStream::FreeBlock(pCurBlock);1390 1394 break; /* No more data. */ 1391 }1392 1395 } 1393 1396 else /* Everything else would be an error! */ -
trunk/src/VBox/Main/src-client/GuestCtrlImplDir.cpp
r38400 r38437 233 233 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 234 234 235 RTFSOBJINFO objInfo;236 235 int rc; 237 236 HRESULT hr = directoryQueryInfoInternal(aDirectory, 238 237 aUsername, aPassword, 239 &objInfo, RTFSOBJATTRADD_NOTHING, &rc); 238 NULL /* No RTFSOBJINFO needed */, 239 RTFSOBJATTRADD_NOTHING, &rc); 240 240 if (SUCCEEDED(hr)) 241 241 { … … 283 283 /** 284 284 * Returns the next directory entry of an open guest directory. 285 * Returns VERR_NO_MORE_FILES if no more entries available. 285 * Returns VERR_NO_DATA if no more entries available or VERR_NOT_FOUND 286 * if directory handle is invalid. 286 287 * 287 288 * @return IPRT status code. … … 486 487 int rc = VINF_SUCCESS; 487 488 488 GuestProcessStreamBlock *pBlock = streamObjs[0]; 489 AssertPtr(pBlock); 490 const char *pszFsType = pBlock->GetString("ftype"); 489 Assert(streamObjs.size()); 490 const char *pszFsType = streamObjs[0].GetString("ftype"); 491 491 if (!pszFsType) /* Attribute missing? */ 492 492 rc = VERR_NOT_FOUND; … … 495 495 { 496 496 rc = VERR_FILE_NOT_FOUND; 497 /* This is not critical for Main, so don't set hr -- 498 * we will take care of rc then. */ 497 499 } 498 500 if ( RT_SUCCESS(rc) 499 501 && aObjInfo) /* Do we want object details? */ 500 502 { 501 hr = executeStreamQueryFsObjInfo(aDirectory, pBlock,503 hr = executeStreamQueryFsObjInfo(aDirectory, streamObjs[0], 502 504 aObjInfo, enmAddAttribs); 503 505 } … … 541 543 ComAssertComRC(hr); 542 544 545 Assert(streamBlock.GetCount()); 543 546 hr = pDirEntry->init(this, streamBlock); 544 547 if (SUCCEEDED(hr)) … … 548 551 else 549 552 hr = setError(VBOX_E_IPRT_ERROR, 550 Guest::tr(" Unableto init guest directory entry"));551 } 552 else if (rc == VERR_NO_ MORE_FILES)553 { 554 /* No more directory entries to read. */553 Guest::tr("Failed to init guest directory entry")); 554 } 555 else if (rc == VERR_NO_DATA) 556 { 557 /* No more directory entries to read. That's fine. */ 555 558 hr = E_ABORT; /** @todo Find/define a better rc! */ 556 559 } -
trunk/src/VBox/Main/src-client/GuestCtrlImplFile.cpp
r38395 r38437 46 46 return setError(E_INVALIDARG, tr("No user name specified")); 47 47 48 /* If filename ends with a slash or backslash we assume it's a directory and 49 * call the appropriate function instead the regular one just for files. */ 50 Utf8Str Utf8File(aFile); 51 if ( Utf8File.endsWith("/") 52 || Utf8File.endsWith("\\")) 53 { 54 return directoryExistsInternal(aFile, aUsername, aPassword, aExists); 55 } 48 56 return fileExistsInternal(aFile, 49 57 aUsername, aPassword, aExists); … … 61 69 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 62 70 63 RTFSOBJINFO objInfo;64 71 int rc; 65 72 HRESULT hr = fileQueryInfoInternal(aFile, 66 73 aUsername, aPassword, 67 &objInfo, RTFSOBJATTRADD_NOTHING, &rc); 74 NULL /* No RTFSOBJINFO needed */, 75 RTFSOBJATTRADD_NOTHING, &rc); 68 76 if (SUCCEEDED(hr)) 69 77 { … … 139 147 { 140 148 int rc = VINF_SUCCESS; 141 142 GuestProcessStreamBlock *pBlock = streamObjs[0]; 143 AssertPtr(pBlock); 144 const char *pszFsType = pBlock->GetString("ftype"); 149 const char *pszFsType = streamObjs[0].GetString("ftype"); 145 150 if (!pszFsType) /* Attribute missing? */ 146 151 rc = VERR_NOT_FOUND; … … 149 154 { 150 155 rc = VERR_FILE_NOT_FOUND; 156 /* This is not critical for Main, so don't set hr -- 157 * we will take care of rc then. */ 151 158 } 152 159 if ( RT_SUCCESS(rc) 153 160 && aObjInfo) /* Do we want object details? */ 154 161 { 155 hr = executeStreamQueryFsObjInfo(aFile, pBlock,162 hr = executeStreamQueryFsObjInfo(aFile, streamObjs[0], 156 163 aObjInfo, enmAddAttribs); 157 164 } -
trunk/src/VBox/Main/testcase/tstGuestCtrlParseBuffer.cpp
r38395 r38437 90 90 /* Good stuff, but with a second block -- should be *not* taken into account since 91 91 * we're only interested in parsing/handling the first object. */ 92 { "t9=t9\0t91=t91\0\0t92=t92\0\0", sizeof("t9=t9\0t91=t91\0\0t92=t92\0\0"), 0, sizeof("t9=t9\0t91=t91\0") - 1, 2, VINF_SUCCESS } 92 { "t9=t9\0t91=t91\0\0t92=t92\0\0", sizeof("t9=t9\0t91=t91\0\0t92=t92\0\0"), 0, sizeof("t9=t9\0t91=t91\0") - 1, 2, VINF_SUCCESS }, 93 /* Some "real world" examples. */ 94 { "hdr_id=vbt_stat\0hdr_ver=1\0name=foo.txt\0\0", 95 sizeof("hdr_id=vbt_stat\0hdr_ver=1\0name=foo.txt\0\0"), 96 0, sizeof("hdr_id=vbt_stat\0hdr_ver=1\0name=foo.txt\0\0") - 1, 97 3, VINF_SUCCESS } 93 98 }; 94 99
Note:
See TracChangeset
for help on using the changeset viewer.