mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 18:06:55 -06:00
23.01
This commit is contained in:
@@ -15,15 +15,15 @@ CCopyCoder::~CCopyCoder()
|
||||
::MidFree(_buf);
|
||||
}
|
||||
|
||||
STDMETHODIMP CCopyCoder::SetFinishMode(UInt32 /* finishMode */)
|
||||
Z7_COM7F_IMF(CCopyCoder::SetFinishMode(UInt32 /* finishMode */))
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
|
||||
Z7_COM7F_IMF(CCopyCoder::Code(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream,
|
||||
const UInt64 * /* inSize */, const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress)
|
||||
ICompressProgressInfo *progress))
|
||||
{
|
||||
if (!_buf)
|
||||
{
|
||||
@@ -44,7 +44,12 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
|
||||
{
|
||||
size = (UInt32)rem;
|
||||
if (size == 0)
|
||||
{
|
||||
/* if we enable the following check,
|
||||
we will make one call of Read(_buf, 0) for empty stream */
|
||||
// if (TotalSize != 0)
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +86,7 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
|
||||
return E_FAIL; // internal code failure
|
||||
pos += processed;
|
||||
TotalSize += processed;
|
||||
RINOK(res);
|
||||
RINOK(res)
|
||||
if (processed == 0)
|
||||
return E_FAIL;
|
||||
}
|
||||
@@ -90,32 +95,32 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
|
||||
else
|
||||
TotalSize += size;
|
||||
|
||||
RINOK(readRes);
|
||||
RINOK(readRes)
|
||||
|
||||
if (size != kBufSize)
|
||||
return S_OK;
|
||||
|
||||
if (progress && (TotalSize & (((UInt32)1 << 22) - 1)) == 0)
|
||||
{
|
||||
RINOK(progress->SetRatioInfo(&TotalSize, &TotalSize));
|
||||
RINOK(progress->SetRatioInfo(&TotalSize, &TotalSize))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CCopyCoder::SetInStream(ISequentialInStream *inStream)
|
||||
Z7_COM7F_IMF(CCopyCoder::SetInStream(ISequentialInStream *inStream))
|
||||
{
|
||||
_inStream = inStream;
|
||||
TotalSize = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CCopyCoder::ReleaseInStream()
|
||||
Z7_COM7F_IMF(CCopyCoder::ReleaseInStream())
|
||||
{
|
||||
_inStream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CCopyCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CCopyCoder::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
UInt32 realProcessedSize = 0;
|
||||
HRESULT res = _inStream->Read(data, size, &realProcessedSize);
|
||||
@@ -125,7 +130,7 @@ STDMETHODIMP CCopyCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
return res;
|
||||
}
|
||||
|
||||
STDMETHODIMP CCopyCoder::GetInStreamProcessedSize(UInt64 *value)
|
||||
Z7_COM7F_IMF(CCopyCoder::GetInStreamProcessedSize(UInt64 *value))
|
||||
{
|
||||
*value = TotalSize;
|
||||
return S_OK;
|
||||
@@ -141,7 +146,7 @@ HRESULT CopyStream_ExactSize(ISequentialInStream *inStream, ISequentialOutStream
|
||||
{
|
||||
NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
|
||||
CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
|
||||
RINOK(copyCoder->Code(inStream, outStream, NULL, &size, progress));
|
||||
RINOK(copyCoder->Code(inStream, outStream, NULL, &size, progress))
|
||||
return copyCoderSpec->TotalSize == size ? S_OK : E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user