Function GetStream
Synopsis
#include <include/bufferextractcallback.hpp>
STDMETHOD() GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)
Description
IArchiveExtractCallback.
Source
Lines 43-74 in src/bufferextractcallback.cpp. Line 41 in include/bufferextractcallback.hpp.
STDMETHODIMP BufferExtractCallback::GetStream( UInt32 index, ISequentialOutStream** outStream, Int32 askExtractMode ) try {
*outStream = nullptr;
mOutMemStream.Release();
// Get Name
BitPropVariant prop = mInputArchive.getItemProperty( index, BitProperty::Path );
wstring fullPath;
if ( prop.isEmpty() ) {
fullPath = kEmptyFileAlias;
} else if ( prop.isString() ) {
fullPath = prop.getString();
} else {
return E_FAIL;
}
if ( askExtractMode != NArchive::NExtract::NAskMode::kExtract ) {
return S_OK;
}
if ( !mInputArchive.isItemFolder( index ) ) {
//Note: using [] operator it creates the buffer if it does not exists already!
auto* out_mem_stream_spec = new CBufOutStream( mBuffersMap[ fullPath ] );
CMyComPtr< ISequentialOutStream > outStreamLoc( out_mem_stream_spec );
mOutMemStream = outStreamLoc;
*outStream = outStreamLoc.Detach();
}
return S_OK;
} catch ( const BitException& ) {
return E_OUTOFMEMORY;
}