Fix #101 - thanks to aeonios for pointing that out

Begin with #97
This commit is contained in:
Tino Reichardt
2019-12-02 00:45:27 +01:00
parent a95e994767
commit c2277a3957
6 changed files with 97 additions and 99 deletions

View File

@@ -229,22 +229,34 @@ HRESULT CompressFiles(
index = FindRegistryFormatAlways(arcType); index = FindRegistryFormatAlways(arcType);
if (index >= 0) if (index >= 0)
{ {
char temp[32]; char temp[256];
const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
if (!fo.Method.IsEmpty()) if (!fo.Method.IsEmpty())
{ {
params += " -m0="; params += " -m0=";
params += fo.Method; params += fo.Method;
}
if (fo.Level)
{
params += " -mx="; params += " -mx=";
ConvertUInt64ToString(fo.Level, temp); ConvertUInt64ToString(fo.Level, temp);
params += temp; params += temp;
}
if (fo.NumThreads)
{
params += " -mmt="; params += " -mmt=";
ConvertUInt64ToString(fo.NumThreads, temp); ConvertUInt64ToString(fo.NumThreads, temp);
params += temp; params += temp;
} }
if (!fo.Options.IsEmpty())
{
params += " -m";
params += fo.Options;
}
} }
} }
// for testing current params, /TR 2017-05-18 // for testing current params, /TR 2017-05-18

View File

@@ -160,6 +160,7 @@ static LPCTSTR const kBlockSize = TEXT("BlockSize");
static LPCTSTR const kNumThreads = TEXT("NumThreads"); static LPCTSTR const kNumThreads = TEXT("NumThreads");
static LPCWSTR const kMethod = L"Method"; static LPCWSTR const kMethod = L"Method";
static LPCWSTR const kOptions = L"Options"; static LPCWSTR const kOptions = L"Options";
static LPCWSTR const kSplitVolume = L"SplitVolume";
static LPCWSTR const kEncryptionMethod = L"EncryptionMethod"; static LPCWSTR const kEncryptionMethod = L"EncryptionMethod";
static LPCTSTR const kNtSecur = TEXT("Security"); static LPCTSTR const kNtSecur = TEXT("Security");
@@ -233,6 +234,7 @@ void CInfo::Save() const
SetRegString(fk, kMethod, fo.Method); SetRegString(fk, kMethod, fo.Method);
SetRegString(fk, kOptions, fo.Options); SetRegString(fk, kOptions, fo.Options);
SetRegString(fk, kSplitVolume, fo.SplitVolume);
SetRegString(fk, kEncryptionMethod, fo.EncryptionMethod); SetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
} }
} }
@@ -274,8 +276,9 @@ void CInfo::Load()
fo.FormatID = formatIDs[i]; fo.FormatID = formatIDs[i];
if (fk.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS) if (fk.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS)
{ {
GetRegString(fk, kOptions, fo.Options);
GetRegString(fk, kMethod, fo.Method); GetRegString(fk, kMethod, fo.Method);
GetRegString(fk, kOptions, fo.Options);
GetRegString(fk, kSplitVolume, fo.SplitVolume);
GetRegString(fk, kEncryptionMethod, fo.EncryptionMethod); GetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
GetRegUInt32(fk, kLevel, fo.Level); GetRegUInt32(fk, kLevel, fo.Level);

View File

@@ -45,6 +45,7 @@ namespace NCompression
CSysString FormatID; CSysString FormatID;
UString Method; UString Method;
UString SplitVolume;
UString Options; UString Options;
UString EncryptionMethod; UString EncryptionMethod;

View File

@@ -33,6 +33,8 @@ extern bool g_IsNT;
#include "CompressDialogRes.h" #include "CompressDialogRes.h"
#include "ExtractRes.h" #include "ExtractRes.h"
#define DLGDBG 0
#ifdef LANG #ifdef LANG
static const UInt32 kLangIDs[] = static const UInt32 kLangIDs[] =
{ {
@@ -262,42 +264,57 @@ struct CFormatInfo
bool EncryptFileNames; bool EncryptFileNames;
}; };
#if DLGDBG
void ShowInfo(LPCWSTR str, ...)
{
wchar_t buf[4000];
va_list args;
va_start(args, str);
wvsprintf(buf, str, args);
va_end(args);
ShowErrorMessage(NULL, buf);
}
#else
#define ShowInfo(x, ...)
#endif
#define METHODS_PAIR(x) ARRAY_SIZE(x), x #define METHODS_PAIR(x) ARRAY_SIZE(x), x
static const CFormatInfo g_Formats[] = static const CFormatInfo g_Formats[] =
{ {
{ {
"", "", /* 0 */
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
0, 0, 0, 0,
false, false, false, false, false, false false, false, false, false, false, false
}, },
{ {
k7zFormat, k7zFormat, /* 1 */
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_7zMethods), METHODS_PAIR(g_7zMethods),
true, true, true, true, true, true true, true, true, true, true, true
}, },
{ {
"Zip", "Zip", /* 2 */
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_ZipMethods), METHODS_PAIR(g_ZipMethods),
false, false, true, false, true, false false, false, true, false, true, false
}, },
{ {
"GZip", "GZip", /* 3 */
(1 << 1) | (1 << 5) | (1 << 7) | (1 << 9), (1 << 1) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_GZipMethods), METHODS_PAIR(g_GZipMethods),
false, false, false, false, false, false false, false, false, false, false, false
}, },
{ {
"BZip2", "BZip2", /* 4 */
(1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_BZip2Methods), METHODS_PAIR(g_BZip2Methods),
false, false, true, false, false, false false, false, true, false, false, false
}, },
{ {
"xz", "xz", /* 5 */
(1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_XzMethods), METHODS_PAIR(g_XzMethods),
false, true, true, false, false, false false, true, true, false, false, false
@@ -333,19 +350,19 @@ static const CFormatInfo g_Formats[] =
false, false, true, false, false, false false, false, true, false, false, false
}, },
{ {
"Swfc", "Swfc", /* 11 */
(1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_SwfcMethods), METHODS_PAIR(g_SwfcMethods),
false, false, true, false, false, false false, false, true, false, false, false
}, },
{ {
"Tar", "Tar", /* 12 */
(1 << 0), (1 << 0),
0, 0, 0, 0,
false, false, false, false, false, false false, false, false, false, false, false
}, },
{ {
"wim", "wim", /* 13 */
(1 << 0), (1 << 0),
0, 0, 0, 0,
false, false, false, false, false, false false, false, false, false, false, false
@@ -445,9 +462,10 @@ bool CCompressDialog::OnInit()
m_ArchivePath.Attach(GetItem(IDC_COMPRESS_ARCHIVE)); m_ArchivePath.Attach(GetItem(IDC_COMPRESS_ARCHIVE));
m_Format.Attach(GetItem(IDC_COMPRESS_FORMAT)); m_Format.Attach(GetItem(IDC_COMPRESS_FORMAT));
m_Level.Attach(GetItem(IDC_COMPRESS_LEVEL));
m_Method.Attach(GetItem(IDC_COMPRESS_METHOD)); m_Method.Attach(GetItem(IDC_COMPRESS_METHOD));
m_Level.Attach(GetItem(IDC_COMPRESS_LEVEL));
m_Dictionary.Attach(GetItem(IDC_COMPRESS_DICTIONARY)); m_Dictionary.Attach(GetItem(IDC_COMPRESS_DICTIONARY));
m_Order.Attach(GetItem(IDC_COMPRESS_ORDER)); m_Order.Attach(GetItem(IDC_COMPRESS_ORDER));
m_Solid.Attach(GetItem(IDC_COMPRESS_SOLID)); m_Solid.Attach(GetItem(IDC_COMPRESS_SOLID));
m_NumThreads.Attach(GetItem(IDC_COMPRESS_THREADS)); m_NumThreads.Attach(GetItem(IDC_COMPRESS_THREADS));
@@ -501,6 +519,8 @@ bool CCompressDialog::OnInit()
StartDirPrefix = DirPrefix; StartDirPrefix = DirPrefix;
SetArchiveName(fileName); SetArchiveName(fileName);
} }
SetMethod();
SetLevel(); SetLevel();
SetParams(); SetParams();
@@ -525,8 +545,6 @@ bool CCompressDialog::OnInit()
CheckControlsEnable(); CheckControlsEnable();
// OnButtonSFX();
SetEncryptionMethod(); SetEncryptionMethod();
SetMemoryUsage(); SetMemoryUsage();
@@ -535,22 +553,6 @@ bool CCompressDialog::OnInit()
return CModalDialog::OnInit(); return CModalDialog::OnInit();
} }
/*
namespace NCompressDialog
{
bool CInfo::GetFullPathName(UString &result) const
{
#ifndef UNDER_CE
// NDirectory::MySetCurrentDirectory(CurrentDirPrefix);
#endif
FString resultF;
bool res = MyGetFullPathName(us2fs(ArchiveName), resultF);
result = fs2us(resultF);
return res;
}
}
*/
void CCompressDialog::UpdatePasswordControl() void CCompressDialog::UpdatePasswordControl()
{ {
bool showPassword = IsShowPasswordChecked(); bool showPassword = IsShowPasswordChecked();
@@ -606,16 +608,6 @@ void CCompressDialog::CheckSFXControlsEnable()
EnableItem(IDX_COMPRESS_SFX, enable); EnableItem(IDX_COMPRESS_SFX, enable);
} }
/*
void CCompressDialog::CheckVolumeEnable()
{
bool isSFX = IsSFX();
m_Volume.Enable(!isSFX);
if (isSFX)
m_Volume.SetText(TEXT(""));
}
*/
void CCompressDialog::CheckControlsEnable() void CCompressDialog::CheckControlsEnable()
{ {
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
@@ -643,7 +635,6 @@ void CCompressDialog::CheckControlsEnable()
|| ai.Flags_AltStreams() || ai.Flags_AltStreams()
|| ai.Flags_NtSecure()); || ai.Flags_NtSecure());
} }
// CheckVolumeEnable();
EnableItem(IDG_COMPRESS_ENCRYPTION, fi.Encrypt); EnableItem(IDG_COMPRESS_ENCRYPTION, fi.Encrypt);
@@ -699,8 +690,6 @@ void CCompressDialog::OnButtonSFX()
} }
SetArchiveName2(false); // it's for OnInit SetArchiveName2(false); // it's for OnInit
} }
// CheckVolumeEnable();
} }
bool CCompressDialog::GetFinalPath_Smart(UString &resPath) bool CCompressDialog::GetFinalPath_Smart(UString &resPath)
@@ -847,7 +836,6 @@ void CCompressDialog::OnOK()
Info.NumThreads = GetNumThreadsSpec(); Info.NumThreads = GetNumThreadsSpec();
{ {
// Info.SolidIsSpecified = g_Formats[GetStaticFormatIndex()].Solid;
UInt32 solidLogSize = GetBlockSizeSpec(); UInt32 solidLogSize = GetBlockSizeSpec();
Info.SolidBlockSize = 0; Info.SolidBlockSize = 0;
if (solidLogSize == (UInt32)(Int32)-1) if (solidLogSize == (UInt32)(Int32)-1)
@@ -868,7 +856,6 @@ void CCompressDialog::OnOK()
m_RegistryInfo.EncryptHeaders = m_RegistryInfo.EncryptHeaders =
Info.EncryptHeaders = IsButtonCheckedBool(IDX_COMPRESS_ENCRYPT_FILE_NAMES); Info.EncryptHeaders = IsButtonCheckedBool(IDX_COMPRESS_ENCRYPT_FILE_NAMES);
GetButton_Bools(IDX_COMPRESS_NT_SYM_LINKS, Info.SymLinks, m_RegistryInfo.SymLinks); GetButton_Bools(IDX_COMPRESS_NT_SYM_LINKS, Info.SymLinks, m_RegistryInfo.SymLinks);
GetButton_Bools(IDX_COMPRESS_NT_HARD_LINKS, Info.HardLinks, m_RegistryInfo.HardLinks); GetButton_Bools(IDX_COMPRESS_NT_HARD_LINKS, Info.HardLinks, m_RegistryInfo.HardLinks);
GetButton_Bools(IDX_COMPRESS_NT_ALT_STREAMS, Info.AltStreams, m_RegistryInfo.AltStreams); GetButton_Bools(IDX_COMPRESS_NT_ALT_STREAMS, Info.AltStreams, m_RegistryInfo.AltStreams);
@@ -883,15 +870,13 @@ void CCompressDialog::OnOK()
} }
m_Params.GetText(Info.Options); m_Params.GetText(Info.Options);
m_Volume.GetText(Info.SplitVolume);
UString volumeString; Info.SplitVolume.Trim();
m_Volume.GetText(volumeString);
volumeString.Trim();
Info.VolumeSizes.Clear(); Info.VolumeSizes.Clear();
if (!volumeString.IsEmpty()) if (!Info.SplitVolume.IsEmpty())
{ {
if (!ParseVolumeSizes(volumeString, Info.VolumeSizes)) if (!ParseVolumeSizes(Info.SplitVolume, Info.VolumeSizes))
{ {
ShowErrorMessageHwndRes(*this, IDS_INCORRECT_VOLUME_SIZE); ShowErrorMessageHwndRes(*this, IDS_INCORRECT_VOLUME_SIZE);
return; return;
@@ -948,29 +933,17 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
// we can 't change m_ArchivePath in that handler ! // we can 't change m_ArchivePath in that handler !
DirPrefix.Empty(); DirPrefix.Empty();
SetItemText(IDT_COMPRESS_ARCHIVE_FOLDER, DirPrefix); SetItemText(IDT_COMPRESS_ARCHIVE_FOLDER, DirPrefix);
/*
UString path;
m_ArchivePath.GetText(path);
m_ArchivePath.SetText(L"");
if (IsAbsolutePath(path))
{
UString fileName;
SetArcPathFields(path, fileName);
SetArchiveName(fileName);
}
*/
return true; return true;
} }
case IDC_COMPRESS_FORMAT: case IDC_COMPRESS_FORMAT:
{ {
//ShowInfo(L"FORMAT level=%d method=%d format=%d", GetLevel(), GetMethodID(), GetFormatIndex());
bool isSFX = IsSFX(); bool isSFX = IsSFX();
SaveOptionsInMem(); SaveOptionsInMem();
m_Solid.ResetContent(); m_Solid.ResetContent();
SetLevel(); SetLevel();
SetMethod(GetMethodID());
SetSolidBlockSize(); SetSolidBlockSize();
SetNumThreads(); SetNumThreads();
SetParams(); SetParams();
@@ -983,13 +956,14 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
case IDC_COMPRESS_LEVEL: case IDC_COMPRESS_LEVEL:
{ {
//ShowInfo(L"LEVEL level=%d method=%d format=%d", GetLevel(), GetMethodID(), GetFormatIndex());
{ {
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormatAlways(ai.Name); int index = FindRegistryFormatAlways(ai.Name);
NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
fo.ResetForLevelChange(); fo.ResetForLevelChange();
} }
SetMethod(GetMethodID());
SetSolidBlockSize(); SetSolidBlockSize();
SetNumThreads(); SetNumThreads();
CheckSFXNameChange(); CheckSFXNameChange();
@@ -999,7 +973,8 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
case IDC_COMPRESS_METHOD: case IDC_COMPRESS_METHOD:
{ {
SetLevel(); //ShowInfo(L"METHOD level=%d method=%d format=%d", GetLevel(), GetMethodID(), GetFormatIndex());
SetMethod(GetMethodID());
SetDictionary(); SetDictionary();
SetOrder(); SetOrder();
SetSolidBlockSize(); SetSolidBlockSize();
@@ -1164,21 +1139,6 @@ void CCompressDialog::SetLevel()
UInt32 langID = 0; UInt32 langID = 0;
unsigned i, ir; unsigned i, ir;
SetMethod(GetMethodID());
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
{
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
{
const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
if (fo.Level <= 49)
level = fo.Level;
else
level = 5;
}
}
m_Level.ResetContent();
if (GetMethodID() == kZSTD) if (GetMethodID() == kZSTD)
LevelsMask = g_Formats[6].LevelsMask; LevelsMask = g_Formats[6].LevelsMask;
else if (GetMethodID() == kBROTLI) else if (GetMethodID() == kBROTLI)
@@ -1206,6 +1166,20 @@ void CCompressDialog::SetLevel()
else else
LevelsMask = g_Formats[GetStaticFormatIndex()].LevelsMask; LevelsMask = g_Formats[GetStaticFormatIndex()].LevelsMask;
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
{
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
{
const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
if (fo.Level <= 49)
level = fo.Level;
else
level = 5;
}
}
m_Level.ResetContent();
for (i = LevelsStart; i <= LevelsEnd; i++) for (i = LevelsStart; i <= LevelsEnd; i++)
{ {
TCHAR s[40]; TCHAR s[40];
@@ -1241,7 +1215,10 @@ void CCompressDialog::SetLevel()
m_Level.SetItemData(index, i); m_Level.SetItemData(index, i);
} }
} }
ShowInfo(L"SetLevel() methodID=%d level=%d start=%d end=%d", GetMethodID(), level, LevelsStart, LevelsEnd);
SetNearestSelectComboBox(m_Level, level); SetNearestSelectComboBox(m_Level, level);
return; return;
} }
@@ -1253,8 +1230,16 @@ static LRESULT ComboBox_AddStringAscii(NControl::CComboBox &cb, const char *s)
void CCompressDialog::SetMethod(int keepMethodId) void CCompressDialog::SetMethod(int keepMethodId)
{ {
m_Method.ResetContent();
UInt32 level = GetLevel2(); UInt32 level = GetLevel2();
int mID = GetMethodID();
static int mID_old = 0;
ShowInfo(L"SetMethod level=%d method=%d methodPrev=%d", GetLevel(), mID, mID_old);
if (mID != mID_old) {
mID_old = mID;
SetLevel();
}
if (level == 0) if (level == 0)
{ {
SetDictionary(); SetDictionary();
@@ -1275,15 +1260,7 @@ void CCompressDialog::SetMethod(int keepMethodId)
bool isSfx = IsSFX(); bool isSfx = IsSFX();
bool weUseSameMethod = false; bool weUseSameMethod = false;
#if 0 m_Method.ResetContent();
{
wchar_t buf[2000];
wsprintf(buf, L"keep=%d level = %d method=%s", keepMethodId, defaultLevel, (LPCWSTR)defaultMethod);
ShowErrorMessage(*this, buf);
}
#endif
for (unsigned m = 0; m < fi.NumMethods; m++) for (unsigned m = 0; m < fi.NumMethods; m++)
{ {
EMethodID methodID = fi.MathodIDs[m]; EMethodID methodID = fi.MathodIDs[m];
@@ -1315,8 +1292,7 @@ void CCompressDialog::SetMethod(int keepMethodId)
} }
} }
// if (!weUseSameMethod) if (!weUseSameMethod) {
{
SetDictionary(); SetDictionary();
SetOrder(); SetOrder();
} }
@@ -2120,6 +2096,7 @@ void CCompressDialog::SetParams()
{ {
const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
m_Params.SetText(fo.Options); m_Params.SetText(fo.Options);
m_Volume.SetText(fo.SplitVolume);
} }
} }
@@ -2128,9 +2105,12 @@ void CCompressDialog::SaveOptionsInMem()
const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex]; const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex];
int index = FindRegistryFormatAlways(ai.Name); int index = FindRegistryFormatAlways(ai.Name);
m_Params.GetText(Info.Options); m_Params.GetText(Info.Options);
m_Volume.GetText(Info.SplitVolume);
Info.Options.Trim(); Info.Options.Trim();
Info.SplitVolume.Trim();
NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
fo.Options = Info.Options; fo.Options = Info.Options;
fo.SplitVolume = Info.SplitVolume;
fo.Level = GetLevelSpec(); fo.Level = GetLevelSpec();
fo.Dictionary = GetDictionarySpec(); fo.Dictionary = GetDictionarySpec();
fo.Order = GetOrderSpec(); fo.Order = GetOrderSpec();

View File

@@ -46,6 +46,7 @@ namespace NCompressDialog
bool OrderMode; bool OrderMode;
UInt32 Order; UInt32 Order;
UString Options; UString Options;
UString SplitVolume;
UString EncryptionMethod; UString EncryptionMethod;
@@ -83,6 +84,7 @@ namespace NCompressDialog
OrderMode = false; OrderMode = false;
Method.Empty(); Method.Empty();
Options.Empty(); Options.Empty();
SplitVolume.Empty();
EncryptionMethod.Empty(); EncryptionMethod.Empty();
} }
}; };

View File

@@ -3,7 +3,7 @@
set ROOT=%cd%\7zip set ROOT=%cd%\7zip
if not defined OUTDIR set OUTDIR=%ROOT%\bin64 if not defined OUTDIR set OUTDIR=%ROOT%\bin64
if not defined ERRFILE set ERRFILE=%cd%\error.txt if not defined ERRFILE set ERRFILE=%cd%\error.txt
if not defined SUBSYS set SUBSYS="5.01" if not defined SUBSYS set SUBSYS="5.02"
mkdir %OUTDIR% mkdir %OUTDIR%
set OPTS=PLATFORM=x64 MY_STATIC_LINK=1 /NOLOGO set OPTS=PLATFORM=x64 MY_STATIC_LINK=1 /NOLOGO