本文整理汇总了C++中CMyComPtr::UpdateItems方法的典型用法代码示例。如果您正苦于以下问题:C++ CMyComPtr::UpdateItems方法的具体用法?C++ CMyComPtr::UpdateItems怎么用?C++ CMyComPtr::UpdateItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMyComPtr
的用法示例。
在下文中一共展示了CMyComPtr::UpdateItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compressOut
void compressOut( const CMyComPtr< IOutArchive >& out_arc, CMyComPtr< T > out_stream,
const vector< FSItem >& in_items, const BitArchiveCreator& creator ) {
auto* update_callback_spec = new UpdateCallback( creator, in_items );
CMyComPtr< IArchiveUpdateCallback2 > update_callback( update_callback_spec );
HRESULT result = out_arc->UpdateItems( out_stream, static_cast< uint32_t >( in_items.size() ), update_callback );
update_callback_spec->Finilize();
if ( result == E_NOTIMPL ) {
throw BitException( "Unsupported operation!" );
}
if ( result == E_FAIL && update_callback_spec->getErrorMessage().empty() ) {
throw BitException( "Failed operation (unkwown error)!" );
}
if ( result != S_OK ) {
throw BitException( update_callback_spec->getErrorMessage() );
}
if ( !update_callback_spec->mFailedFiles.empty() ) {
wstringstream wsstream;
wsstream << L"Error for files: " << endl;
for ( const auto& failed_file : update_callback_spec->mFailedFiles ) {
wsstream << failed_file.first << L" (error code: " << failed_file.second << L")" << endl;
}
throw BitException( wsstream.str() );
}
}
示例2: CommonUpdate
HRESULT CAgent::CommonUpdate(
const wchar_t *newArchiveName,
int numUpdateItems,
IArchiveUpdateCallback *updateCallback)
{
if (!CanUpdate())
return E_NOTIMPL;
CMyComPtr<IOutArchive> outArchive;
RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive));
COutFileStream *outStreamSpec = new COutFileStream;
CMyComPtr<IOutStream> outStream(outStreamSpec);
UString archiveName = newArchiveName;
{
UString resultPath;
int pos;
if(!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
throw 141716;
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
}
/*
bool isOK = false;
for (int i = 0; i < (1 << 16); i++)
{
resultName = newArchiveName;
if (i > 0)
{
wchar_t s[32];
ConvertUInt64ToString(i, s);
resultName += s;
}
if (outStreamSpec->Open(realPath))
{
isOK = true;
break;
}
if (::GetLastError() != ERROR_FILE_EXISTS)
return ::GetLastError();
}
if (!isOK)
return ::GetLastError();
*/
if (!outStreamSpec->Create(archiveName, true))
{
// ShowLastErrorMessage();
return E_FAIL;
}
RINOK(outArchive->UpdateItems(outStream, numUpdateItems, updateCallback));
return outStreamSpec->Close();
}
示例3: DoOperation
//.........这里部分代码省略.........
}
CObjectVector<CArcItem> arcItems;
if (GetArchive())
{
RINOK(ReadItems());
EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", arcItems);
}
CRecordVector<CUpdatePair2> updatePairs2;
{
CRecordVector<CUpdatePair> updatePairs;
GetUpdatePairInfoList(dirItems, arcItems, fileTimeType, updatePairs);
CAgUpCallbackImp upCallback(&arcItems, updateCallback100);
UpdateProduce(updatePairs, actionSet, updatePairs2, &upCallback);
}
UInt32 numFiles = 0;
for (i = 0; i < updatePairs2.Size(); i++)
if (updatePairs2[i].NewData)
numFiles++;
if (updateCallback100)
{
RINOK(updateCallback100->SetNumFiles(numFiles));
}
CUpdateCallbackAgent updateCallbackAgent;
updateCallbackAgent.SetCallback(updateCallback100);
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec );
updateCallbackSpec->DirItems = &dirItems;
updateCallbackSpec->ArcItems = &arcItems;
updateCallbackSpec->UpdatePairs = &updatePairs2;
updateCallbackSpec->Archive = GetArchive();
updateCallbackSpec->Callback = &updateCallbackAgent;
COutFileStream *outStreamSpec = new COutFileStream;
CMyComPtr<IOutStream> outStream(outStreamSpec);
UString archiveName = newArchiveName;
{
UString resultPath;
int pos;
if(!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
return E_FAIL;
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
}
if (!outStreamSpec->Create(archiveName, true))
{
// ShowLastErrorMessage();
return E_FAIL;
}
CMyComPtr<ISetProperties> setProperties;
if (outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties) == S_OK)
{
if (m_PropNames.Size() == 0)
{
RINOK(setProperties->SetProperties(0, 0, 0));
}
else
{
CRecordVector<const wchar_t *> names;
for(i = 0; i < m_PropNames.Size(); i++)
names.Add((const wchar_t *)m_PropNames[i]);
NWindows::NCOM::CPropVariant *propValues = new NWindows::NCOM::CPropVariant[m_PropValues.Size()];
try
{
for (int i = 0; i < m_PropValues.Size(); i++)
propValues[i] = m_PropValues[i];
RINOK(setProperties->SetProperties(&names.Front(), propValues, names.Size()));
}
catch(...)
{
delete []propValues;
return E_FAIL;
}
delete []propValues;
}
}
m_PropNames.Clear();
m_PropValues.Clear();
if (sfxModule != NULL)
{
CInFileStream *sfxStreamSpec = new CInFileStream;
CMyComPtr<IInStream> sfxStream(sfxStreamSpec);
if (!sfxStreamSpec->Open(sfxModule))
return E_FAIL;
// throw "Can't open sfx module";
RINOK(CopyBlock(sfxStream, outStream));
}
RINOK(outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback));
return outStreamSpec->Close();
}