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

@@ -60,6 +60,62 @@ static void BoolVector_Fill_False(CBoolVector &v, unsigned size)
p[i] = false;
}
HRESULT CCoder::CheckDataAfterEnd(bool &dataAfterEnd_Error /* , bool &InternalPackSizeError */) const
{
if (Coder)
{
if (PackSizePointers.IsEmpty() || !PackSizePointers[0])
return S_OK;
CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize;
Coder.QueryInterface(IID_ICompressGetInStreamProcessedSize, (void **)&getInStreamProcessedSize);
// if (!getInStreamProcessedSize) return E_FAIL;
if (getInStreamProcessedSize)
{
UInt64 processed;
RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&processed));
if (processed != (UInt64)(Int64)-1)
{
const UInt64 size = PackSizes[0];
if (processed < size && Finish)
dataAfterEnd_Error = true;
if (processed > size)
{
// InternalPackSizeError = true;
// return S_FALSE;
}
}
}
}
else if (Coder2)
{
CMyComPtr<ICompressGetInStreamProcessedSize2> getInStreamProcessedSize2;
Coder2.QueryInterface(IID_ICompressGetInStreamProcessedSize2, (void **)&getInStreamProcessedSize2);
FOR_VECTOR (i, PackSizePointers)
{
if (!PackSizePointers[i])
continue;
UInt64 processed;
RINOK(getInStreamProcessedSize2->GetInStreamProcessedSize2(i, &processed));
if (processed != (UInt64)(Int64)-1)
{
const UInt64 size = PackSizes[i];
if (processed < size && Finish)
dataAfterEnd_Error = true;
else if (processed > size)
{
// InternalPackSizeError = true;
// return S_FALSE;
}
}
}
}
return S_OK;
}
class CBondsChecks
{
CBoolVector _coderUsed;
@@ -151,8 +207,10 @@ bool CBindInfo::CalcMapsAndCheck()
}
void CCoder::SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes)
void CCoder::SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish)
{
Finish = finish;
if (unpackSize)
{
UnpackSize = *unpackSize;
@@ -640,8 +698,12 @@ void CMixerST::SelectMainCoder(bool useFirst)
HRESULT CMixerST::Code(
ISequentialInStream * const *inStreams,
ISequentialOutStream * const *outStreams,
ICompressProgressInfo *progress)
ICompressProgressInfo *progress,
bool &dataAfterEnd_Error)
{
// InternalPackSizeError = false;
dataAfterEnd_Error = false;
_binderStreams.Clear();
unsigned ci = MainCoderIndex;
@@ -742,7 +804,16 @@ HRESULT CMixerST::Code(
if (res == k_My_HRESULT_WritingWasCut)
res = S_OK;
return res;
if (res != S_OK)
return res;
for (i = 0; i < _coders.Size(); i++)
{
RINOK(_coders[i].CheckDataAfterEnd(dataAfterEnd_Error /*, InternalPackSizeError */));
}
return S_OK;
}
@@ -988,8 +1059,12 @@ HRESULT CMixerMT::ReturnIfError(HRESULT code)
HRESULT CMixerMT::Code(
ISequentialInStream * const *inStreams,
ISequentialOutStream * const *outStreams,
ICompressProgressInfo *progress)
ICompressProgressInfo *progress,
bool &dataAfterEnd_Error)
{
// InternalPackSizeError = false;
dataAfterEnd_Error = false;
Init(inStreams, outStreams);
unsigned i;
@@ -1031,6 +1106,11 @@ HRESULT CMixerMT::Code(
return result;
}
for (i = 0; i < _coders.Size(); i++)
{
RINOK(_coders[i].CheckDataAfterEnd(dataAfterEnd_Error /* , InternalPackSizeError */));
}
return S_OK;
}

View File

@@ -201,9 +201,13 @@ public:
CRecordVector<UInt64> PackSizes;
CRecordVector<const UInt64 *> PackSizePointers;
CCoder() {}
bool Finish;
void SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes);
CCoder(): Finish(false) {}
void SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish);
HRESULT CheckDataAfterEnd(bool &dataAfterEnd_Error /* , bool &InternalPackSizeError */) const;
IUnknown *GetUnknown() const
{
@@ -239,9 +243,12 @@ protected:
public:
unsigned MainCoderIndex;
// bool InternalPackSizeError;
CMixer(bool encodeMode):
EncodeMode(encodeMode),
MainCoderIndex(0)
// , InternalPackSizeError(false)
{}
/*
@@ -273,11 +280,12 @@ public:
virtual CCoder &GetCoder(unsigned index) = 0;
virtual void SelectMainCoder(bool useFirst) = 0;
virtual void ReInit() = 0;
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes) = 0;
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish) = 0;
virtual HRESULT Code(
ISequentialInStream * const *inStreams,
ISequentialOutStream * const *outStreams,
ICompressProgressInfo *progress) = 0;
ICompressProgressInfo *progress,
bool &dataAfterEnd_Error) = 0;
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const = 0;
bool Is_UnpackSize_Correct_for_Coder(UInt32 coderIndex);
@@ -338,12 +346,13 @@ public:
virtual CCoder &GetCoder(unsigned index);
virtual void SelectMainCoder(bool useFirst);
virtual void ReInit();
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes)
{ _coders[coderIndex].SetCoderInfo(unpackSize, packSizes); }
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish)
{ _coders[coderIndex].SetCoderInfo(unpackSize, packSizes, finish); }
virtual HRESULT Code(
ISequentialInStream * const *inStreams,
ISequentialOutStream * const *outStreams,
ICompressProgressInfo *progress);
ICompressProgressInfo *progress,
bool &dataAfterEnd_Error);
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const;
HRESULT GetMainUnpackStream(
@@ -419,12 +428,13 @@ public:
virtual CCoder &GetCoder(unsigned index);
virtual void SelectMainCoder(bool useFirst);
virtual void ReInit();
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes)
{ _coders[coderIndex].SetCoderInfo(unpackSize, packSizes); }
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish)
{ _coders[coderIndex].SetCoderInfo(unpackSize, packSizes, finish); }
virtual HRESULT Code(
ISequentialInStream * const *inStreams,
ISequentialOutStream * const *outStreams,
ICompressProgressInfo *progress);
ICompressProgressInfo *progress,
bool &dataAfterEnd_Error);
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const;
CMixerMT(bool encodeMode): CMixer(encodeMode) {}

View File

@@ -20,21 +20,20 @@ static void SetMethodProp32(COneMethodInfo &m, PROPID propID, UInt32 value)
m.AddProp32(propID, value);
}
void CMultiMethodProps::SetGlobalLevelAndThreads(COneMethodInfo &oneMethodInfo
#ifndef _7ZIP_ST
, UInt32 numThreads
#endif
)
void CMultiMethodProps::SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const
{
UInt32 level = _level;
if (level != (UInt32)(Int32)-1)
SetMethodProp32(oneMethodInfo, NCoderPropID::kLevel, (UInt32)level);
#ifndef _7ZIP_ST
SetMethodProp32(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
#endif
}
#ifndef _7ZIP_ST
void CMultiMethodProps::SetMethodThreadsTo(COneMethodInfo &oneMethodInfo, UInt32 numThreads)
{
SetMethodProp32(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
}
#endif
void CMultiMethodProps::Init()
{
#ifndef _7ZIP_ST
@@ -73,7 +72,7 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
return S_OK;
}
if (name.IsEqualTo("crc"))
if (name.IsPrefixedBy_Ascii_NoCase("crc"))
{
name.Delete(0, 3);
_crcSize = 4;

View File

@@ -22,11 +22,13 @@ public:
COneMethodInfo _filterMethod;
bool _autoFilter;
void SetGlobalLevelAndThreads(COneMethodInfo &oneMethodInfo
#ifndef _7ZIP_ST
, UInt32 numThreads
#endif
);
void SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const;
#ifndef _7ZIP_ST
static void SetMethodThreadsTo(COneMethodInfo &oneMethodInfo, UInt32 numThreads);
#endif
unsigned GetNumEmptyMethods() const
{

View File

@@ -7,58 +7,57 @@
namespace NArchive {
namespace NItemName {
static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR;
static const wchar_t kDirDelimiter = L'/';
static const wchar_t kOsPathSepar = WCHAR_PATH_SEPARATOR;
static const wchar_t kUnixPathSepar = L'/';
void ReplaceToOsPathSeparator(wchar_t *s)
{
#ifdef _WIN32
for (;;)
void ReplaceSlashes_OsToUnix
#if WCHAR_PATH_SEPARATOR != L'/'
(UString &name)
{
wchar_t c = *s;
if (c == 0)
break;
if (c == kDirDelimiter)
*s = kOSDirDelimiter;
s++;
name.Replace(kOsPathSepar, kUnixPathSepar);
}
#else
(UString &) {}
#endif
UString GetOsPath(const UString &name)
{
#if WCHAR_PATH_SEPARATOR != L'/'
UString newName = name;
newName.Replace(kUnixPathSepar, kOsPathSepar);
return newName;
#else
return name;
#endif
}
UString MakeLegalName(const UString &name)
{
UString zipName = name;
zipName.Replace(kOSDirDelimiter, kDirDelimiter);
return zipName;
}
UString GetOSName(const UString &name)
{
UString newName = name;
newName.Replace(kDirDelimiter, kOSDirDelimiter);
return newName;
}
UString GetOSName2(const UString &name)
UString GetOsPath_Remove_TailSlash(const UString &name)
{
if (name.IsEmpty())
return UString();
UString newName = GetOSName(name);
if (newName.Back() == kOSDirDelimiter)
UString newName = GetOsPath(name);
if (newName.Back() == kOsPathSepar)
newName.DeleteBack();
return newName;
}
void ConvertToOSName2(UString &name)
void ReplaceToOsSlashes_Remove_TailSlash(UString &name)
{
if (!name.IsEmpty())
{
name.Replace(kDirDelimiter, kOSDirDelimiter);
if (name.Back() == kOSDirDelimiter)
#if WCHAR_PATH_SEPARATOR != L'/'
name.Replace(kUnixPathSepar, kOsPathSepar);
#endif
if (name.Back() == kOsPathSepar)
name.DeleteBack();
}
}
bool HasTailSlash(const AString &name, UINT
#if defined(_WIN32) && !defined(UNDER_CE)
codePage
@@ -67,20 +66,21 @@ bool HasTailSlash(const AString &name, UINT
{
if (name.IsEmpty())
return false;
LPCSTR prev =
#if defined(_WIN32) && !defined(UNDER_CE)
CharPrevExA((WORD)codePage, name, &name[name.Len()], 0);
#else
(LPCSTR)(name) + (name.Len() - 1);
#endif
return (*prev == '/');
char c =
#if defined(_WIN32) && !defined(UNDER_CE)
*CharPrevExA((WORD)codePage, name, name.Ptr(name.Len()), 0);
#else
name.Back();
#endif
return (c == '/');
}
#ifndef _WIN32
UString WinNameToOSName(const UString &name)
UString WinPathToOsPath(const UString &name)
{
UString newName = name;
newName.Replace(L'\\', kOSDirDelimiter);
newName.Replace(L'\\', WCHAR_PATH_SEPARATOR);
return newName;
}
#endif

View File

@@ -8,19 +8,20 @@
namespace NArchive {
namespace NItemName {
void ReplaceToOsPathSeparator(wchar_t *s);
UString MakeLegalName(const UString &name);
UString GetOSName(const UString &name);
UString GetOSName2(const UString &name);
void ConvertToOSName2(UString &name);
bool HasTailSlash(const AString &name, UINT codePage);
#ifdef _WIN32
inline UString WinNameToOSName(const UString &name) { return name; }
#else
UString WinNameToOSName(const UString &name);
#endif
void ReplaceSlashes_OsToUnix(UString &name);
UString GetOsPath(const UString &name);
UString GetOsPath_Remove_TailSlash(const UString &name);
void ReplaceToOsSlashes_Remove_TailSlash(UString &name);
bool HasTailSlash(const AString &name, UINT codePage);
#ifdef _WIN32
inline UString WinPathToOsPath(const UString &name) { return name; }
#else
UString WinPathToOsPath(const UString &name);
#endif
}}