Update to 7-Zip 17.00 Beta

This commit is contained in:
Tino Reichardt
2017-04-30 14:14:14 +02:00
parent 54389d6e2f
commit aa5ba75da0
451 changed files with 15746 additions and 8574 deletions

View File

@@ -15,7 +15,7 @@ namespace NPpmdZip {
CDecoder::CDecoder(bool fullFileMode):
_fullFileMode(fullFileMode)
{
_ppmd.Stream.In = &_inStream.p;
_ppmd.Stream.In = &_inStream.vt;
Ppmd8_Construct(&_ppmd);
}
@@ -25,7 +25,7 @@ CDecoder::~CDecoder()
}
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
if (!_outStream.Alloc())
return E_OUTOFMEMORY;
@@ -64,15 +64,21 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream
bool wasFinished = false;
UInt64 processedSize = 0;
while (!outSize || processedSize < *outSize)
for (;;)
{
size_t size = kBufSize;
if (outSize != NULL)
if (outSize)
{
const UInt64 rem = *outSize - processedSize;
if (size > rem)
{
size = (size_t)rem;
if (size == 0)
break;
}
}
Byte *data = _outStream.Buf;
size_t i = 0;
int sym = 0;
@@ -84,6 +90,7 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream
data[i] = (Byte)sym;
}
while (++i != size);
processedSize += i;
RINOK(WriteStream(outStream, _outStream.Buf, i));
@@ -99,13 +106,16 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream
wasFinished = true;
break;
}
if (progress)
{
UInt64 inSize = _inStream.GetProcessed();
RINOK(progress->SetRatioInfo(&inSize, &processedSize));
const UInt64 inProccessed = _inStream.GetProcessed();
RINOK(progress->SetRatioInfo(&inProccessed, &processedSize));
}
}
RINOK(_inStream.Res);
if (_fullFileMode)
{
if (!wasFinished)
@@ -117,11 +127,29 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream
}
if (!Ppmd8_RangeDec_IsFinishedOK(&_ppmd))
return S_FALSE;
if (inSize && *inSize != _inStream.GetProcessed())
return S_FALSE;
}
return S_OK;
}
STDMETHODIMP CDecoder::SetFinishMode(UInt32 finishMode)
{
_fullFileMode = (finishMode != 0);
return S_OK;
}
STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
{
*value = _inStream.GetProcessed();
return S_OK;
}
// ---------- Encoder ----------
void CEncProps::Normalize(int level)
@@ -206,7 +234,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIA
CEncoder::CEncoder()
{
_props.Normalize(-1);
_ppmd.Stream.Out = &_outStream.p;
_ppmd.Stream.Out = &_outStream.vt;
Ppmd8_Construct(&_ppmd);
}
@@ -248,10 +276,10 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream
RINOK(_outStream.Res);
}
processed += size;
if (progress != NULL)
if (progress)
{
UInt64 outSize = _outStream.GetProcessed();
RINOK(progress->SetRatioInfo(&processed, &outSize));
const UInt64 outProccessed = _outStream.GetProcessed();
RINOK(progress->SetRatioInfo(&processed, &outProccessed));
}
}
}