本文整理汇总了C++中CMyComPtr::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ CMyComPtr::Open方法的具体用法?C++ CMyComPtr::Open怎么用?C++ CMyComPtr::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMyComPtr
的用法示例。
在下文中一共展示了CMyComPtr::Open方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BitException
// NOTE: this function is not a method of BitMemExtractor because it would dirty the header with extra dependencies
CMyComPtr< IInArchive > openArchive( const Bit7zLibrary& lib, const BitInFormat& format,
const vector< byte_t >& in_buffer, const BitArchiveOpener& opener ) {
CMyComPtr< IInArchive > inArchive;
const GUID formatGUID = format.guid();
lib.createArchiveObject( &formatGUID, &::IID_IInArchive, reinterpret_cast< void** >( &inArchive ) );
CBufInStream* bufStreamSpec = new CBufInStream;
CMyComPtr< IInStream > bufStream( bufStreamSpec );
bufStreamSpec->Init( &in_buffer[0], in_buffer.size() );
OpenCallback* openCallbackSpec = new OpenCallback( opener );
CMyComPtr< IArchiveOpenCallback > openCallback( openCallbackSpec );
if ( inArchive->Open( bufStream, 0, openCallback ) != S_OK ) {
throw BitException( L"Cannot open archive buffer" );
}
return inArchive;
}
示例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: OpenStream
HRESULT CArc::OpenStream(
CCodecs *codecs,
int formatIndex,
IInStream *stream,
ISequentialInStream *seqStream,
IArchiveOpenCallback *callback)
{
Archive.Release();
ErrorMessage.Empty();
const UString fileName = ExtractFileNameFromPath(Path);
UString extension;
{
int dotPos = fileName.ReverseFind(L'.');
if (dotPos >= 0)
extension = fileName.Mid(dotPos + 1);
}
CIntVector orderIndices;
if (formatIndex >= 0)
orderIndices.Add(formatIndex);
else
{
int i;
int numFinded = 0;
for (i = 0; i < codecs->Formats.Size(); i++)
if (codecs->Formats[i].FindExtension(extension) >= 0)
orderIndices.Insert(numFinded++, i);
else
orderIndices.Add(i);
if (!stream)
{
if (numFinded != 1)
return E_NOTIMPL;
orderIndices.DeleteFrom(1);
}
#ifndef _SFX
if (orderIndices.Size() >= 2 && (numFinded == 0 || extension.CompareNoCase(L"exe") == 0))
{
CIntVector orderIndices2;
CByteBuffer byteBuffer;
const size_t kBufferSize = (1 << 21);
byteBuffer.SetCapacity(kBufferSize);
RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
size_t processedSize = kBufferSize;
RINOK(ReadStream(stream, byteBuffer, &processedSize));
if (processedSize == 0)
return S_FALSE;
const Byte *buf = byteBuffer;
CByteBuffer hashBuffer;
const UInt32 kNumVals = 1 << (kNumHashBytes * 8);
hashBuffer.SetCapacity(kNumVals);
Byte *hash = hashBuffer;
memset(hash, 0xFF, kNumVals);
Byte prevs[256];
if (orderIndices.Size() >= 256)
return S_FALSE;
int i;
for (i = 0; i < orderIndices.Size(); i++)
{
const CArcInfoEx &ai = codecs->Formats[orderIndices[i]];
const CByteBuffer &sig = ai.StartSignature;
if (sig.GetCapacity() < kNumHashBytes)
continue;
UInt32 v = HASH_VAL(sig, 0);
prevs[i] = hash[v];
hash[v] = (Byte)i;
}
processedSize -= (kNumHashBytes - 1);
for (UInt32 pos = 0; pos < processedSize; pos++)
{
for (; pos < processedSize && hash[HASH_VAL(buf, pos)] == 0xFF; pos++);
if (pos == processedSize)
break;
UInt32 v = HASH_VAL(buf, pos);
Byte *ptr = &hash[v];
int i = *ptr;
do
{
int index = orderIndices[i];
const CArcInfoEx &ai = codecs->Formats[index];
const CByteBuffer &sig = ai.StartSignature;
if (sig.GetCapacity() != 0 && pos + sig.GetCapacity() <= processedSize + (kNumHashBytes - 1) &&
TestSignature(buf + pos, sig, sig.GetCapacity()))
{
orderIndices2.Add(index);
orderIndices[i] = 0xFF;
*ptr = prevs[i];
}
else
ptr = &prevs[i];
i = *ptr;
}
while (i != 0xFF);
}
for (i = 0; i < orderIndices.Size(); i++)
//.........这里部分代码省略.........
示例4: OpenArchive
HRESULT OpenArchive(
CCodecs *codecs,
IInStream *inStream,
const UString &fileName,
IInArchive **archiveResult,
int &formatIndex,
UString &defaultItemName,
IArchiveOpenCallback *openArchiveCallback)
{
*archiveResult = NULL;
UString extension;
{
int dotPos = fileName.ReverseFind(L'.');
if (dotPos >= 0)
extension = fileName.Mid(dotPos + 1);
}
CIntVector orderIndices;
int i;
int numFinded = 0;
for (i = 0; i < codecs->Formats.Size(); i++)
if (codecs->Formats[i].FindExtension(extension) >= 0)
orderIndices.Insert(numFinded++, i);
else
orderIndices.Add(i);
#ifndef _SFX
if (numFinded != 1)
{
CIntVector orderIndices2;
CByteBuffer byteBuffer;
const UInt32 kBufferSize = (200 << 10);
byteBuffer.SetCapacity(kBufferSize);
Byte *buffer = byteBuffer;
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
UInt32 processedSize;
RINOK(ReadStream(inStream, buffer, kBufferSize, &processedSize));
for (UInt32 pos = 0; pos < processedSize; pos++)
{
for (int i = 0; i < orderIndices.Size(); i++)
{
int index = orderIndices[i];
const CArcInfoEx &ai = codecs->Formats[index];
const CByteBuffer &sig = ai.StartSignature;
if (sig.GetCapacity() == 0)
continue;
if (pos + sig.GetCapacity() > processedSize)
continue;
if (TestSignature(buffer + pos, sig, sig.GetCapacity()))
{
orderIndices2.Add(index);
orderIndices.Delete(i--);
}
}
}
orderIndices2 += orderIndices;
orderIndices = orderIndices2;
/* begin: extracted from 4.65 */
if (orderIndices.Size() >= 2)
{
int isoIndex = codecs->FindFormatForArchiveType(L"iso");
int udfIndex = codecs->FindFormatForArchiveType(L"udf");
int iIso = -1;
int iUdf = -1;
for (int i = 0; i < orderIndices.Size(); i++)
{
if (orderIndices[i] == isoIndex) iIso = i;
if (orderIndices[i] == udfIndex) iUdf = i;
}
if (iUdf == iIso + 1)
{
orderIndices[iUdf] = isoIndex;
orderIndices[iIso] = udfIndex;
}
}
/* end: extracted from 4.65 */
}
else if (extension == L"000" || extension == L"001")
{
CByteBuffer byteBuffer;
const UInt32 kBufferSize = (1 << 10);
byteBuffer.SetCapacity(kBufferSize);
Byte *buffer = byteBuffer;
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
UInt32 processedSize;
RINOK(ReadStream(inStream, buffer, kBufferSize, &processedSize));
if (processedSize >= 16)
{
Byte kRarHeader[] = {0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00};
if (TestSignature(buffer, kRarHeader, 7) && buffer[9] == 0x73 && (buffer[10] && 1) != 0)
{
for (int i = 0; i < orderIndices.Size(); i++)
{
int index = orderIndices[i];
const CArcInfoEx &ai = codecs->Formats[index];
if (ai.Name.CompareNoCase(L"rar") != 0)
continue;
orderIndices.Delete(i--);
orderIndices.Insert(0, index);
break;
//.........这里部分代码省略.........
示例5: InternalOpenArchive
static HRESULT InternalOpenArchive(C7ZipLibrary * pLibrary,
C7ZipDllHandler * pHandler,
C7ZipInStream * pInStream,
C7ZipArchiveOpenCallback * pOpenCallBack,
C7ZipArchive ** ppArchive,
HRESULT * pResult,
bool fCheckFileTypeBySignature)
{
CMyComPtr<IInArchive> archive = NULL;
CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo = NULL;
CMyComPtr<IInArchiveGetStream> getStream = NULL;
wstring extension = pInStream->GetExt();
C7ZipInStreamWrapper * pArchiveStream = new C7ZipInStreamWrapper(pInStream);
CMyComPtr<IInStream> inStream(pArchiveStream);
CMyComPtr<IArchiveOpenCallback> openCallBack(pOpenCallBack);
std::vector<IInArchive *> archives;
do {
if (archive != NULL)
archives.push_back(archive);
FAIL_RET(CreateInArchive(pHandler->GetFunctions(),
pHandler->GetFormatInfoArray(),
inStream,
extension,
archive,
fCheckFileTypeBySignature), pResult);
if (archive == NULL)
return false;
archive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
if (setCompressCodecsInfo) {
C7ZipCompressCodecsInfo * pCompressCodecsInfo =
new C7ZipCompressCodecsInfo(pLibrary);
RBOOLOK(setCompressCodecsInfo->SetCompressCodecsInfo(pCompressCodecsInfo));
}
FAIL_RET(archive->Open(inStream, &kMaxCheckStartPosition, openCallBack), pResult);
UInt32 mainSubfile;
{
NCOM::CPropVariant prop;
FAIL_RET(archive->GetArchiveProperty(kpidMainSubfile, &prop), pResult);
if (prop.vt == VT_UI4)
mainSubfile = prop.ulVal;
else {
break;
}
UInt32 numItems;
FAIL_RET(archive->GetNumberOfItems(&numItems), pResult);
if (mainSubfile >= numItems)
break;
}
if (archive->QueryInterface(IID_IInArchiveGetStream, (void **)&getStream) != S_OK || !getStream)
break;
CMyComPtr<ISequentialInStream> subSeqStream;
if (getStream->GetStream(mainSubfile, &subSeqStream) != S_OK || !subSeqStream)
break;
inStream = NULL;
if (subSeqStream.QueryInterface(IID_IInStream, &inStream) != S_OK || !inStream)
break;
wstring path;
FAIL_RET(GetArchiveItemPath(archive, mainSubfile, path), pResult);
CMyComPtr<IArchiveOpenSetSubArchiveName> setSubArchiveName;
openCallBack->QueryInterface(IID_IArchiveOpenSetSubArchiveName, (void **)&setSubArchiveName);
if (setSubArchiveName) {
setSubArchiveName->SetSubArchiveName(path.c_str());
}
FAIL_RET(GetFilePathExt(path, extension), pResult);
} while(true);
if (archive == NULL)
return S_FALSE;
return Create7ZipArchive(pLibrary, archives, archive, ppArchive) ? S_OK : S_FALSE;
}