Skip to content

Commit 6c65c81

Browse files
author
Oleh Kulykov
committed
1721296482
1 parent d5afe7e commit 6c65c81

26 files changed

+648
-357
lines changed

src/CPP/7zip/Archive/7z/7zCompressionMode.h

100755100644
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace NArchive {
1010
namespace N7z {
1111

12-
struct CMethodFull final : public CMethodProps
12+
struct CMethodFull: public CMethodProps
1313
{
1414
CMethodId Id;
1515
UInt32 NumStreams;
@@ -21,14 +21,14 @@ struct CMethodFull final : public CMethodProps
2121
bool IsSimpleCoder() const { return NumStreams == 1; }
2222
};
2323

24-
struct CBond2 final
24+
struct CBond2
2525
{
2626
UInt32 OutCoder;
2727
UInt32 OutStream;
2828
UInt32 InCoder;
2929
};
3030

31-
struct CCompressionMethodMode final
31+
struct CCompressionMethodMode
3232
{
3333
/*
3434
if (Bonds.Empty()), then default bonds must be created
@@ -52,31 +52,30 @@ struct CCompressionMethodMode final
5252

5353
bool DefaultMethod_was_Inserted;
5454
bool Filter_was_Inserted;
55+
bool PasswordIsDefined;
56+
bool MemoryUsageLimit_WasSet;
5557

5658
#ifndef Z7_ST
57-
UInt32 NumThreads;
5859
bool NumThreads_WasForced;
5960
bool MultiThreadMixer;
61+
UInt32 NumThreads;
6062
#endif
6163

62-
UInt64 MemoryUsageLimit;
63-
bool MemoryUsageLimit_WasSet;
64-
65-
bool PasswordIsDefined;
6664
UString Password; // _Wipe
67-
65+
UInt64 MemoryUsageLimit;
66+
6867
bool IsEmpty() const { return (Methods.IsEmpty() && !PasswordIsDefined); }
6968
CCompressionMethodMode():
7069
DefaultMethod_was_Inserted(false)
7170
, Filter_was_Inserted(false)
71+
, PasswordIsDefined(false)
72+
, MemoryUsageLimit_WasSet(false)
7273
#ifndef Z7_ST
73-
, NumThreads(1)
7474
, NumThreads_WasForced(false)
7575
, MultiThreadMixer(true)
76+
, NumThreads(1)
7677
#endif
7778
, MemoryUsageLimit((UInt64)1 << 30)
78-
, MemoryUsageLimit_WasSet(false)
79-
, PasswordIsDefined(false)
8079
{}
8180

8281
#ifdef Z7_CPP_IS_SUPPORTED_default

src/CPP/7zip/Archive/7z/7zDecode.cpp

100755100644
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,10 @@ HRESULT CDecoder::Decode(
442442
len = password.Len();
443443
}
444444
CByteBuffer_Wipe buffer(len * 2);
445+
const LPCOLESTR psw = passwordBSTR;
445446
for (size_t k = 0; k < len; k++)
446447
{
447-
const wchar_t c = passwordBSTR[k];
448+
const wchar_t c = psw[k];
448449
((Byte *)buffer)[k * 2] = (Byte)c;
449450
((Byte *)buffer)[k * 2 + 1] = (Byte)(c >> 8);
450451
}
@@ -501,8 +502,7 @@ HRESULT CDecoder::Decode(
501502

502503
CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;
503504

504-
CLockedInStream *lockedInStreamSpec = new CLockedInStream;
505-
CMyComPtr<IUnknown> lockedInStream = lockedInStreamSpec;
505+
CMyComPtr2_Create<IUnknown, CLockedInStream> lockedInStream;
506506

507507
#ifdef USE_MIXER_MT
508508
#ifdef USE_MIXER_ST
@@ -514,8 +514,8 @@ HRESULT CDecoder::Decode(
514514
{
515515
// lockedInStream.Pos = (UInt64)(Int64)-1;
516516
// RINOK(InStream_GetPos(inStream, lockedInStream.Pos))
517-
RINOK(inStream->Seek((Int64)(startPos + packPositions[0]), STREAM_SEEK_SET, &lockedInStreamSpec->Pos))
518-
lockedInStreamSpec->Stream = inStream;
517+
RINOK(inStream->Seek((Int64)(startPos + packPositions[0]), STREAM_SEEK_SET, &lockedInStream->Pos))
518+
lockedInStream->Stream = inStream;
519519

520520
#ifdef USE_MIXER_MT
521521
#ifdef USE_MIXER_ST
@@ -551,7 +551,7 @@ HRESULT CDecoder::Decode(
551551
{
552552
CLockedSequentialInStreamMT *lockedStreamImpSpec = new CLockedSequentialInStreamMT;
553553
packStream = lockedStreamImpSpec;
554-
lockedStreamImpSpec->Init(lockedInStreamSpec, packPos);
554+
lockedStreamImpSpec->Init(lockedInStream.ClsPtr(), packPos);
555555
}
556556
#ifdef USE_MIXER_ST
557557
else
@@ -561,7 +561,7 @@ HRESULT CDecoder::Decode(
561561
#ifdef USE_MIXER_ST
562562
CLockedSequentialInStreamST *lockedStreamImpSpec = new CLockedSequentialInStreamST;
563563
packStream = lockedStreamImpSpec;
564-
lockedStreamImpSpec->Init(lockedInStreamSpec, packPos);
564+
lockedStreamImpSpec->Init(lockedInStream.ClsPtr(), packPos);
565565
#endif
566566
}
567567
}

src/CPP/7zip/Archive/7z/7zDecode.h

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace NArchive {
1111
namespace N7z {
1212

13-
struct CBindInfoEx final : public NCoderMixer2::CBindInfo
13+
struct CBindInfoEx: public NCoderMixer2::CBindInfo
1414
{
1515
CRecordVector<CMethodId> CoderMethodIDs;
1616

@@ -21,7 +21,7 @@ struct CBindInfoEx final : public NCoderMixer2::CBindInfo
2121
}
2222
};
2323

24-
class CDecoder final
24+
class CDecoder
2525
{
2626
bool _bindInfoPrev_Defined;
2727
#ifdef USE_MIXER_ST

src/CPP/7zip/Archive/7z/7zEncode.cpp

100755100644
Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,9 @@ static HRESULT FillProps_from_Coder(IUnknown *coder, CByteBuffer &props)
299299
writeCoderProperties, coder)
300300
if (writeCoderProperties)
301301
{
302-
CDynBufSeqOutStream *outStreamSpec = new CDynBufSeqOutStream;
303-
CMyComPtr<ISequentialOutStream> dynOutStream(outStreamSpec);
302+
CMyComPtr2_Create<ISequentialOutStream, CDynBufSeqOutStream> outStreamSpec;
304303
outStreamSpec->Init();
305-
RINOK(writeCoderProperties->WriteCoderProperties(dynOutStream))
304+
RINOK(writeCoderProperties->WriteCoderProperties(outStreamSpec))
306305
outStreamSpec->CopyToBuffer(props);
307306
}
308307
else
@@ -332,11 +331,8 @@ HRESULT CEncoder::Encode1(
332331

333332
RINOK(_mixer->ReInit2())
334333

335-
CMtEncMultiProgress *mtProgressSpec = NULL;
336-
CMyComPtr<ICompressProgressInfo> mtProgress;
337-
338-
CSequentialOutMtNotify *mtOutStreamNotifySpec = NULL;
339-
CMyComPtr<ISequentialOutStream> mtOutStreamNotify;
334+
CMyComPtr2<ICompressProgressInfo, CMtEncMultiProgress> mtProgress;
335+
CMyComPtr2<ISequentialOutStream, CSequentialOutMtNotify> mtOutStreamNotify;
340336

341337
CRecordVector<CSequentialOutTempBufferImp2 *> tempBufferSpecs;
342338
CObjectVector<CMyComPtr<ISequentialOutStream> > tempBuffers;
@@ -454,18 +450,16 @@ HRESULT CEncoder::Encode1(
454450

455451
if (useMtProgress)
456452
{
457-
mtProgressSpec = new CMtEncMultiProgress;
458-
mtProgress = mtProgressSpec;
459-
mtProgressSpec->Init(compressProgress);
453+
mtProgress.SetFromCls(new CMtEncMultiProgress);
454+
mtProgress->Init(compressProgress);
460455

461-
mtOutStreamNotifySpec = new CSequentialOutMtNotify;
462-
mtOutStreamNotify = mtOutStreamNotifySpec;
463-
mtOutStreamNotifySpec->_stream = outStream;
464-
mtOutStreamNotifySpec->_mtProgressSpec = mtProgressSpec;
456+
mtOutStreamNotify.SetFromCls(new CSequentialOutMtNotify);
457+
mtOutStreamNotify->_stream = outStream;
458+
mtOutStreamNotify->_mtProgressSpec = mtProgress.ClsPtr();
465459

466460
FOR_VECTOR (t, tempBufferSpecs)
467461
{
468-
tempBufferSpecs[t]->_mtProgressSpec = mtProgressSpec;
462+
tempBufferSpecs[t]->_mtProgressSpec = mtProgress.ClsPtr();
469463
}
470464
}
471465

@@ -474,7 +468,8 @@ HRESULT CEncoder::Encode1(
474468
{
475469
outStreamSizeCountSpec = new CSequentialOutStreamSizeCount;
476470
outStreamSizeCount = outStreamSizeCountSpec;
477-
outStreamSizeCountSpec->SetStream(mtOutStreamNotify ? (ISequentialOutStream *)mtOutStreamNotify : outStream);
471+
outStreamSizeCountSpec->SetStream(mtOutStreamNotify.IsDefined() ?
472+
mtOutStreamNotify.Interface() : outStream);
478473
outStreamSizeCountSpec->Init();
479474
outStreamPointers.Add(outStreamSizeCount);
480475
}
@@ -486,8 +481,9 @@ HRESULT CEncoder::Encode1(
486481

487482
RINOK(_mixer->Code(
488483
&inStreamPointer,
489-
&outStreamPointers.Front(),
490-
mtProgress ? (ICompressProgressInfo *)mtProgress : compressProgress, dataAfterEnd_Error))
484+
outStreamPointers.ConstData(),
485+
mtProgress.IsDefined() ? mtProgress.Interface() :
486+
compressProgress, dataAfterEnd_Error))
491487

492488
if (_bindInfo.PackStreams.Size() != 0)
493489
packSizes.Add(outStreamSizeCountSpec->GetSize());

src/CPP/7zip/Archive/7z/7zEncode.h

100755100644
File mode changed.

src/CPP/7zip/Archive/7z/7zExtract.cpp

100755100644
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
271271

272272
RINOK(extractCallback->SetTotal(importantTotalUnpacked))
273273

274-
CLocalProgress *lps = new CLocalProgress;
275-
CMyComPtr<ICompressProgressInfo> progress = lps;
274+
CMyComPtr2_Create<ICompressProgressInfo, CLocalProgress> lps;
276275
lps->Init(extractCallback, false);
277276

278277
CDecoder decoder(
@@ -385,7 +384,7 @@ Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
385384
&curUnpacked,
386385

387386
outStream,
388-
progress,
387+
lps,
389388
NULL // *inStreamMainRes
390389
, dataAfterEnd_Error
391390

src/CPP/7zip/Archive/7z/7zFolderInStream.cpp

100755100644
File mode changed.

src/CPP/7zip/Archive/7z/7zFolderInStream.h

100755100644
File mode changed.

src/CPP/7zip/Archive/7z/7zHandler.cpp

100755100644
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value))
272272
prop = true;
273273
break;
274274
}
275+
default: break;
275276
}
276277
return prop.Detach(value);
277278
#ifndef Z7_SFX
@@ -291,7 +292,7 @@ bool CHandler::IsFolderEncrypted(CNum folderIndex) const
291292
if (folderIndex == kNumNoIndex)
292293
return false;
293294
const size_t startPos = _db.FoCodersDataOffset[folderIndex];
294-
const Byte *p = _db.CodersData + startPos;
295+
const Byte *p = _db.CodersData.ConstData() + startPos;
295296
const size_t size = _db.FoCodersDataOffset[folderIndex + 1] - startPos;
296297
CInByte2 inByte;
297298
inByte.Init(p, size);
@@ -350,11 +351,11 @@ Z7_COM7F_IMF(CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data
350351
{
351352
if (_db.NameOffsets && _db.NamesBuf)
352353
{
353-
size_t offset = _db.NameOffsets[index];
354-
size_t size = (_db.NameOffsets[index + 1] - offset) * 2;
354+
const size_t offset = _db.NameOffsets[index];
355+
const size_t size = (_db.NameOffsets[index + 1] - offset) * 2;
355356
if (size < ((UInt32)1 << 31))
356357
{
357-
*data = (const void *)(_db.NamesBuf + offset * 2);
358+
*data = (const void *)(_db.NamesBuf.ConstData() + offset * 2);
358359
*dataSize = (UInt32)size;
359360
*propType = NPropDataType::kUtf16z;
360361
}
@@ -395,7 +396,7 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
395396
temp[--pos] = 0;
396397

397398
const size_t startPos = _db.FoCodersDataOffset[folderIndex];
398-
const Byte *p = _db.CodersData + startPos;
399+
const Byte *p = _db.CodersData.ConstData() + startPos;
399400
const size_t size = _db.FoCodersDataOffset[folderIndex + 1] - startPos;
400401
CInByte2 inByte;
401402
inByte.Init(p, size);
@@ -482,9 +483,9 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
482483
if (propsSize == 1)
483484
ConvertUInt32ToString((UInt32)props[0] + 1, s);
484485
}
485-
else if (id == k_ARM64)
486+
else if (id == k_ARM64 || id == k_RISCV)
486487
{
487-
name = "ARM64";
488+
name = id == k_ARM64 ? "ARM64" : "RISCV";
488489
if (propsSize == 4)
489490
ConvertUInt32ToString(GetUi32(props), s);
490491
/*
@@ -666,6 +667,7 @@ Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
666667
#endif
667668

668669
#endif
670+
default: break;
669671
}
670672
// return prop.Detach(value);
671673
return S_OK;

src/CPP/7zip/Archive/7z/7zHandler.h

100755100644
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ class COutHandler: public CMultiMethodProps
5454
CBoolPair Write_Attrib;
5555

5656
bool _useMultiThreadMixer;
57-
5857
bool _removeSfxBlock;
59-
6058
// bool _volumeMode;
6159

60+
UInt32 _decoderCompatibilityVersion;
61+
CUIntVector _enabledFilters;
62+
CUIntVector _disabledFilters;
63+
6264
void InitSolidFiles() { _numSolidFiles = (UInt64)(Int64)(-1); }
6365
void InitSolidSize() { _numSolidBytes = (UInt64)(Int64)(-1); }
6466
void InitSolid()

0 commit comments

Comments
 (0)