本文整理汇总了C++中CMyComPtr::Seek方法的典型用法代码示例。如果您正苦于以下问题:C++ CMyComPtr::Seek方法的具体用法?C++ CMyComPtr::Seek怎么用?C++ CMyComPtr::Seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMyComPtr
的用法示例。
在下文中一共展示了CMyComPtr::Seek方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadStream
static bool ReadStream(CMyComPtr<IInStream> & inStream, Int64 offset, UINT32 seekOrigin, CByteBuffer & signature)
{
UInt64 savedPosition = 0;
UInt64 newPosition = 0;
#if MY_VER_MAJOR >= 15
UInt32 readCount = signature.Size();
#else
UInt32 readCount = signature.GetCapacity();
#endif
unsigned char * buf = signature;
if (S_OK != inStream->Seek(0, FILE_CURRENT, &savedPosition))
return false;
if (S_OK != inStream->Seek(offset, seekOrigin, &newPosition)) {
inStream->Seek(savedPosition, FILE_BEGIN, &newPosition); //restore pos
return false;
}
while (readCount > 0) {
UInt32 processedCount = 0;
if (S_OK != inStream->Read(buf, readCount, &processedCount)) {
inStream->Seek(savedPosition, FILE_BEGIN, &newPosition); //restore pos
return false;
}
if (processedCount == 0)
break;
readCount -= processedCount;
buf += processedCount;
}
inStream->Seek(savedPosition, FILE_BEGIN, &newPosition); //restore pos
return readCount == 0;
}
示例2: FindFirstFile
bool vms7zipArchive::Find7zipDLL(vms7zipFormatDLL &dll, LPCSTR pszArchive, bool bByExt, CMyComPtr <IInStream> &spFile, CMyComPtr <IInArchive> &spArc)
{
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile ("Archive\\7-zip\\Formats\\*.dll", &wfd);
if (hFind == INVALID_HANDLE_VALUE)
return false;
bool bFound = false;
do
{
CString str = "Archive\\7-zip\\Formats\\"; str += wfd.cFileName;
if (false == dll.Load (str))
continue;
if (bByExt && false == dll.IsSupportedArchive (pszArchive))
continue;
GUID guid;
if (FAILED (dll.get_GUID (&guid)))
continue;
dll.CreateObject (&guid, &IID_IInArchive, (void**) &spArc);
if (spArc == NULL)
continue;
spFile->Seek (0, STREAM_SEEK_SET, NULL);
if (spArc->Open (spFile, 0, 0) == S_OK)
bFound = true;
else
spArc = NULL;
}
while (bFound == false && FindNextFile (hFind, &wfd));
FindClose (hFind);
return bFound;
}
示例3: UpdateArchive
HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
const CObjectVector<NArchive::NTar::CItemEx> &inputItems,
const CObjectVector<CUpdateItem> &updateItems,
UINT codePage,
IArchiveUpdateCallback *updateCallback)
{
COutArchive outArchive;
outArchive.Create(outStream);
outArchive.Pos = 0;
CMyComPtr<IOutStream> outSeekStream;
outStream->QueryInterface(IID_IOutStream, (void **)&outSeekStream);
UInt64 complexity = 0;
unsigned i;
for (i = 0; i < updateItems.Size(); i++)
{
const CUpdateItem &ui = updateItems[i];
if (ui.NewData)
complexity += ui.Size;
else
complexity += inputItems[ui.IndexInArchive].GetFullSize();
}
RINOK(updateCallback->SetTotal(complexity));
NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
CLocalProgress *lps = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> progress = lps;
lps->Init(updateCallback, true);
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
streamSpec->SetStream(inStream);
complexity = 0;
for (i = 0; i < updateItems.Size(); i++)
{
lps->InSize = lps->OutSize = complexity;
RINOK(lps->SetCur());
const CUpdateItem &ui = updateItems[i];
CItem item;
if (ui.NewProps)
{
item.Mode = ui.Mode;
item.Name = ui.Name;
item.User = ui.User;
item.Group = ui.Group;
if (ui.IsDir)
{
item.LinkFlag = NFileHeader::NLinkFlag::kDirectory;
item.PackSize = 0;
}
else
{
item.LinkFlag = NFileHeader::NLinkFlag::kNormal;
item.PackSize = ui.Size;
}
item.MTime = ui.MTime;
item.DeviceMajorDefined = false;
item.DeviceMinorDefined = false;
item.UID = 0;
item.GID = 0;
memcpy(item.Magic, NFileHeader::NMagic::kUsTar_00, 8);
}
else
item = inputItems[ui.IndexInArchive];
AString symLink;
if (ui.NewData || ui.NewProps)
{
RINOK(GetPropString(updateCallback, ui.IndexInClient, kpidSymLink, symLink, codePage, true));
if (!symLink.IsEmpty())
{
item.LinkFlag = NFileHeader::NLinkFlag::kSymLink;
item.LinkName = symLink;
}
}
if (ui.NewData)
{
item.SparseBlocks.Clear();
item.PackSize = ui.Size;
item.Size = ui.Size;
if (ui.Size == (UInt64)(Int64)-1)
return E_INVALIDARG;
CMyComPtr<ISequentialInStream> fileInStream;
bool needWrite = true;
if (!symLink.IsEmpty())
{
item.PackSize = 0;
item.Size = 0;
}
//.........这里部分代码省略.........
示例4: Seek
HRESULT Seek(UInt64 offset)
{
PosInArc = offset;
return Stream->Seek(offset, STREAM_SEEK_SET, NULL);
}