本文整理汇总了C++中CByteBuffer::AllocAtLeast方法的典型用法代码示例。如果您正苦于以下问题:C++ CByteBuffer::AllocAtLeast方法的具体用法?C++ CByteBuffer::AllocAtLeast怎么用?C++ CByteBuffer::AllocAtLeast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CByteBuffer
的用法示例。
在下文中一共展示了CByteBuffer::AllocAtLeast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Extract
//.........这里部分代码省略.........
if (extractStatuses.IsEmpty())
chmFolderOutStream->m_StartIndex = index + 1;
else
chmFolderOutStream->m_StartIndex = index;
if (limitFolderIndex == folderIndex)
{
for (; i < numItems; i++)
{
const UInt32 nextIndex = allFilesMode ? i : indices[i];
const CItem &nextItem = m_Database.Items[m_Database.Indices[nextIndex]];
if (nextItem.Section != sectionIndex)
break;
UInt64 nextFolderIndex = m_Database.GetFolder(nextIndex);
if (nextFolderIndex != folderIndex)
break;
for (index++; index < nextIndex; index++)
extractStatuses.Add(false);
extractStatuses.Add(true);
index = nextIndex;
lastItem = &nextItem;
if (nextItem.Size != 0)
finishPos = nextItem.Offset + nextItem.Size;
lastFolderIndex = m_Database.GetLastFolder(index);
}
}
unPackSize = MyMin(finishPos - startPos, unPackSize);
chmFolderOutStream->m_FolderSize = folderSize;
chmFolderOutStream->m_PosInFolder = 0;
chmFolderOutStream->m_PosInSection = startPos;
chmFolderOutStream->m_ExtractStatuses = &extractStatuses;
chmFolderOutStream->m_NumFiles = extractStatuses.Size();
chmFolderOutStream->m_CurrentIndex = 0;
try
{
UInt64 startBlock = lzxInfo.GetBlockIndexFromFolderIndex(folderIndex);
const CResetTable &rt = lzxInfo.ResetTable;
UInt32 numBlocks = (UInt32)rt.GetNumBlocks(unPackSize);
for (UInt32 b = 0; b < numBlocks; b++)
{
UInt64 completedSize = currentTotalSize + chmFolderOutStream->m_PosInSection - startPos;
RINOK(extractCallback->SetCompleted(&completedSize));
UInt64 bCur = startBlock + b;
if (bCur >= rt.ResetOffsets.Size())
return E_FAIL;
UInt64 offset = rt.ResetOffsets[(unsigned)bCur];
UInt64 compressedSize;
rt.GetCompressedSizeOfBlock(bCur, compressedSize);
// chm writes full blocks. So we don't need to use reduced size for last block
RINOK(m_Stream->Seek(compressedPos + offset, STREAM_SEEK_SET, NULL));
streamSpec->SetStream(m_Stream);
streamSpec->Init(compressedSize);
lzxDecoderSpec->SetKeepHistory(b > 0);
size_t compressedSizeT = (size_t)compressedSize;
if (compressedSizeT != compressedSize)
throw 2;
packBuf.AllocAtLeast(compressedSizeT);
HRESULT res = ReadStream_FALSE(inStream, packBuf, compressedSizeT);
if (res == S_OK)
{
lzxDecoderSpec->KeepHistoryForNext = true;
res = lzxDecoderSpec->Code(packBuf, compressedSizeT, kBlockSize); // rt.BlockSize;
if (res == S_OK)
res = WriteStream(chmFolderOutStream,
lzxDecoderSpec->GetUnpackData(),
lzxDecoderSpec->GetUnpackSize());
}
if (res != S_OK)
{
if (res != S_FALSE)
return res;
throw 1;
}
}
}
catch(...)
{
RINOK(chmFolderOutStream->FlushCorrupted(unPackSize));
}
currentTotalSize += folderSize;
if (folderIndex == lastFolderIndex)
break;
extractStatuses.Clear();
}
}
return S_OK;
COM_TRY_END
}