Skip to content

Commit

Permalink
Merge pull request #50 from szcnick/dev
Browse files Browse the repository at this point in the history
update master branch to new version
  • Loading branch information
jinfeihan57 committed Jun 20, 2020
2 parents 7583e71 + 9d8a8fc commit 8d44b53
Show file tree
Hide file tree
Showing 89 changed files with 5,931 additions and 3,068 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Ubuntu
on:
pull_request:
push:
paths-ignore:
- 'README.md'
Expand Down Expand Up @@ -42,6 +43,6 @@ jobs:
- name: check
run: |
cd ./check
bash check.sh `pwd`/../bin/7za
bash check.sh `pwd`/../bin/7z
cd ..
12 changes: 6 additions & 6 deletions C/7zVersion.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#define MY_VER_MAJOR 16
#define MY_VER_MAJOR 17
#define MY_VER_MINOR 02
#define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "17.01"
#define MY_VERSION "17.01"
#define MY_DATE "2020-04-20"
#define MY_VERSION_NUMBERS "17.02 beta"
#define MY_VERSION "17.02"
#define MY_DATE "2017-08-28"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"
#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain"
#define MY_COPYRIGHT_CR "Copyright (c) 1999-2016 Igor Pavlov"
#define MY_COPYRIGHT_CR "Copyright (c) 1999-2020 Igor Pavlov"

#ifdef USE_COPYRIGHT_CR
#define MY_COPYRIGHT MY_COPYRIGHT_CR
Expand All @@ -18,5 +18,5 @@

#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " : " MY_COPYRIGHT " : " MY_DATE

#define P7ZIP_VERSION "17.01"
#define P7ZIP_VERSION "17.02"

123 changes: 0 additions & 123 deletions C/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions CPP/7zip/Archive/7z/7zCompressionMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ struct CMethodFull: public CMethodProps
{
CMethodId Id;
UInt32 NumStreams;
int CodecIndex;

CMethodFull(): CodecIndex(-1) {}

bool IsSimpleCoder() const { return NumStreams == 1; }
};
Expand Down
20 changes: 14 additions & 6 deletions CPP/7zip/Archive/7z/7zDecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,13 @@ HRESULT CDecoder::Decode(

, ISequentialOutStream *outStream
, ICompressProgressInfo *compressProgress

, ISequentialInStream **
#ifdef USE_MIXER_ST
inStreamMainRes
#endif

#ifdef USE_MIXER_ST
inStreamMainRes
#endif
, bool &dataAfterEnd_Error

_7Z_DECODER_CRYPRO_VARS_DECL

Expand All @@ -239,6 +241,8 @@ HRESULT CDecoder::Decode(
#endif
)
{
dataAfterEnd_Error = false;

const UInt64 *packPositions = &folders.PackPositions[folders.FoStartPackStreamIndex[folderIndex]];
CFolderEx folderInfo;
folders.ParseFolderEx(folderIndex, folderInfo);
Expand Down Expand Up @@ -415,12 +419,14 @@ HRESULT CDecoder::Decode(
}
#endif

bool finishMode = false;
{
CMyComPtr<ICompressSetFinishMode> setFinishMode;
decoder->QueryInterface(IID_ICompressSetFinishMode, (void **)&setFinishMode);
if (setFinishMode)
{
RINOK(setFinishMode->SetFinishMode(BoolToInt(fullUnpack)));
finishMode = fullUnpack;
RINOK(setFinishMode->SetFinishMode(BoolToInt(finishMode)));
}
}

Expand Down Expand Up @@ -450,7 +456,7 @@ HRESULT CDecoder::Decode(
unpackSize :
&folders.CoderUnpackSizes[unpackStreamIndexStart + i];

_mixer->SetCoderInfo(i, unpackSizesPointer, packSizesPointers);
_mixer->SetCoderInfo(i, unpackSizesPointer, packSizesPointers, finishMode);
}

if (outStream)
Expand Down Expand Up @@ -530,7 +536,9 @@ HRESULT CDecoder::Decode(
progress2 = new CDecProgress(compressProgress);

ISequentialOutStream *outStreamPointer = outStream;
return _mixer->Code(inStreamPointers, &outStreamPointer, progress2 ? (ICompressProgressInfo *)progress2 : compressProgress);
return _mixer->Code(inStreamPointers, &outStreamPointer,
progress2 ? (ICompressProgressInfo *)progress2 : compressProgress,
dataAfterEnd_Error);
}

#ifdef USE_MIXER_ST
Expand Down
2 changes: 2 additions & 0 deletions CPP/7zip/Archive/7z/7zDecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class CDecoder

, ISequentialOutStream *outStream
, ICompressProgressInfo *compressProgress

, ISequentialInStream **inStreamMainRes
, bool &dataAfterEnd_Error

_7Z_DECODER_CRYPRO_VARS_DECL

Expand Down
35 changes: 18 additions & 17 deletions CPP/7zip/Archive/7z/7zEncode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,10 @@ HRESULT CEncoder::CreateMixerCoder(

CCreatedCoder cod;

// RINOK(CreateCoder(
// EXTERNAL_CODECS_LOC_VARS
// methodFull.Id, true, cod));

if (methodFull.CodecIndex >= 0)
{
RINOK(CreateCoder_Index(
EXTERNAL_CODECS_LOC_VARS
methodFull.CodecIndex, true, cod));
}
else
{
RINOK(CreateCoder_Id(
RINOK(CreateCoder(
EXTERNAL_CODECS_LOC_VARS
methodFull.Id, true, cod));
}

if (cod.NumStreams != methodFull.NumStreams)
return E_FAIL;
if (!cod.Coder && !cod.Coder2)
Expand Down Expand Up @@ -345,7 +333,7 @@ HRESULT CEncoder::Encode(
}

for (i = 0; i < numMethods; i++)
_mixer->SetCoderInfo(i, NULL, NULL);
_mixer->SetCoderInfo(i, NULL, NULL, false);


/* inStreamSize can be used by BCJ2 to set optimal range of conversion.
Expand Down Expand Up @@ -382,6 +370,17 @@ HRESULT CEncoder::Encode(
resetInitVector->ResetInitVector();
}

{
CMyComPtr<ICompressSetCoderPropertiesOpt> optProps;
coder->QueryInterface(IID_ICompressSetCoderPropertiesOpt, (void **)&optProps);
if (optProps)
{
PROPID propID = NCoderPropID::kExpectedDataSize;
NWindows::NCOM::CPropVariant prop = (UInt64)unpackSize;
RINOK(optProps->SetCoderPropertiesOpt(&propID, &prop, 1));
}
}

CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
coder->QueryInterface(IID_ICompressWriteCoderProperties, (void **)&writeCoderProperties);

Expand All @@ -392,7 +391,7 @@ HRESULT CEncoder::Encode(
CDynBufSeqOutStream *outStreamSpec = new CDynBufSeqOutStream;
CMyComPtr<ISequentialOutStream> dynOutStream(outStreamSpec);
outStreamSpec->Init();
writeCoderProperties->WriteCoderProperties(dynOutStream);
RINOK(writeCoderProperties->WriteCoderProperties(dynOutStream));
outStreamSpec->CopyToBuffer(props);
}
else
Expand Down Expand Up @@ -441,10 +440,12 @@ HRESULT CEncoder::Encode(
for (i = 1; i < _bindInfo.PackStreams.Size(); i++)
outStreamPointers.Add(tempBuffers[i - 1]);

bool dataAfterEnd_Error;

RINOK(_mixer->Code(
&inStreamPointer,
&outStreamPointers.Front(),
mtProgress ? (ICompressProgressInfo *)mtProgress : compressProgress));
mtProgress ? (ICompressProgressInfo *)mtProgress : compressProgress, dataAfterEnd_Error));

if (_bindInfo.PackStreams.Size() != 0)
packSizes.Add(outStreamSizeCountSpec->GetSize());
Expand Down
19 changes: 14 additions & 5 deletions CPP/7zip/Archive/7z/7zExtract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
#endif


bool dataAfterEnd_Error = false;

HRESULT result = decoder.Decode(
EXTERNAL_CODECS_VARS
_inStream,
Expand All @@ -358,20 +360,27 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
outStream,
progress,
NULL // *inStreamMainRes
, dataAfterEnd_Error

_7Z_DECODER_CRYPRO_VARS
#if !defined(_7ZIP_ST) && !defined(_SFX)
, true, _numThreads
#endif
);

if (result == S_FALSE || result == E_NOTIMPL)
if (result == S_FALSE || result == E_NOTIMPL || dataAfterEnd_Error)
{
bool wasFinished = folderOutStream->WasWritingFinished();

int resOp = (result == S_FALSE ?
NExtract::NOperationResult::kDataError :
NExtract::NOperationResult::kUnsupportedMethod);

int resOp = NExtract::NOperationResult::kDataError;

if (result != S_FALSE)
{
if (result == E_NOTIMPL)
resOp = NExtract::NOperationResult::kUnsupportedMethod;
else if (wasFinished && dataAfterEnd_Error)
resOp = NExtract::NOperationResult::kDataAfterEnd;
}

RINOK(folderOutStream->FlushCorrupted(resOp));

Expand Down
15 changes: 9 additions & 6 deletions CPP/7zip/Archive/7z/7zFolderInStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@ STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSiz
{
if (_stream)
{
UInt32 processed2;
RINOK(_stream->Read(data, size, &processed2));
if (processed2 != 0)
UInt32 cur = size;
const UInt32 kMax = (UInt32)1 << 20;
if (cur > kMax)
cur = kMax;
RINOK(_stream->Read(data, cur, &cur));
if (cur != 0)
{
_crc = CrcUpdate(_crc, data, processed2);
_pos += processed2;
_crc = CrcUpdate(_crc, data, cur);
_pos += cur;
if (processedSize)
*processedSize = processed2;
*processedSize = cur;
return S_OK;
}

Expand Down
Loading

0 comments on commit 8d44b53

Please sign in to comment.