本文整理汇总了C++中Utf8Str::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ Utf8Str::contains方法的具体用法?C++ Utf8Str::contains怎么用?C++ Utf8Str::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utf8Str
的用法示例。
在下文中一共展示了Utf8Str::contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: taskCopyFileFromGuest
HRESULT Guest::taskCopyFileFromGuest(GuestTask *aTask)
{
LogFlowFuncEnter();
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
/*
* Do *not* take a write lock here since we don't (and won't)
* touch any class-specific data (of IGuest) here - only the member functions
* which get called here can do that.
*/
HRESULT rc = S_OK;
try
{
ComObjPtr<Guest> pGuest = aTask->pGuest;
/* Does our source file exist? */
BOOL fFileExists;
rc = pGuest->FileExists(Bstr(aTask->strSource).raw(),
Bstr(aTask->strUserName).raw(), Bstr(aTask->strPassword).raw(),
&fFileExists);
if (SUCCEEDED(rc))
{
if (!fFileExists)
rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
Guest::tr("Source file \"%s\" does not exist, or is not a file"),
aTask->strSource.c_str());
}
else
rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
/* Query file size to make an estimate for our progress object. */
if (SUCCEEDED(rc))
{
LONG64 lFileSize;
rc = pGuest->FileQuerySize(Bstr(aTask->strSource).raw(),
Bstr(aTask->strUserName).raw(), Bstr(aTask->strPassword).raw(),
&lFileSize);
if (FAILED(rc))
rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
com::SafeArray<IN_BSTR> args;
com::SafeArray<IN_BSTR> env;
if (SUCCEEDED(rc))
{
/*
* Prepare tool command line.
*/
char szSource[RTPATH_MAX];
if (RTStrPrintf(szSource, sizeof(szSource), "%s", aTask->strSource.c_str()) <= sizeof(szSource) - 1)
{
/*
* Normalize path slashes, based on the detected guest.
*/
Utf8Str osType = mData.mOSTypeId;
if ( osType.contains("Microsoft", Utf8Str::CaseInsensitive)
|| osType.contains("Windows", Utf8Str::CaseInsensitive))
{
/* We have a Windows guest. */
RTPathChangeToDosSlashes(szSource, true /* Force conversion. */);
}
else /* ... or something which isn't from Redmond ... */
{
RTPathChangeToUnixSlashes(szSource, true /* Force conversion. */);
}
args.push_back(Bstr(szSource).raw()); /* Tell our cat tool which file to output. */
}
else
rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
Guest::tr("Error preparing command line"));
}
ComPtr<IProgress> execProgress;
ULONG uPID;
if (SUCCEEDED(rc))
{
LogRel(("Copying file \"%s\" to host \"%s\" (%u bytes) ...\n",
aTask->strSource.c_str(), aTask->strDest.c_str(), lFileSize));
/*
* Okay, since we gathered all stuff we need until now to start the
* actual copying, start the guest part now.
*/
rc = pGuest->executeAndWaitForTool(Bstr(VBOXSERVICE_TOOL_CAT).raw(),
Bstr("Copying file to host").raw(),
ComSafeArrayAsInParam(args),
ComSafeArrayAsInParam(env),
Bstr(aTask->strUserName).raw(),
Bstr(aTask->strPassword).raw(),
ExecuteProcessFlag_WaitForProcessStartOnly
| ExecuteProcessFlag_WaitForStdOut,
NULL, NULL,
execProgress.asOutParam(), &uPID);
if (FAILED(rc))
rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
//.........这里部分代码省略.........
示例2: taskCopyFileToGuest
HRESULT Guest::taskCopyFileToGuest(GuestTask *aTask)
{
LogFlowFuncEnter();
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
/*
* Do *not* take a write lock here since we don't (and won't)
* touch any class-specific data (of IGuest) here - only the member functions
* which get called here can do that.
*/
HRESULT rc = S_OK;
try
{
ComObjPtr<Guest> pGuest = aTask->pGuest;
/* Does our source file exist? */
if (!RTFileExists(aTask->strSource.c_str()))
{
rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
Guest::tr("Source file \"%s\" does not exist, or is not a file"),
aTask->strSource.c_str());
}
else
{
RTFILE fileSource;
int vrc = RTFileOpen(&fileSource, aTask->strSource.c_str(),
RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
if (RT_FAILURE(vrc))
{
rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
Guest::tr("Could not open source file \"%s\" for reading (%Rrc)"),
aTask->strSource.c_str(), vrc);
}
else
{
uint64_t cbSize;
vrc = RTFileGetSize(fileSource, &cbSize);
if (RT_FAILURE(vrc))
{
rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
Guest::tr("Could not query file size of \"%s\" (%Rrc)"),
aTask->strSource.c_str(), vrc);
}
else
{
com::SafeArray<IN_BSTR> args;
com::SafeArray<IN_BSTR> env;
/*
* Prepare tool command line.
*/
char szOutput[RTPATH_MAX];
if (RTStrPrintf(szOutput, sizeof(szOutput), "--output=%s", aTask->strDest.c_str()) <= sizeof(szOutput) - 1)
{
/*
* Normalize path slashes, based on the detected guest.
*/
Utf8Str osType = mData.mOSTypeId;
if ( osType.contains("Microsoft", Utf8Str::CaseInsensitive)
|| osType.contains("Windows", Utf8Str::CaseInsensitive))
{
/* We have a Windows guest. */
RTPathChangeToDosSlashes(szOutput, true /* Force conversion. */);
}
else /* ... or something which isn't from Redmond ... */
{
RTPathChangeToUnixSlashes(szOutput, true /* Force conversion. */);
}
args.push_back(Bstr(szOutput).raw()); /* We want to write a file ... */
}
else
{
rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
Guest::tr("Error preparing command line"));
}
ComPtr<IProgress> execProgress;
ULONG uPID;
if (SUCCEEDED(rc))
{
LogRel(("Copying file \"%s\" to guest \"%s\" (%u bytes) ...\n",
aTask->strSource.c_str(), aTask->strDest.c_str(), cbSize));
/*
* Okay, since we gathered all stuff we need until now to start the
* actual copying, start the guest part now.
*/
rc = pGuest->executeAndWaitForTool(Bstr(VBOXSERVICE_TOOL_CAT).raw(),
Bstr("Copying file to guest").raw(),
ComSafeArrayAsInParam(args),
ComSafeArrayAsInParam(env),
Bstr(aTask->strUserName).raw(),
Bstr(aTask->strPassword).raw(),
ExecuteProcessFlag_WaitForProcessStartOnly,
NULL, NULL,
execProgress.asOutParam(), &uPID);
//.........这里部分代码省略.........