This commit is contained in:
Igor Pavlov
2021-11-28 19:03:01 -08:00
committed by fn ⌃ ⌥
parent d789d4137d
commit 1194dc9353
152 changed files with 6049 additions and 946 deletions

View File

File diff suppressed because it is too large Load Diff

View File

@@ -34,7 +34,7 @@ namespace NCompressDialog
NWildcard::ECensorPathMode PathMode;
bool SolidIsSpecified;
bool MultiThreadIsAllowed;
// bool MultiThreadIsAllowed;
UInt64 SolidBlockSize;
UInt32 NumThreads;
@@ -80,6 +80,8 @@ namespace NCompressDialog
FormatIndex(-1)
{
Level = Order = (UInt32)(Int32)-1;
NumThreads = (UInt32)(Int32)-1;
SolidIsSpecified = false;
Dict64 = (UInt64)(Int64)(-1);
OrderMode = false;
Method.Empty();
@@ -100,16 +102,23 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
NWindows::NControl::CComboBox m_Order;
NWindows::NControl::CComboBox m_Solid;
NWindows::NControl::CComboBox m_NumThreads;
NWindows::NControl::CComboBox m_Volume;
NWindows::NControl::CDialogChildControl m_Params;
NWindows::NControl::CComboBox m_UpdateMode;
NWindows::NControl::CComboBox m_PathMode;
NWindows::NControl::CComboBox m_Volume;
NWindows::NControl::CDialogChildControl m_Params;
NWindows::NControl::CEdit _password1Control;
NWindows::NControl::CEdit _password2Control;
NWindows::NControl::CComboBox _encryptionMethod;
int _auto_MethodId;
UInt32 _auto_Dict; // (UInt32)(Int32)-1 means unknown
UInt32 _auto_Order;
UInt64 _auto_Solid;
UInt32 _auto_NumThreads;
int _default_encryptionMethod_Index;
NCompression::CInfo m_RegistryInfo;
@@ -118,13 +127,30 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
UString DirPrefix;
UString StartDirPrefix;
bool _ramSize_Defined;
UInt64 _ramSize;
UInt64 _ramUsage_Auto;
UInt64 _ramUsage_Limit;
void CheckButton_TwoBools(UINT id, const CBoolPair &b1, const CBoolPair &b2);
void GetButton_Bools(UINT id, CBoolPair &b1, CBoolPair &b2);
void SetArchiveName(const UString &name);
int FindRegistryFormat(const UString &name);
int FindRegistryFormatAlways(const UString &name);
const CArcInfoEx &Get_ArcInfoEx()
{
return (*ArcFormats)[GetFormatIndex()];
}
NCompression::CFormatOptions &Get_FormatOptions()
{
const CArcInfoEx &ai = Get_ArcInfoEx();
return m_RegistryInfo.Formats[ FindRegistryFormatAlways(ai.Name) ];
}
void CheckSFXNameChange();
void SetArchiveName2(bool prevWasSFX);
@@ -132,11 +158,35 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void SetNearestSelectComboBox(NWindows::NControl::CComboBox &comboBox, UInt32 value);
void SetLevel();
void SetLevel2();
void SetLevel()
{
SetLevel2();
EnableMultiCombo(IDC_COMPRESS_LEVEL);
SetMethod();
}
void SetMethod(int keepMethodId = -1);
void SetMethod2(int keepMethodId);
void SetMethod(int keepMethodId = -1)
{
SetMethod2(keepMethodId);
EnableMultiCombo(IDC_COMPRESS_METHOD);
}
void MethodChanged()
{
SetDictionary2();
EnableMultiCombo(IDC_COMPRESS_DICTIONARY);
SetOrder2();
EnableMultiCombo(IDC_COMPRESS_ORDER);
}
int GetMethodID_RAW();
int GetMethodID();
UString GetMethodSpec(UString &estimatedName);
UString GetMethodSpec();
bool IsMethodEqualTo(const UString &s);
UString GetEncryptionMethodSpec();
bool IsZipFormat();
@@ -144,10 +194,10 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void SetEncryptionMethod();
void AddDict2(size_t sizeReal, size_t sizeShow);
void AddDict(size_t size);
void SetDictionary();
int AddDict2(size_t sizeReal, size_t sizeShow);
int AddDict(size_t size);
void SetDictionary2();
UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);
UInt64 GetComboValue_64(NWindows::NControl::CComboBox &c, int defMax = 0);
@@ -155,24 +205,60 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
UInt32 GetLevel() { return GetComboValue(m_Level); }
UInt32 GetLevelSpec() { return GetComboValue(m_Level, 1); }
UInt32 GetLevel2();
UInt64 GetDict() { return GetComboValue_64(m_Dictionary); }
UInt64 GetDictSpec() { return GetComboValue_64(m_Dictionary, 1); }
UInt32 GetOrder() { return GetComboValue(m_Order); }
UInt64 GetDict2()
{
UInt64 num = GetDictSpec();
if (num == (UInt64)(Int64)-1)
{
if (_auto_Dict == (UInt32)(Int32)-1)
return (UInt64)(Int64)-1; // unknown
num = _auto_Dict;
}
return num;
}
// UInt32 GetOrder() { return GetComboValue(m_Order); }
UInt32 GetOrderSpec() { return GetComboValue(m_Order, 1); }
UInt32 GetNumThreadsSpec() { return GetComboValue(m_NumThreads, 1); }
UInt32 GetNumThreads2() { UInt32 num = GetNumThreadsSpec(); if (num == UInt32(-1)) num = 1; return num; }
UInt32 GetNumThreads2()
{
UInt32 num = GetNumThreadsSpec();
if (num == (UInt32)(Int32)-1)
num = _auto_NumThreads;
return num;
}
UInt32 GetBlockSizeSpec() { return GetComboValue(m_Solid, 1); }
int AddOrder(UInt32 size);
void SetOrder();
int AddOrder_Auto();
void SetOrder2();
bool GetOrderMode();
void SetSolidBlockSize(bool useDictionary = false);
void SetNumThreads();
void SetSolidBlockSize2();
void SetSolidBlockSize(/* bool useDictionary = false */)
{
SetSolidBlockSize2();
EnableMultiCombo(IDC_COMPRESS_SOLID);
}
void SetNumThreads2();
void SetNumThreads()
{
SetNumThreads2();
EnableMultiCombo(IDC_COMPRESS_THREADS);
}
UInt64 GetMemoryUsage_Dict_DecompMem(UInt64 dict, UInt64 &decompressMemory);
UInt64 GetMemoryUsage_Threads_Dict_DecompMem(UInt32 numThreads, UInt64 dict, UInt64 &decompressMemory);
UInt64 GetMemoryUsage_DecompMem(UInt64 &decompressMemory);
UInt64 GetMemoryUsageComp_Dict(UInt64 dict64);
UInt64 GetMemoryUsageComp_Threads_Dict(UInt32 numThreads, UInt64 dict64);
void PrintMemUsage(UINT res, UInt64 value);
void SetMemoryUsage();
@@ -186,9 +272,32 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
bool SetArcPathFields(const UString &path, UString &name, bool always);
bool GetFinalPath_Smart(UString &resPath);
void CheckSFXControlsEnable();
// void CheckVolumeEnable();
void EnableMultiCombo(unsigned id);
void FormatChanged();
void OnButtonSetArchive();
bool IsSFX();
void OnButtonSFX();
virtual bool OnInit();
virtual bool OnCommand(int code, int itemID, LPARAM lParam);
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
virtual void OnOK();
virtual void OnHelp();
void MessageBoxError(LPCWSTR message)
{
MessageBoxW(*this, message, L"7-Zip", MB_ICONERROR);
}
public:
CObjectVector<CArcInfoEx> *ArcFormats;
const CObjectVector<CArcInfoEx> *ArcFormats;
CUIntVector ArcIndices; // can not be empty, must contain Info.FormatIndex, if Info.FormatIndex >= 0
AStringVector ExternalMethods;
void SetMethods(const CObjectVector<CCodecInfoUser> &userCodecs);
NCompressDialog::CInfo Info;
UString OriginalFileName; // for bzip2, gzip2
@@ -201,28 +310,6 @@ public:
}
CCompressDialog(): CurrentDirWasChanged(false) {};
void MessageBoxError(LPCWSTR message)
{
MessageBoxW(*this, message, L"7-Zip", MB_ICONERROR);
}
protected:
void CheckSFXControlsEnable();
// void CheckVolumeEnable();
void CheckControlsEnable();
void OnButtonSetArchive();
bool IsSFX();
void OnButtonSFX();
virtual bool OnInit();
virtual bool OnCommand(int code, int itemID, LPARAM lParam);
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
virtual void OnOK();
virtual void OnHelp();
};
#endif

View File

@@ -64,6 +64,12 @@ class CThreadExtracting: public CProgressThreadVirt
{
HRESULT ProcessVirt();
public:
/*
#ifdef EXTERNAL_CODECS
const CExternalCodecs *externalCodecs;
#endif
*/
CCodecs *codecs;
CExtractCallbackImp *ExtractCallbackSpec;
const CObjectVector<COpenType> *FormatIndices;
@@ -105,7 +111,13 @@ HRESULT CThreadExtracting::ProcessVirt()
*/
#endif
HRESULT res = Extract(codecs,
HRESULT res = Extract(
/*
#ifdef EXTERNAL_CODECS
externalCodecs,
#endif
*/
codecs,
*FormatIndices, *ExcludedFormatIndices,
*ArchivePaths, *ArchivePathsFull,
*WildcardCensor, *Options, ExtractCallbackSpec, ExtractCallback,
@@ -154,6 +166,7 @@ HRESULT CThreadExtracting::ProcessVirt()
HRESULT ExtractGUI(
// DECL_EXTERNAL_CODECS_LOC_VARS
CCodecs *codecs,
const CObjectVector<COpenType> &formatIndices,
const CIntVector &excludedFormatIndices,
@@ -172,6 +185,11 @@ HRESULT ExtractGUI(
messageWasDisplayed = false;
CThreadExtracting extracter;
/*
#ifdef EXTERNAL_CODECS
extracter.externalCodecs = __externalCodecs;
#endif
*/
extracter.codecs = codecs;
extracter.FormatIndices = &formatIndices;
extracter.ExcludedFormatIndices = &excludedFormatIndices;

View File

@@ -20,6 +20,7 @@
*/
HRESULT ExtractGUI(
// DECL_EXTERNAL_CODECS_LOC_VARS
CCodecs *codecs,
const CObjectVector<COpenType> &formatIndices,
const CIntVector &excludedFormatIndices,

View File

@@ -34,6 +34,10 @@
using namespace NWindows;
#ifdef EXTERNAL_CODECS
const CExternalCodecs *g_ExternalCodecs_Ptr;
#endif
extern
HINSTANCE g_hInstance;
HINSTANCE g_hInstance;
@@ -134,18 +138,22 @@ static int Main2()
codecs->CaseSensitiveChange = options.CaseSensitiveChange;
codecs->CaseSensitive = options.CaseSensitive;
ThrowException_if_Error(codecs->Load());
Codecs_AddHashArcHandler(codecs);
#ifdef EXTERNAL_CODECS
{
g_ExternalCodecs_Ptr = &__externalCodecs;
UString s;
codecs->GetCodecsErrorMessage(s);
if (!s.IsEmpty())
{
MessageBoxW(0, s, L"7-Zip", MB_ICONERROR);
}
}
#endif
bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
const bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
if (codecs->Formats.Size() == 0 &&
(isExtractGroupCommand
@@ -170,7 +178,7 @@ static int Main2()
return NExitCode::kFatalError;
}
CIntVector excludedFormatIndices;
CIntVector excludedFormats;
FOR_VECTOR (k, options.ExcludedArcTypes)
{
CIntVector tempIndices;
@@ -180,12 +188,13 @@ static int Main2()
ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE);
return NExitCode::kFatalError;
}
excludedFormatIndices.AddToUniqueSorted(tempIndices[0]);
// excludedFormatIndices.Sort();
excludedFormats.AddToUniqueSorted(tempIndices[0]);
// excludedFormats.Sort();
}
#ifdef EXTERNAL_CODECS
if (isExtractGroupCommand
|| options.Command.IsFromUpdateGroup()
|| options.Command.CommandType == NCommandType::kHash
|| options.Command.CommandType == NCommandType::kBenchmark)
ThrowException_if_Error(__externalCodecs.Load());
@@ -270,8 +279,10 @@ static int Main2()
ecs->MultiArcMode = (ArchivePathsSorted.Size() > 1);
HRESULT result = ExtractGUI(codecs,
formatIndices, excludedFormatIndices,
HRESULT result = ExtractGUI(
// EXTERNAL_CODECS_VARS_L
codecs,
formatIndices, excludedFormats,
ArchivePathsSorted,
ArchivePathsFullSorted,
options.Censor.Pairs.Front().Head,

View File

@@ -872,6 +872,14 @@ SOURCE=..\..\..\Common\CRC.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\DynLimBuf.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\DynLimBuf.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\IntToString.cpp
# End Source File
# Begin Source File
@@ -1188,6 +1196,14 @@ SOURCE=..\..\..\Windows\Window.h
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Common\ItemNameUtils.h
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
# End Source File
# Begin Source File

View File

@@ -174,10 +174,12 @@ HRESULT CHashCallbackGUI::SetOperationResult(UInt64 /* fileSize */, const CHashB
return CheckBreak();
}
static const unsigned k_DigestStringSize = k_HashCalc_DigestSize_Max * 2 + k_HashCalc_ExtraSize * 2 + 16;
static void AddHashString(CProperty &s, const CHasherState &h, unsigned digestIndex)
{
char temp[k_HashCalc_DigestSize_Max * 2 + 4];
AddHashHexToString(temp, h.Digests[digestIndex], h.DigestSize);
char temp[k_DigestStringSize];
h.WriteToString(digestIndex, temp);
s.Value = temp;
}

View File

@@ -156,7 +156,7 @@ HRESULT CUpdateCallbackGUI::ReportExtractResult(Int32 opRes, Int32 isEncrypted,
return S_OK;
}
HRESULT CUpdateCallbackGUI::ReportUpdateOpeartion(UInt32 op, const wchar_t *name, bool isDir)
HRESULT CUpdateCallbackGUI::ReportUpdateOperation(UInt32 op, const wchar_t *name, bool isDir)
{
return SetOperation_Base(op, name, isDir);
}

View File

@@ -146,7 +146,8 @@ static void SetOutProperties(
bool orderMode,
UInt32 order,
bool solidIsSpecified, UInt64 solidBlockSize,
bool multiThreadIsAllowed, UInt32 numThreads,
// bool multiThreadIsAllowed,
UInt32 numThreads,
const UString &encryptionMethod,
bool encryptHeadersIsAllowed, bool encryptHeaders,
bool /* sfxMode */)
@@ -182,7 +183,9 @@ static void SetOutProperties(
AddProp(properties, "he", encryptHeaders);
if (solidIsSpecified)
AddProp(properties, "s", GetNumInBytesString(solidBlockSize));
if (multiThreadIsAllowed)
if (
// multiThreadIsAllowed &&
numThreads != (UInt32)(Int32)-1)
AddProp(properties, "mt", numThreads);
}
@@ -287,6 +290,11 @@ static HRESULT ShowDialog(
CCompressDialog dialog;
NCompressDialog::CInfo &di = dialog.Info;
dialog.ArcFormats = &codecs->Formats;
{
CObjectVector<CCodecInfoUser> userCodecs;
codecs->Get_CodecsInfoUser_Vector(userCodecs);
dialog.SetMethods(userCodecs);
}
if (options.MethodMode.Type_Defined)
di.FormatIndex = options.MethodMode.Type.FormatIndex;
@@ -299,9 +307,13 @@ static HRESULT ShowDialog(
if (!oneFile && ai.Flags_KeepName())
continue;
if ((int)i != di.FormatIndex)
{
if (ai.Flags_HashHandler())
continue;
if (ai.Name.IsEqualTo_Ascii_NoCase("swfc"))
if (!oneFile || name.Len() < 4 || !StringsAreEqualNoCase_Ascii(name.RightPtr(4), ".swf"))
continue;
}
dialog.ArcIndices.Add(i);
}
if (dialog.ArcIndices.IsEmpty())
@@ -392,7 +404,8 @@ static HRESULT ShowDialog(
di.Dict64,
di.OrderMode, di.Order,
di.SolidIsSpecified, di.SolidBlockSize,
di.MultiThreadIsAllowed, di.NumThreads,
// di.MultiThreadIsAllowed,
di.NumThreads,
di.EncryptionMethod,
di.EncryptHeadersIsAllowed, di.EncryptHeaders,
di.SFXMode);
@@ -464,6 +477,13 @@ HRESULT UpdateGUI(
tu.UpdateCallbackGUI->Init();
UString title = LangString(IDS_PROGRESS_COMPRESSING);
if (!formatIndices.IsEmpty())
{
const int fin = formatIndices[0].FormatIndex;
if (fin >= 0)
if (codecs->Formats[fin].Flags_HashHandler())
title = LangString(IDS_CHECKSUM_CALCULATING);
}
/*
if (hwndParent != 0)

View File

@@ -24,6 +24,7 @@ GUI_OBJS = \
COMMON_OBJS = \
$O\CommandLineParser.obj \
$O\CRC.obj \
$O\DynLimBuf.obj \
$O\IntToString.obj \
$O\Lang.obj \
$O\ListFileUtils.obj \
@@ -102,6 +103,7 @@ UI_COMMON_OBJS = \
$O\ZipRegistry.obj \
AR_COMMON_OBJS = \
$O\ItemNameUtils.obj \
$O\OutStreamWithCRC.obj \
FM_OBJS = \