I am having trouble extracting an archiv into a memory buffer.
I have seen hints in a couple of other posts, but just can't get the synta correct.
Here is what I have so far: (The commented lines are the iines in CLient7z.cpp which I am trying to replace with lines to extract to memory)
// Get uncompressed size of file NCOM::CPropVariant size_prop; archive->GetProperty(i, kpidSize, &size_prop); ULONGLONG unpackSize = size_prop.uhVal.QuadPart; TRACE("SIZE %d\n", unpackSize); byte *data = new byte[unpackSize]; // original code // _outFileStreamSpec = new COutFileStream; // new code for stream CBufPtrSeqOutStream *outStreamSpec = new CBufPtrSeqOutStream; // original code // CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec); // new code for stream CMyComPtr<ISequentialOutStream> outStream(outStreamSpec); outStreamSpec->Init(data, unpackSize); // original code // _outFileStream = outStreamLoc; // new code for stream outStreamSpec = outStream; // this line gives this compile error: // cannot convert from 'CMyComPtr<T>' to 'CBufPtrSeqOutStream * *outStream = outStream.Detach(); TRACE("DATA: %#x %#x %#x %#x\n", data[0], data[1], data[2], data[3]); delete data;
you don't need these lines:
outStreamSpec = outStream; *outStream = outStream.Detach();
the problem that you use same name outStream for two different variables. Use outStreamLoc for variable as in Client7z.cpp:
outStream
outStreamLoc
CMyComPtr<ISequentialOutStream> outStreamLoc(outStreamSpec);
Thanks for your help on this.
I changed the CMyComPtr line, and commented out the other two lines.
But nothing is being placed in the data array
// Get name of file in the archive NCOM::CPropVariant name_prop; archive->GetProperty(i, kpidPath, &name_prop); // Get uncompressed size of file NCOM::CPropVariant size_prop; archive->GetProperty(i, kpidSize, &size_prop); ULONGLONG unpackSize = size_prop.uhVal.QuadPart; TRACE("FILE NAME w: %ws SIZE: %d\n", name_prop.bstrVal, unpackSize); byte *data = new byte[unpackSize]; memset(data, 0, unpackSize); // clear to 0s for testing CBufPtrSeqOutStream *outStreamSpec = new CBufPtrSeqOutStream; CMyComPtr<ISequentialOutStream> outStreamLoc(outStreamSpec); outStreamSpec->Init(data, unpackSize); //outStreamSpec = outStream; //*outStream = outStream.Detach(); TRACE("DATA: %#x %#x %#x %#x\n", data[0], data[1], data[2], data[3]); delete data;
I do not get anything into the data array. I feel like I am missing the line which causes the extract to actualy take place into the data array.
Here is the trace output:showing that I am pointed to a member of the archive, but data is still set to 0s
FILE NAME w: 12in Ceramic.jpg SIZE: 5053 DATA: 0 0 0 0
*outStream = outStreamLoc.Detach();
2) also you must call TRACE when data will be decompressed. in SetOperationResult.
CMyComPtr<ISequentialOutStream> outStreamLoc;
must be member of CArchiveExtractCallback
I moved the definition of CMyComPtr<ISequentialOutStream> outStreamLoc; into CArchiveExtractCallback
regarding:
I don't have a variable called outStream
Where should I define outStream?
should CMyComPtr<ISequentialOutStream> outStream; be in CArchiveExtractCallback as well.
original Client7z.cpp:
STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)
Log in to post a comment.
I am having trouble extracting an archiv into a memory buffer.
I have seen hints in a couple of other posts, but just can't get the synta correct.
Here is what I have so far:
(The commented lines are the iines in CLient7z.cpp which I am trying to replace with lines to extract to memory)
Last edit: Al Hart 2015-08-26
you don't need these lines:
the problem that you use same name
outStream
for two different variables. UseoutStreamLoc
for variable as in Client7z.cpp:Thanks for your help on this.
I changed the CMyComPtr line, and commented out the other two lines.
But nothing is being placed in the data array
I do not get anything into the data array. I feel like I am missing the line which causes the extract to actualy take place into the data array.
Here is the trace output:showing that I am pointed to a member of the archive, but data is still set to 0s
2) also you must call TRACE when data will be decompressed. in SetOperationResult.
CMyComPtr<ISequentialOutStream> outStreamLoc;
must be member of
CArchiveExtractCallback
I moved the definition of CMyComPtr<ISequentialOutStream> outStreamLoc; into CArchiveExtractCallback
regarding:
I don't have a variable called outStream
Where should I define outStream?
should
CMyComPtr<ISequentialOutStream> outStream;
be in CArchiveExtractCallback as well.
original Client7z.cpp: