Update to 7-Zip Version 22.00

See: https://sourceforge.net/p/sevenzip/discussion/45797/thread/9c2d9061ce/
This commit is contained in:
Tino Reichardt
2022-08-07 09:59:33 +02:00
parent 6a4fe97fc3
commit 57558682a8
211 changed files with 15251 additions and 2482 deletions

View File

@@ -16,6 +16,7 @@
#include "../FileManager/BrowseDialog.h"
#include "../FileManager/FormatUtils.h"
#include "../FileManager/HelpUtils.h"
#include "../FileManager/PropertyName.h"
#include "../FileManager/SplitUtils.h"
#include "../Explorer/MyMessages.h"
@@ -36,6 +37,9 @@ extern bool g_IsNT;
#include "ExtractRes.h"
#ifdef LANG
// #define IDS_OPTIONS 2100
static const UInt32 kLangIDs[] =
{
IDT_COMPRESS_ARCHIVE,
@@ -49,6 +53,8 @@ static const UInt32 kLangIDs[] =
IDT_COMPRESS_THREADS,
IDT_COMPRESS_PARAMETERS,
IDB_COMPRESS_OPTIONS, // IDS_OPTIONS
IDG_COMPRESS_OPTIONS,
IDX_COMPRESS_SFX,
IDX_COMPRESS_SHARED,
@@ -57,11 +63,6 @@ static const UInt32 kLangIDs[] =
IDT_COMPRESS_MEMORY,
IDT_COMPRESS_MEMORY_DE,
IDX_COMPRESS_NT_SYM_LINKS,
IDX_COMPRESS_NT_HARD_LINKS,
IDX_COMPRESS_NT_ALT_STREAMS,
IDX_COMPRESS_NT_SECUR,
IDG_COMPRESS_ENCRYPTION,
IDT_COMPRESS_ENCRYPTION_METHOD,
IDX_COMPRESS_ENCRYPT_FILE_NAMES,
@@ -71,7 +72,7 @@ static const UInt32 kLangIDs[] =
IDX_PASSWORD_SHOW,
IDT_SPLIT_TO_VOLUMES,
IDT_COMPRESS_PATH_MODE
IDT_COMPRESS_PATH_MODE,
};
#endif
@@ -89,8 +90,6 @@ static const UInt32 kLzmaMaxDictSize = (UInt32)15 << 28;
static LPCSTR const kExeExt = ".exe";
#define k7zFormat "7z"
static const UInt32 g_Levels[] =
{
IDS_METHOD_STORE,
@@ -119,6 +118,8 @@ enum EMethodID
kSha1,
kCrc32,
kCrc64,
kGnu,
kPosix
};
static LPCSTR const kMethodsNames[] =
@@ -135,6 +136,8 @@ static LPCSTR const kMethodsNames[] =
, "SHA1"
, "CRC32"
, "CRC64"
, "GNU"
, "POSIX"
};
static const EMethodID g_7zMethods[] =
@@ -186,6 +189,12 @@ static const EMethodID g_SwfcMethods[] =
// kLZMA
};
static const EMethodID g_TarMethods[] =
{
kGnu,
kPosix
};
static const EMethodID g_HashMethods[] =
{
kSha256
@@ -202,6 +211,13 @@ static const UInt32 kFF_EncryptFileNames = 1 << 4;
static const UInt32 kFF_MemUse = 1 << 5;
static const UInt32 kFF_SFX = 1 << 6;
/*
static const UInt32 kFF_Time_Win = 1 << 10;
static const UInt32 kFF_Time_Unix = 1 << 11;
static const UInt32 kFF_Time_DOS = 1 << 12;
static const UInt32 kFF_Time_1ns = 1 << 13;
*/
struct CFormatInfo
{
LPCSTR Name;
@@ -233,23 +249,26 @@ static const CFormatInfo g_Formats[] =
kFF_MultiThread | kFF_MemUse
},
{
k7zFormat,
"7z",
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_7zMethods),
kFF_Filter | kFF_Solid | kFF_MultiThread | kFF_Encrypt |
kFF_EncryptFileNames | kFF_MemUse | kFF_SFX
// | kFF_Time_Win
},
{
"Zip",
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_ZipMethods),
kFF_MultiThread | kFF_Encrypt | kFF_MemUse
// | kFF_Time_Win | kFF_Time_Unix | kFF_Time_DOS
},
{
"GZip",
(1 << 1) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_GZipMethods),
kFF_MemUse
// | kFF_Time_Unix
},
{
"BZip2",
@@ -272,14 +291,15 @@ static const CFormatInfo g_Formats[] =
{
"Tar",
(1 << 0),
0, NULL,
0
METHODS_PAIR(g_TarMethods),
// kFF_Time_Unix | kFF_Time_Win // | kFF_Time_1ns
},
{
"wim",
(1 << 0),
0, NULL,
0
// | kFF_Time_Win
},
{
"Hash",
@@ -335,22 +355,6 @@ static const UInt32 k_PathMode_IDs[] =
};
void AddComboItems(NControl::CComboBox &combo, const UInt32 *langIDs, unsigned numItems, const int *values, int curVal);
bool GetBoolsVal(const CBoolPair &b1, const CBoolPair &b2);
void CCompressDialog::CheckButton_TwoBools(UINT id, const CBoolPair &b1, const CBoolPair &b2)
{
CheckButton(id, GetBoolsVal(b1, b2));
}
void CCompressDialog::GetButton_Bools(UINT id, CBoolPair &b1, CBoolPair &b2)
{
bool val = IsButtonCheckedBool(id);
bool oldVal = GetBoolsVal(b1, b2);
if (val != oldVal)
b1.Def = b2.Def = true;
b1.Val = b2.Val = val;
}
void CCompressDialog::SetMethods(const CObjectVector<CCodecInfoUser> &userCodecs)
{
@@ -375,12 +379,13 @@ void CCompressDialog::SetMethods(const CObjectVector<CCodecInfoUser> &userCodecs
}
}
bool CCompressDialog::OnInit()
{
#ifdef LANG
LangSetWindowText(*this, IDD_COMPRESS);
LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));
// LangSetDlgItemText(*this, IDB_COMPRESS_OPTIONS, IDS_OPTIONS); // IDG_COMPRESS_OPTIONS
#endif
{
@@ -435,11 +440,6 @@ bool CCompressDialog::OnInit()
CheckButton(IDX_PASSWORD_SHOW, m_RegistryInfo.ShowPassword);
CheckButton(IDX_COMPRESS_ENCRYPT_FILE_NAMES, m_RegistryInfo.EncryptHeaders);
CheckButton_TwoBools(IDX_COMPRESS_NT_SYM_LINKS, Info.SymLinks, m_RegistryInfo.SymLinks);
CheckButton_TwoBools(IDX_COMPRESS_NT_HARD_LINKS, Info.HardLinks, m_RegistryInfo.HardLinks);
CheckButton_TwoBools(IDX_COMPRESS_NT_ALT_STREAMS, Info.AltStreams, m_RegistryInfo.AltStreams);
CheckButton_TwoBools(IDX_COMPRESS_NT_SECUR, Info.NtSecurity, m_RegistryInfo.NtSecurity);
UpdatePasswordControl();
{
@@ -490,7 +490,7 @@ bool CCompressDialog::OnInit()
CheckButton(IDX_COMPRESS_SHARED, Info.OpenShareForWrite);
CheckButton(IDX_COMPRESS_DEL, Info.DeleteAfterCompressing);
FormatChanged();
FormatChanged(false); // isChanged
// OnButtonSFX();
@@ -552,6 +552,13 @@ bool CCompressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
UpdatePasswordControl();
return true;
}
case IDB_COMPRESS_OPTIONS:
{
COptionsDialog dialog(this);
if (dialog.Create(*this) == IDOK)
ShowOptionsString();
return true;
}
}
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
@@ -588,8 +595,44 @@ void CCompressDialog::EnableMultiCombo(unsigned id)
EnableItem(id, enable);
}
static LRESULT ComboBox_AddStringAscii(NControl::CComboBox &cb, const char *s);
static void FormatOptions_To_String(const NCompression::CFormatOptions &fo, AString &s);
void CCompressDialog::FormatChanged()
static void Combine_Two_BoolPairs(const CBoolPair &b1, const CBoolPair &b2, CBool1 &res)
{
if (!b1.Def && b2.Def)
res.Val = b2.Val;
else
res.Val = b1.Val;
}
#define SET_GUI_BOOL(name) \
Combine_Two_BoolPairs(Info. ## name, m_RegistryInfo. ## name, name)
static void Set_Final_BoolPairs(
const CBool1 &gui,
CBoolPair &cmd,
CBoolPair &reg)
{
if (!cmd.Def)
{
reg.Val = gui.Val;
reg.Def = gui.Val;
}
if (gui.Supported)
{
cmd.Val = gui.Val;
cmd.Def = gui.Val;
}
else
cmd.Init();
}
#define SET_FINAL_BOOL_PAIRS(name) \
Set_Final_BoolPairs(name, Info. ## name, m_RegistryInfo. ## name)
void CCompressDialog::FormatChanged(bool isChanged)
{
SetLevel();
SetSolidBlockSize();
@@ -615,18 +658,26 @@ void CCompressDialog::FormatChanged()
CheckSFXControlsEnable();
{
const CArcInfoEx &ai = Get_ArcInfoEx();
ShowItem_Bool(IDX_COMPRESS_NT_SYM_LINKS, ai.Flags_SymLinks());
ShowItem_Bool(IDX_COMPRESS_NT_HARD_LINKS, ai.Flags_HardLinks());
ShowItem_Bool(IDX_COMPRESS_NT_ALT_STREAMS, ai.Flags_AltStreams());
ShowItem_Bool(IDX_COMPRESS_NT_SECUR, ai.Flags_NtSecure());
if (!isChanged)
{
SET_GUI_BOOL (SymLinks);
SET_GUI_BOOL (HardLinks);
SET_GUI_BOOL (AltStreams);
SET_GUI_BOOL (NtSecurity);
SET_GUI_BOOL (PreserveATime);
}
ShowItem_Bool(IDG_COMPRESS_NTFS,
ai.Flags_SymLinks()
|| ai.Flags_HardLinks()
|| ai.Flags_AltStreams()
|| ai.Flags_NtSecure());
PreserveATime.Supported = true;
{
const CArcInfoEx &ai = Get_ArcInfoEx();
SymLinks.Supported = ai.Flags_SymLinks();
HardLinks.Supported = ai.Flags_HardLinks();
AltStreams.Supported = ai.Flags_AltStreams();
NtSecurity.Supported = ai.Flags_NtSecurity();
}
ShowOptionsString();
}
// CheckVolumeEnable();
@@ -821,7 +872,7 @@ void SetErrorMessage_MemUsage(UString &s, UInt64 reqSize, UInt64 ramSize, UInt64
s.Add_LF();
s.Add_LF();
s += LangString(IDS_MEM_ERROR);
AddLangString(s, IDS_MEM_ERROR);
}
@@ -933,17 +984,32 @@ void CCompressDialog::OnOK()
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_HARD_LINKS, Info.HardLinks, m_RegistryInfo.HardLinks);
GetButton_Bools(IDX_COMPRESS_NT_ALT_STREAMS, Info.AltStreams, m_RegistryInfo.AltStreams);
GetButton_Bools(IDX_COMPRESS_NT_SECUR, Info.NtSecurity, m_RegistryInfo.NtSecurity);
/* (Info) is for saving to registry:
(CBoolPair::Val) will be set as (false), if it was (false)
in registry at dialog creation, and user didn't click checkbox.
in another case (CBoolPair::Val) will be set as (true) */
{
const CArcInfoEx &ai = Get_ArcInfoEx();
if (!ai.Flags_SymLinks()) Info.SymLinks.Val = false;
if (!ai.Flags_HardLinks()) Info.HardLinks.Val = false;
if (!ai.Flags_AltStreams()) Info.AltStreams.Val = false;
if (!ai.Flags_NtSecure()) Info.NtSecurity.Val = false;
/* Info properties could be for another archive types.
so we disable unsupported properties in Info */
// const CArcInfoEx &ai = Get_ArcInfoEx();
SET_FINAL_BOOL_PAIRS (SymLinks);
SET_FINAL_BOOL_PAIRS (HardLinks);
SET_FINAL_BOOL_PAIRS (AltStreams);
SET_FINAL_BOOL_PAIRS (NtSecurity);
SET_FINAL_BOOL_PAIRS (PreserveATime);
}
{
const NCompression::CFormatOptions &fo = Get_FormatOptions();
Info.TimePrec = fo.TimePrec;
Info.MTime = fo.MTime;
Info.CTime = fo.CTime;
Info.ATime = fo.ATime;
Info.SetArcMTime = fo.SetArcMTime;
}
m_Params.GetText(Info.Options);
@@ -1031,7 +1097,7 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
{
const bool isSFX = IsSFX();
SaveOptionsInMem();
FormatChanged();
FormatChanged(true); // isChanged
SetArchiveName2(isSFX);
return true;
}
@@ -1057,6 +1123,7 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
SetMemoryUsage();
if (Get_ArcInfoEx().Flags_HashHandler())
SetArchiveName2(false);
return true;
}
@@ -1188,6 +1255,7 @@ void CCompressDialog::SetArchiveName(const UString &name)
m_ArchivePath.SetText(fileName);
}
int CCompressDialog::FindRegistryFormat(const UString &name)
{
FOR_VECTOR (i, m_RegistryInfo.Formats)
@@ -1199,7 +1267,8 @@ int CCompressDialog::FindRegistryFormat(const UString &name)
return -1;
}
int CCompressDialog::FindRegistryFormatAlways(const UString &name)
unsigned CCompressDialog::FindRegistryFormat_Always(const UString &name)
{
int index = FindRegistryFormat(name);
if (index < 0)
@@ -1211,6 +1280,14 @@ int CCompressDialog::FindRegistryFormatAlways(const UString &name)
return index;
}
NCompression::CFormatOptions &CCompressDialog::Get_FormatOptions()
{
const CArcInfoEx &ai = Get_ArcInfoEx();
return m_RegistryInfo.Formats[FindRegistryFormat_Always(ai.Name)];
}
int CCompressDialog::GetStaticFormatIndex()
{
const CArcInfoEx &ai = Get_ArcInfoEx();
@@ -1293,8 +1370,11 @@ void CCompressDialog::SetMethod2(int keepMethodId)
const CArcInfoEx &ai = Get_ArcInfoEx();
if (GetLevel() == 0 && !ai.Flags_HashHandler())
{
MethodChanged();
return;
if (!ai.Is_Tar())
{
MethodChanged();
return;
}
}
UString defaultMethod;
{
@@ -1308,7 +1388,7 @@ void CCompressDialog::SetMethod2(int keepMethodId)
const bool isSfx = IsSFX();
bool weUseSameMethod = false;
const bool is7z = ai.Name.IsEqualTo_Ascii_NoCase("7z");
const bool is7z = ai.Is_7z();
for (unsigned m = 0;; m++)
{
@@ -1367,12 +1447,12 @@ void CCompressDialog::SetMethod2(int keepMethodId)
bool CCompressDialog::IsZipFormat()
{
return Get_ArcInfoEx().Name.IsEqualTo_Ascii_NoCase("zip");
return Get_ArcInfoEx().Is_Zip();
}
bool CCompressDialog::IsXzFormat()
{
return Get_ArcInfoEx().Name.IsEqualTo_Ascii_NoCase("xz");
return Get_ArcInfoEx().Is_Xz();
}
void CCompressDialog::SetEncryptionMethod()
@@ -1380,13 +1460,13 @@ void CCompressDialog::SetEncryptionMethod()
_encryptionMethod.ResetContent();
_default_encryptionMethod_Index = -1;
const CArcInfoEx &ai = Get_ArcInfoEx();
if (ai.Name.IsEqualTo_Ascii_NoCase("7z"))
if (ai.Is_7z())
{
ComboBox_AddStringAscii(_encryptionMethod, "AES-256");
_encryptionMethod.SetCurSel(0);
_default_encryptionMethod_Index = 0;
}
else if (ai.Name.IsEqualTo_Ascii_NoCase("zip"))
else if (ai.Is_Zip())
{
int index = FindRegistryFormat(ai.Name);
UString encryptionMethod;
@@ -1929,7 +2009,7 @@ void CCompressDialog::SetSolidBlockSize2()
}
}
const bool is7z = ai.Name.IsEqualTo_Ascii_NoCase("7z");
const bool is7z = ai.Is_7z();
const UInt64 cs = Get_Lzma2_ChunkSize(dict);
@@ -2549,11 +2629,16 @@ void CCompressDialog::SetParams()
void CCompressDialog::SaveOptionsInMem()
{
/* these options are for (Info.FormatIndex).
If it's called just after format changing,
then it's format that was selected before format changing
So we store previous format properties */
m_Params.GetText(Info.Options);
Info.Options.Trim();
const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex];
const int index = FindRegistryFormatAlways(ai.Name);
const unsigned index = FindRegistryFormat_Always(ai.Name);
NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
fo.Options = Info.Options;
fo.Level = GetLevelSpec();
@@ -2587,7 +2672,512 @@ void CCompressDialog::SaveOptionsInMem()
fo.MemUse = Get_MemUse_Spec();
}
unsigned CCompressDialog::GetFormatIndex()
{
return (unsigned)m_Format.GetItemData_of_CurSel();
}
static void AddText_from_BoolPair(AString &s, const char *name, const CBoolPair &bp)
{
if (bp.Def)
{
s.Add_OptSpaced(name);
if (!bp.Val)
s += "-";
}
/*
else if (bp.Val)
{
s.Add_OptSpaced("[");
s += name;
s += "]";
}
*/
}
static void AddText_from_Bool1(AString &s, const char *name, const CBool1 &b)
{
if (b.Supported && b.Val)
s.Add_OptSpaced(name);
}
void CCompressDialog::ShowOptionsString()
{
NCompression::CFormatOptions &fo = Get_FormatOptions();
AString s;
if (fo.TimePrec != -1)
{
s.Add_OptSpaced("tp");
s.Add_UInt32(fo.TimePrec);
}
AddText_from_BoolPair(s, "tm", fo.MTime);
AddText_from_BoolPair(s, "tc", fo.CTime);
AddText_from_BoolPair(s, "ta", fo.ATime);
AddText_from_BoolPair(s, "-stl", fo.SetArcMTime);
// const CArcInfoEx &ai = Get_ArcInfoEx();
AddText_from_Bool1(s, "SL", SymLinks);
AddText_from_Bool1(s, "HL", HardLinks);
AddText_from_Bool1(s, "AS", AltStreams);
AddText_from_Bool1(s, "Sec", NtSecurity);
// AddText_from_Bool1(s, "Preserve", PreserveATime);
SetItemText(IDT_COMPRESS_OPTIONS, GetUnicodeString(s));
}
// ---------- OPTIONS ----------
void COptionsDialog::CheckButton_Bool1(UINT id, const CBool1 &b1)
{
CheckButton(id, b1.Val);
}
void COptionsDialog::GetButton_Bool1(UINT id, CBool1 &b1)
{
b1.Val = IsButtonCheckedBool(id);
}
void COptionsDialog::CheckButton_BoolBox(
bool supported, const CBoolPair &b2, CBoolBox &bb)
{
const bool isSet = b2.Def;
const bool val = isSet ? b2.Val : bb.DefaultVal;
bb.IsSupported = supported;
CheckButton (bb.Set_Id, isSet);
ShowItem_Bool (bb.Set_Id, supported);
CheckButton (bb.Id, val);
EnableItem (bb.Id, isSet);
ShowItem_Bool (bb.Id, supported);
}
void COptionsDialog::GetButton_BoolBox(CBoolBox &bb)
{
// we save value for invisible buttons too
bb.BoolPair.Val = IsButtonCheckedBool (bb.Id);
bb.BoolPair.Def = IsButtonCheckedBool (bb.Set_Id);
}
void COptionsDialog::Store_TimeBoxes()
{
TimePrec = GetPrecSpec();
GetButton_BoolBox (MTime);
GetButton_BoolBox (CTime);
GetButton_BoolBox (ATime);
GetButton_BoolBox (ZTime);
}
UInt32 COptionsDialog::GetComboValue(NWindows::NControl::CComboBox &c, int defMax)
{
if (c.GetCount() <= defMax)
return (UInt32)(Int32)-1;
return (UInt32)c.GetItemData_of_CurSel();
}
static const unsigned kTimePrec_Win = 0;
static const unsigned kTimePrec_Unix = 1;
static const unsigned kTimePrec_DOS = 2;
static const unsigned kTimePrec_1ns = 3;
static void AddTimeOption(UString &s, UInt32 val, const UString &unit, const char *sys = NULL)
{
// s += " : ";
{
AString s2;
s2.Add_UInt32(val);
s += s2;
}
s.Add_Space();
s += unit;
if (sys)
{
s += " : ";
s += sys;
}
}
int COptionsDialog::AddPrec(unsigned prec, bool isDefault)
{
UString s;
UInt32 writePrec = prec;
if (isDefault)
{
// s += "* ";
// writePrec = (UInt32)(Int32)-1;
}
if (prec == kTimePrec_Win) AddTimeOption(s, 100, NsString, "Windows");
else if (prec == kTimePrec_Unix) AddTimeOption(s, 1, SecString, "Unix");
else if (prec == kTimePrec_DOS) AddTimeOption(s, 2, SecString, "DOS");
else if (prec == kTimePrec_1ns) AddTimeOption(s, 1, NsString, "Linux");
else if (prec == k_PropVar_TimePrec_Base) AddTimeOption(s, 1, SecString);
else if (prec >= k_PropVar_TimePrec_Base)
{
UInt32 d = 1;
for (unsigned i = prec; i < k_PropVar_TimePrec_Base + 9; i++)
d *= 10;
AddTimeOption(s, d, NsString);
}
else
s.Add_UInt32(prec);
const int index = (int)m_Prec.AddString(s);
m_Prec.SetItemData(index, writePrec);
return index;
}
void COptionsDialog::SetPrec()
{
// const CFormatInfo &fi = g_Formats[cd->GetStaticFormatIndex()];
const CArcInfoEx &ai = cd->Get_ArcInfoEx();
// UInt32 flags = fi.Flags;
UInt32 flags = ai.Get_TimePrecFlags();
UInt32 defaultPrec = ai.Get_DefaultTimePrec();
if (defaultPrec != 0)
flags |= ((UInt32)1 << defaultPrec);
// const NCompression::CFormatOptions &fo = cd->Get_FormatOptions();
// unsigned defaultPrec = kTimePrec_Win;
if (ai.Is_GZip())
defaultPrec = kTimePrec_Unix;
{
UString s;
s += GetNameOfProperty(kpidType, L"type");
s += ": ";
s += ai.Name;
if (ai.Is_Tar())
{
const int methodID = cd->GetMethodID();
// for debug
// defaultPrec = kTimePrec_Unix;
// flags = (UInt32)1 << kTimePrec_Unix;
s += ":";
if (methodID >= 0 && (unsigned)methodID < ARRAY_SIZE(kMethodsNames))
s += kMethodsNames[methodID];
if (methodID == kPosix)
{
// for debug
// flags |= (UInt32)1 << kTimePrec_Win;
// flags |= (UInt32)1 << kTimePrec_1ns;
}
}
else
{
// if (is_for_MethodChanging) return;
}
SetItemText(IDT_COMPRESS_TIME_INFO, s);
}
m_Prec.ResetContent();
_auto_Prec = defaultPrec;
unsigned selectedPrec = defaultPrec;
{
// if (TimePrec >= kTimePrec_Win && TimePrec <= kTimePrec_DOS)
if ((Int32)TimePrec >= 0)
selectedPrec = TimePrec;
}
int curSel = -1;
int defaultPrecIndex = -1;
for (unsigned prec = 0;
// prec <= k_PropVar_TimePrec_HighPrec;
prec <= k_PropVar_TimePrec_1ns;
prec++)
{
if (((flags >> prec) & 1) == 0)
continue;
const bool isDefault = (defaultPrec == prec);
const int index = AddPrec(prec, isDefault);
if (isDefault)
defaultPrecIndex = index;
if (selectedPrec == prec)
curSel = index;
}
if (curSel < 0 && selectedPrec > kTimePrec_DOS)
curSel = AddPrec(selectedPrec, false); // isDefault
if (curSel < 0)
curSel = defaultPrecIndex;
if (curSel >= 0)
m_Prec.SetCurSel(curSel);
{
const bool isSet = IsSet_TimePrec();
const int count = m_Prec.GetCount();
const bool showPrec = (count != 0);
ShowItem_Bool(IDC_COMPRESS_TIME_PREC, showPrec);
ShowItem_Bool(IDT_COMPRESS_TIME_PREC, showPrec);
EnableItem(IDC_COMPRESS_TIME_PREC, isSet && (count > 1));
CheckButton(IDX_COMPRESS_PREC_SET, isSet);
const bool setIsSupported = isSet || (count > 1);
EnableItem(IDX_COMPRESS_PREC_SET, setIsSupported);
ShowItem_Bool(IDX_COMPRESS_PREC_SET, setIsSupported);
}
SetTimeMAC();
}
void COptionsDialog::SetTimeMAC()
{
const CArcInfoEx &ai = cd->Get_ArcInfoEx();
const
bool m_allow = ai.Flags_MTime();
bool c_allow = ai.Flags_CTime();
bool a_allow = ai.Flags_ATime();
if (ai.Is_Tar())
{
const int methodID = cd->GetMethodID();
c_allow = false;
a_allow = false;
if (methodID == kPosix)
{
// c_allow = true; // do we need it as change time ?
a_allow = true;
}
}
if (ai.Is_Zip())
{
// const int methodID = GetMethodID();
UInt32 prec = GetPrec();
if (prec == (UInt32)(Int32)-1)
prec = _auto_Prec;
if (prec != kTimePrec_Win)
{
c_allow = false;
a_allow = false;
}
}
/*
MTime.DefaultVal = true;
CTime.DefaultVal = false;
ATime.DefaultVal = false;
*/
MTime.DefaultVal = ai.Flags_MTime_Default();
CTime.DefaultVal = ai.Flags_CTime_Default();
ATime.DefaultVal = ai.Flags_ATime_Default();
ZTime.DefaultVal = false;
const NCompression::CFormatOptions &fo = cd->Get_FormatOptions();
CheckButton_BoolBox (m_allow, fo.MTime, MTime );
CheckButton_BoolBox (c_allow, fo.CTime, CTime );
CheckButton_BoolBox (a_allow, fo.ATime, ATime );
CheckButton_BoolBox (true, fo.SetArcMTime, ZTime);
if (m_allow && !fo.MTime.Def)
{
const bool isSingleFile = ai.Flags_KeepName();
if (!isSingleFile)
{
// we can hide changing checkboxes for MTime here:
ShowItem_Bool (MTime.Set_Id, false);
EnableItem (MTime.Id, false);
}
}
// On_CheckBoxSet_Prec_Clicked();
// const bool isSingleFile = ai.Flags_KeepName();
// mtime for Gz can be
}
void COptionsDialog::On_CheckBoxSet_Prec_Clicked()
{
const bool isSet = IsButtonCheckedBool(IDX_COMPRESS_PREC_SET);
if (!isSet)
{
// We save current MAC boxes to memory before SetPrec()
Store_TimeBoxes();
Reset_TimePrec();
SetPrec();
}
EnableItem(IDC_COMPRESS_TIME_PREC, isSet);
}
void COptionsDialog::On_CheckBoxSet_Clicked(const CBoolBox &bb)
{
const bool isSet = IsButtonCheckedBool(bb.Set_Id);
if (!isSet)
CheckButton(bb.Id, bb.DefaultVal);
EnableItem(bb.Id, isSet);
}
#ifdef LANG
static const UInt32 kLangIDs_Options[] =
{
IDX_COMPRESS_NT_SYM_LINKS,
IDX_COMPRESS_NT_HARD_LINKS,
IDX_COMPRESS_NT_ALT_STREAMS,
IDX_COMPRESS_NT_SECUR,
IDG_COMPRESS_TIME,
IDT_COMPRESS_TIME_PREC,
IDX_COMPRESS_MTIME,
IDX_COMPRESS_CTIME,
IDX_COMPRESS_ATIME,
IDX_COMPRESS_ZTIME,
IDX_COMPRESS_PRESERVE_ATIME
};
#endif
bool COptionsDialog::OnInit()
{
#ifdef LANG
LangSetWindowText(*this, IDB_COMPRESS_OPTIONS); // IDS_OPTIONS
LangSetDlgItems(*this, kLangIDs_Options, ARRAY_SIZE(kLangIDs_Options));
// LangSetDlgItemText(*this, IDB_COMPRESS_TIME_DEFAULT, IDB_COMPRESS_TIME_DEFAULT);
// LangSetDlgItemText(*this, IDX_COMPRESS_TIME_DEFAULT, IDX_COMPRESS_TIME_DEFAULT);
#endif
LangString(IDS_COMPRESS_SEC, SecString);
if (SecString.IsEmpty())
SecString = "sec";
LangString(IDS_COMPRESS_NS, NsString);
if (NsString.IsEmpty())
NsString = "ns";
{
// const CArcInfoEx &ai = cd->Get_ArcInfoEx();
ShowItem_Bool ( IDX_COMPRESS_NT_SYM_LINKS, cd->SymLinks.Supported);
ShowItem_Bool ( IDX_COMPRESS_NT_HARD_LINKS, cd->HardLinks.Supported);
ShowItem_Bool ( IDX_COMPRESS_NT_ALT_STREAMS, cd->AltStreams.Supported);
ShowItem_Bool ( IDX_COMPRESS_NT_SECUR, cd->NtSecurity.Supported);
ShowItem_Bool ( IDG_COMPRESS_NTFS,
cd->SymLinks.Supported
|| cd->HardLinks.Supported
|| cd->AltStreams.Supported
|| cd->NtSecurity.Supported);
}
/* we read property from two sources:
1) command line : (Info)
2) registry : (m_RegistryInfo)
(Info) has priority, if both are no defined */
CheckButton_Bool1 ( IDX_COMPRESS_NT_SYM_LINKS, cd->SymLinks);
CheckButton_Bool1 ( IDX_COMPRESS_NT_HARD_LINKS, cd->HardLinks);
CheckButton_Bool1 ( IDX_COMPRESS_NT_ALT_STREAMS, cd->AltStreams);
CheckButton_Bool1 ( IDX_COMPRESS_NT_SECUR, cd->NtSecurity);
CheckButton_Bool1 (IDX_COMPRESS_PRESERVE_ATIME, cd->PreserveATime);
m_Prec.Attach (GetItem(IDC_COMPRESS_TIME_PREC));
MTime.SetIDs ( IDX_COMPRESS_MTIME, IDX_COMPRESS_MTIME_SET);
CTime.SetIDs ( IDX_COMPRESS_CTIME, IDX_COMPRESS_CTIME_SET);
ATime.SetIDs ( IDX_COMPRESS_ATIME, IDX_COMPRESS_ATIME_SET);
ZTime.SetIDs ( IDX_COMPRESS_ZTIME, IDX_COMPRESS_ZTIME_SET);
{
const NCompression::CFormatOptions &fo = cd->Get_FormatOptions();
TimePrec = fo.TimePrec;
MTime.BoolPair = fo.MTime;
CTime.BoolPair = fo.CTime;
ATime.BoolPair = fo.ATime;
ZTime.BoolPair = fo.SetArcMTime;
}
SetPrec();
NormalizePosition();
return CModalDialog::OnInit();
}
bool COptionsDialog::OnCommand(int code, int itemID, LPARAM lParam)
{
if (code == CBN_SELCHANGE)
{
switch (itemID)
{
case IDC_COMPRESS_TIME_PREC:
{
Store_TimeBoxes();
SetTimeMAC(); // for zip/tar
return true;
}
}
}
return CModalDialog::OnCommand(code, itemID, lParam);
}
bool COptionsDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
{
switch (buttonID)
{
case IDX_COMPRESS_PREC_SET: { On_CheckBoxSet_Prec_Clicked(); return true; }
case IDX_COMPRESS_MTIME_SET: { On_CheckBoxSet_Clicked (MTime); return true; }
case IDX_COMPRESS_CTIME_SET: { On_CheckBoxSet_Clicked (CTime); return true; }
case IDX_COMPRESS_ATIME_SET: { On_CheckBoxSet_Clicked (ATime); return true; }
case IDX_COMPRESS_ZTIME_SET: { On_CheckBoxSet_Clicked (ZTime); return true; }
}
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
void COptionsDialog::OnOK()
{
GetButton_Bool1 (IDX_COMPRESS_NT_SYM_LINKS, cd->SymLinks);
GetButton_Bool1 (IDX_COMPRESS_NT_HARD_LINKS, cd->HardLinks);
GetButton_Bool1 (IDX_COMPRESS_NT_ALT_STREAMS, cd->AltStreams);
GetButton_Bool1 (IDX_COMPRESS_NT_SECUR, cd->NtSecurity);
GetButton_Bool1 (IDX_COMPRESS_PRESERVE_ATIME, cd->PreserveATime);
Store_TimeBoxes();
{
NCompression::CFormatOptions &fo = cd->Get_FormatOptions();
fo.TimePrec = TimePrec;
fo.MTime = MTime.BoolPair;
fo.CTime = CTime.BoolPair;
fo.ATime = ATime.BoolPair;
fo.SetArcMTime = ZTime.BoolPair;
}
CModalDialog::OnOK();
}
void COptionsDialog::OnHelp()
{
ShowHelpWindow(kHelpTopic);
}

View File

@@ -60,6 +60,14 @@ namespace NCompressDialog
CBoolPair HardLinks;
CBoolPair AltStreams;
CBoolPair NtSecurity;
CBoolPair PreserveATime;
UInt32 TimePrec;
CBoolPair MTime;
CBoolPair CTime;
CBoolPair ATime;
CBoolPair SetArcMTime;
UString ArcPath; // in: Relative or abs ; out: Relative or abs
@@ -91,11 +99,46 @@ namespace NCompressDialog
Options.Empty();
SplitVolume.Empty();
EncryptionMethod.Empty();
TimePrec = (UInt32)(Int32)(-1);
}
};
}
struct CBool1
{
bool Val;
bool Supported;
CBool1(): Val(false), Supported(false) {}
void Init()
{
Val = false;
Supported = false;
}
void SetTrueTrue()
{
Val = true;
Supported = true;
}
void SetVal_as_Supported(bool val)
{
Val = val;
Supported = true;
}
/*
bool IsVal_True_and_Defined() const
{
return Def && Val;
}
*/
};
class CCompressDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox m_ArchivePath;
@@ -128,8 +171,6 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
int _default_encryptionMethod_Index;
NCompression::CInfo m_RegistryInfo;
int m_PrevFormat;
UString DirPrefix;
UString StartDirPrefix;
@@ -139,23 +180,25 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
UInt64 _ramSize_Reduced; // full for 64-bit and reduced for 32-bit
UInt64 _ramUsage_Auto;
void CheckButton_TwoBools(UINT id, const CBoolPair &b1, const CBoolPair &b2);
void GetButton_Bools(UINT id, CBoolPair &b1, CBoolPair &b2);
public:
NCompression::CInfo m_RegistryInfo;
CBool1 SymLinks;
CBool1 HardLinks;
CBool1 AltStreams;
CBool1 NtSecurity;
CBool1 PreserveATime;
void SetArchiveName(const UString &name);
int FindRegistryFormat(const UString &name);
int FindRegistryFormatAlways(const UString &name);
unsigned FindRegistryFormat_Always(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) ];
}
NCompression::CFormatOptions &Get_FormatOptions();
void CheckSFXNameChange();
void SetArchiveName2(bool prevWasSFX);
@@ -239,6 +282,12 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
UInt32 GetBlockSizeSpec() { return GetComboValue(m_Solid, 1); }
/*
UInt32 GetPrecSpec() { return GetComboValue(m_Prec, 1); }
UInt32 GetPrec() { return GetComboValue(m_Prec, 0); }
*/
int AddOrder(UInt32 size);
int AddOrder_Auto();
@@ -273,6 +322,7 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void PrintMemUsage(UINT res, UInt64 value);
void SetMemoryUsage();
void SetParams();
void SaveOptionsInMem();
void UpdatePasswordControl();
@@ -285,7 +335,7 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void CheckSFXControlsEnable();
// void CheckVolumeEnable();
void EnableMultiCombo(unsigned id);
void FormatChanged();
void FormatChanged(bool isChanged);
void OnButtonSetArchive();
bool IsSFX();
@@ -302,6 +352,8 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
MessageBoxW(*this, message, L"7-Zip", MB_ICONERROR);
}
void ShowOptionsString();
public:
const CObjectVector<CArcInfoEx> *ArcFormats;
CUIntVector ArcIndices; // can not be empty, must contain Info.FormatIndex, if Info.FormatIndex >= 0
@@ -315,11 +367,103 @@ public:
INT_PTR Create(HWND wndParent = 0)
{
BIG_DIALOG_SIZE(400, 304);
BIG_DIALOG_SIZE(400, 320);
return CModalDialog::Create(SIZED_DIALOG(IDD_COMPRESS), wndParent);
}
CCompressDialog(): CurrentDirWasChanged(false) {};
};
class COptionsDialog: public NWindows::NControl::CModalDialog
{
struct CBoolBox
{
bool IsSupported;
bool DefaultVal;
CBoolPair BoolPair;
int Id;
int Set_Id;
void SetIDs(int id, int set_Id)
{
Id = id;
Set_Id = set_Id;
}
CBoolBox():
IsSupported(false),
DefaultVal(false)
{}
};
CCompressDialog *cd;
NWindows::NControl::CComboBox m_Prec;
UInt32 _auto_Prec;
UInt32 TimePrec;
void Reset_TimePrec() { TimePrec = (UInt32)(Int32)-1; }
bool IsSet_TimePrec() const { return TimePrec != (UInt32)(Int32)-1; }
CBoolBox MTime;
CBoolBox CTime;
CBoolBox ATime;
CBoolBox ZTime;
UString SecString;
UString NsString;
void CheckButton_Bool1(UINT id, const CBool1 &b1);
void GetButton_Bool1(UINT id, CBool1 &b1);
void CheckButton_BoolBox(bool supported, const CBoolPair &b2, CBoolBox &bb);
void GetButton_BoolBox(CBoolBox &bb);
void Store_TimeBoxes();
UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);
UInt32 GetPrecSpec()
{
UInt32 prec = GetComboValue(m_Prec, 1);
if (prec == _auto_Prec)
prec = (UInt32)(Int32)-1;
return prec;
}
UInt32 GetPrec() { return GetComboValue(m_Prec, 0); }
// void OnButton_TimeDefault();
int AddPrec(unsigned prec, bool isDefault);
void SetPrec();
void SetTimeMAC();
void On_CheckBoxSet_Prec_Clicked();
void On_CheckBoxSet_Clicked(const CBoolBox &bb);
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();
public:
INT_PTR Create(HWND wndParent = 0)
{
BIG_DIALOG_SIZE(240, 232);
return CModalDialog::Create(SIZED_DIALOG(IDD_COMPRESS_OPTIONS), wndParent);
}
COptionsDialog(CCompressDialog *cdLoc):
cd(cdLoc)
// , TimePrec(0)
{
Reset_TimePrec();
};
};
#endif

View File

@@ -2,7 +2,7 @@
#include "../../GuiCommon.rc"
#define xc 400
#define yc 354
#define yc 320
#undef gSize
#undef gSpace
@@ -20,10 +20,6 @@
#define gSize 192
#define gSpace 24
#define ntSize2 168
#define ntSizeX (ntSize2 - m - m)
#define ntPosX m + m
#define ntPosY 292
#define g1xs 88
#define g0xs (gSize - g1xs)
@@ -99,18 +95,9 @@ BEGIN
LTEXT "Parameters:", IDT_COMPRESS_PARAMETERS, m, 256, gSize, 8
EDITTEXT IDE_COMPRESS_PARAMETERS, m, 268, gSize, 14, ES_AUTOHSCROLL
GROUPBOX "NTFS", IDG_COMPRESS_NTFS, m, ntPosY, ntSize2, 68
CONTROL "Store symbolic links", IDX_COMPRESS_NT_SYM_LINKS, MY_CHECKBOX,
ntPosX, ntPosY + 12, ntSizeX, 10
CONTROL "Store hard links", IDX_COMPRESS_NT_HARD_LINKS, MY_CHECKBOX,
ntPosX, ntPosY + 26, ntSizeX, 10
CONTROL "Store alternate data streams", IDX_COMPRESS_NT_ALT_STREAMS, MY_CHECKBOX,
ntPosX, ntPosY + 40, ntSizeX, 10
CONTROL "Store file security", IDX_COMPRESS_NT_SECUR, MY_CHECKBOX,
ntPosX, ntPosY + 54, ntSizeX, 10
PUSHBUTTON "Options", IDB_COMPRESS_OPTIONS, m, 292, bxs, bys
LTEXT "", IDT_COMPRESS_OPTIONS, m + bxs + m, 294, gSize - bxs - m, 16, SS_NOPREFIX
LTEXT "&Update mode:", IDT_COMPRESS_UPDATE_MODE, g4x, 41, 80, 8
COMBOBOX IDC_COMPRESS_UPDATE_MODE, g4x + 84, 39, g4xs - 84, 80, MY_COMBO
@@ -225,4 +212,10 @@ BEGIN
IDS_COMPRESS_SOLID "Solid"
IDS_SPLIT_CONFIRM "Specified volume size: {0} bytes.\nAre you sure you want to split archive into such volumes?"
IDS_COMPRESS_SEC "sec"
IDS_COMPRESS_NS "ns"
END
#include "CompressOptionsDialog.rc"

View File

@@ -1,5 +1,6 @@
#define IDD_COMPRESS 4000
#define IDD_COMPRESS_2 14000
#define IDD_COMPRESS_OPTIONS 14001
#define IDC_COMPRESS_ARCHIVE 100
#define IDB_COMPRESS_SET_ARCHIVE 101
@@ -28,6 +29,10 @@
#define IDT_COMPRESS_ARCHIVE_FOLDER 130
// #define IDB_COMPRESS_OPTIONS 140
#define IDB_COMPRESS_OPTIONS 2100
#define IDT_COMPRESS_OPTIONS 141
#define IDT_COMPRESS_PATH_MODE 3410
#define IDT_PASSWORD_ENTER 3801
@@ -86,3 +91,31 @@
#define IDT_SPLIT_TO_VOLUMES 7302
#define IDS_INCORRECT_VOLUME_SIZE 7307
#define IDS_SPLIT_CONFIRM 7308
// Options Dialog
#define IDG_COMPRESS_TIME 4080
#define IDT_COMPRESS_TIME_PREC 4081
#define IDX_COMPRESS_MTIME 4082
#define IDX_COMPRESS_CTIME 4083
#define IDX_COMPRESS_ATIME 4084
#define IDX_COMPRESS_ZTIME 4085
#define IDX_COMPRESS_PRESERVE_ATIME 4086
#define IDS_COMPRESS_SEC 4090
#define IDS_COMPRESS_NS 4091
#define IDC_COMPRESS_TIME_PREC 190
#define IDT_COMPRESS_TIME_INFO 191
#define IDX_COMPRESS_PREC_SET 201
#define IDX_COMPRESS_MTIME_SET 202
#define IDX_COMPRESS_CTIME_SET 203
#define IDX_COMPRESS_ATIME_SET 204
#define IDX_COMPRESS_ZTIME_SET 205
// #define IDX_COMPRESS_NT_SYM_LINKS_SET 210
// #define IDX_COMPRESS_NT_HARD_LINKS_SET 211
// #define IDX_COMPRESS_NT_ALT_STREAMS_SET 212
// #define IDX_COMPRESS_NT_SECUR_SET 213

View File

@@ -0,0 +1,76 @@
#include "CompressDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 240
#define yc 232
#define g5x m
#define g5x2 (g5x + m)
#define g5xs (xc)
#define g5xs2 (g5xs - m - m)
#define ntPosX g5x2
#define ntPosY m
#define ntSizeX g5xs2
#define precSizeX 76
#define ntSizeY 72
#define timePosY (ntPosY + ntSizeY + 20)
#define ceSize 18
#define ceString ":"
IDD_COMPRESS_OPTIONS DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT
CAPTION "Options"
BEGIN
GROUPBOX "NTFS", IDG_COMPRESS_NTFS, g5x, ntPosY, g5xs, ntSizeY
CONTROL "Store symbolic links", IDX_COMPRESS_NT_SYM_LINKS, MY_CHECKBOX,
ntPosX, ntPosY + 12, ntSizeX, 10
CONTROL "Store hard links", IDX_COMPRESS_NT_HARD_LINKS, MY_CHECKBOX,
ntPosX, ntPosY + 26, ntSizeX, 10
CONTROL "Store alternate data streams", IDX_COMPRESS_NT_ALT_STREAMS, MY_CHECKBOX,
ntPosX, ntPosY + 40, ntSizeX, 10
CONTROL "Store file security", IDX_COMPRESS_NT_SECUR, MY_CHECKBOX,
ntPosX, ntPosY + 54, ntSizeX, 10
LTEXT "", IDT_COMPRESS_TIME_INFO, g5x, timePosY - 14, g5xs, 8
GROUPBOX "Time", IDG_COMPRESS_TIME, g5x, timePosY, g5xs, 112
// CONTROL "Default", IDX_COMPRESS_TIME_DEFAULT, MY_CHECKBOX,
// ntPosX, timePosY + 10, ntSizeX, 16
CONTROL ceString, IDX_COMPRESS_PREC_SET, MY_CHECKBOX, ntPosX, timePosY + 14, ceSize, 10
LTEXT "Timestamp precision:", IDT_COMPRESS_TIME_PREC,
ntPosX + ceSize, timePosY + 14, ntSizeX - precSizeX - ceSize, 8
COMBOBOX IDC_COMPRESS_TIME_PREC, ntPosX + ntSizeX - precSizeX, timePosY + 12, precSizeX, 70, MY_COMBO
// PUSHBUTTON "Default", IDB_COMPRESS_TIME_DEFAULT, ntPosX + ntSizeX - bxs, timePosY + 22, bxs, bys, WS_GROUP
CONTROL ceString, IDX_COMPRESS_MTIME_SET, MY_CHECKBOX, ntPosX, timePosY + 28, ceSize, 10
CONTROL "Store modification time", IDX_COMPRESS_MTIME, MY_CHECKBOX,
ntPosX + ceSize, timePosY + 28, ntSizeX - ceSize, 10
CONTROL ceString, IDX_COMPRESS_CTIME_SET, MY_CHECKBOX, ntPosX, timePosY + 42, ceSize, 10
CONTROL "Store creation time", IDX_COMPRESS_CTIME, MY_CHECKBOX,
ntPosX + ceSize, timePosY + 42, ntSizeX - ceSize, 10
CONTROL ceString, IDX_COMPRESS_ATIME_SET, MY_CHECKBOX, ntPosX, timePosY + 56, ceSize, 10
CONTROL "Store last access time", IDX_COMPRESS_ATIME, MY_CHECKBOX,
ntPosX + ceSize, timePosY + 56, ntSizeX - ceSize, 10
CONTROL ceString, IDX_COMPRESS_ZTIME_SET, MY_CHECKBOX | BS_MULTILINE, ntPosX, timePosY + 72, ceSize, 16
CONTROL "Set archive time to latest file time", IDX_COMPRESS_ZTIME, MY_CHECKBOX | BS_MULTILINE,
ntPosX + ceSize, timePosY + 72, ntSizeX - ceSize, 16
CONTROL "Do not change source files last access time", IDX_COMPRESS_PRESERVE_ATIME, MY_CHECKBOX | BS_MULTILINE,
ntPosX, timePosY + 92, ntSizeX, 16
DEFPUSHBUTTON "OK", IDOK, bx3, by, bxs, bys, WS_GROUP
PUSHBUTTON "Cancel", IDCANCEL, bx2, by, bxs, bys
PUSHBUTTON "Help", IDHELP, bx1, by, bxs, bys
END

View File

@@ -75,6 +75,8 @@ extern
bool g_LVN_ITEMACTIVATE_Support;
bool g_LVN_ITEMACTIVATE_Support = true;
DECLARE_AND_SET_CLIENT_VERSION_VAR
static void ErrorMessage(LPCWSTR message)
{
MessageBoxW(NULL, message, L"7-Zip ZS", MB_ICONERROR | MB_OK);
@@ -135,7 +137,7 @@ static int Main2()
CREATE_CODECS_OBJECT
codecs->CaseSensitiveChange = options.CaseSensitiveChange;
codecs->CaseSensitive_Change = options.CaseSensitive_Change;
codecs->CaseSensitive = options.CaseSensitive;
ThrowException_if_Error(codecs->Load());
Codecs_AddHashArcHandler(codecs);

View File

@@ -773,6 +773,10 @@ SOURCE=..\..\..\..\C\7zCrcOpt.c
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\7zTypes.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -1211,5 +1215,17 @@ SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
# End Source File
# End Group
# Begin Group "7-Zip"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\Archive\IArchive.h
# End Source File
# Begin Source File
SOURCE=..\..\ICoder.h
# End Source File
# End Group
# End Target
# End Project

View File

@@ -61,6 +61,53 @@ HRESULT CThreadUpdating::ProcessVirt()
return HRESULT_FROM_WIN32(ei.SystemError);
}
// parse command line properties
static bool ParseProp_Time_BoolPair(const CProperty &prop, const char *name, CBoolPair &bp)
{
if (!prop.Name.IsPrefixedBy_Ascii_NoCase(name))
return false;
const UString rem = prop.Name.Ptr((unsigned)strlen(name));
UString val = prop.Value;
if (!rem.IsEmpty())
{
if (!val.IsEmpty())
return true;
val = rem;
}
bool res;
if (StringToBool(val, res))
{
bp.Val = res;
bp.Def = true;
}
return true;
}
static void ParseProp(
const CProperty &prop,
NCompressDialog::CInfo &di)
{
if (ParseProp_Time_BoolPair(prop, "tm", di.MTime)) return;
if (ParseProp_Time_BoolPair(prop, "tc", di.CTime)) return;
if (ParseProp_Time_BoolPair(prop, "ta", di.ATime)) return;
}
static void ParseProperties(
const CObjectVector<CProperty> &properties,
NCompressDialog::CInfo &di)
{
FOR_VECTOR (i, properties)
{
ParseProp(properties[i], di);
}
}
static void AddProp_UString(CObjectVector<CProperty> &properties, const char *name, const UString &value)
{
CProperty prop;
@@ -81,10 +128,31 @@ static void AddProp_bool(CObjectVector<CProperty> &properties, const char *name,
AddProp_UString(properties, name, UString(value ? "on": "off"));
}
static bool IsThereMethodOverride(bool is7z, const UString &propertiesString)
static void AddProp_BoolPair(CObjectVector<CProperty> &properties,
const char *name, const CBoolPair &bp)
{
if (bp.Def)
AddProp_bool(properties, name, bp.Val);
}
static void SplitOptionsToStrings(const UString &src, UStringVector &strings)
{
SplitString(src, strings);
FOR_VECTOR (i, strings)
{
UString &s = strings[i];
if (s.Len() > 2
&& s[0] == '-'
&& MyCharLower_Ascii(s[1]) == 'm')
s.DeleteFrontal(2);
}
}
static bool IsThereMethodOverride(bool is7z, const UStringVector &strings)
{
UStringVector strings;
SplitString(propertiesString, strings);
FOR_VECTOR (i, strings)
{
const UString &s = strings[i];
@@ -106,17 +174,11 @@ static bool IsThereMethodOverride(bool is7z, const UString &propertiesString)
}
static void ParseAndAddPropertires(CObjectVector<CProperty> &properties,
const UString &propertiesString)
const UStringVector &strings)
{
UStringVector strings;
SplitString(propertiesString, strings);
FOR_VECTOR (i, strings)
{
UString s = strings[i];
if (s.Len() > 2
&& s[0] == '-'
&& MyCharLower_Ascii(s[1]) == 'm')
s.DeleteFrontal(2);
const UString &s = strings[i];
CProperty property;
const int index = s.Find(L'=');
if (index < 0)
@@ -142,58 +204,49 @@ static void AddProp_Size(CObjectVector<CProperty> &properties, const char *name,
static void SetOutProperties(
CObjectVector<CProperty> &properties,
const NCompressDialog::CInfo &di,
bool is7z,
UInt32 level,
bool setMethod,
const UString &method,
UInt64 dict64,
bool orderMode,
UInt32 order,
bool solidIsSpecified, UInt64 solidBlockSize,
// bool multiThreadIsAllowed,
UInt32 numThreads,
const UString &encryptionMethod,
bool encryptHeadersIsAllowed, bool encryptHeaders,
const NCompression::CMemUse &memUse,
bool /* sfxMode */)
bool setMethod)
{
if (level != (UInt32)(Int32)-1)
AddProp_UInt32(properties, "x", (UInt32)level);
if (di.Level != (UInt32)(Int32)-1)
AddProp_UInt32(properties, "x", (UInt32)di.Level);
if (setMethod)
{
if (!method.IsEmpty())
AddProp_UString(properties, is7z ? "0": "m", method);
if (dict64 != (UInt64)(Int64)-1)
if (!di.Method.IsEmpty())
AddProp_UString(properties, is7z ? "0": "m", di.Method);
if (di.Dict64 != (UInt64)(Int64)-1)
{
AString name;
if (is7z)
name = "0";
name += (orderMode ? "mem" : "d");
AddProp_Size(properties, name, dict64);
name += (di.OrderMode ? "mem" : "d");
AddProp_Size(properties, name, di.Dict64);
}
if (order != (UInt32)(Int32)-1)
if (di.Order != (UInt32)(Int32)-1)
{
AString name;
if (is7z)
name = "0";
name += (orderMode ? "o" : "fb");
AddProp_UInt32(properties, name, (UInt32)order);
name += (di.OrderMode ? "o" : "fb");
AddProp_UInt32(properties, name, (UInt32)di.Order);
}
}
if (!encryptionMethod.IsEmpty())
AddProp_UString(properties, "em", encryptionMethod);
if (!di.EncryptionMethod.IsEmpty())
AddProp_UString(properties, "em", di.EncryptionMethod);
if (encryptHeadersIsAllowed)
AddProp_bool(properties, "he", encryptHeaders);
if (solidIsSpecified)
AddProp_Size(properties, "s", solidBlockSize);
if (di.EncryptHeadersIsAllowed)
AddProp_bool(properties, "he", di.EncryptHeaders);
if (di.SolidIsSpecified)
AddProp_Size(properties, "s", di.SolidBlockSize);
if (
// multiThreadIsAllowed &&
numThreads != (UInt32)(Int32)-1)
AddProp_UInt32(properties, "mt", numThreads);
// di.MultiThreadIsAllowed &&
di.NumThreads != (UInt32)(Int32)-1)
AddProp_UInt32(properties, "mt", di.NumThreads);
const NCompression::CMemUse &memUse = di.MemUsage;
if (memUse.IsDefined)
{
const char *kMemUse = "memuse";
@@ -208,8 +261,16 @@ static void SetOutProperties(
else
AddProp_Size(properties, kMemUse, memUse.Val);
}
AddProp_BoolPair(properties, "tm", di.MTime);
AddProp_BoolPair(properties, "tc", di.CTime);
AddProp_BoolPair(properties, "ta", di.ATime);
if (di.TimePrec != (UInt32)(Int32)-1)
AddProp_UInt32(properties, "tp", di.TimePrec);
}
struct C_UpdateMode_ToAction_Pair
{
NCompressDialog::NUpdateMode::EEnum UpdateMode;
@@ -358,6 +419,10 @@ static HRESULT ShowDialog(
di.HardLinks = options.HardLinks;
di.AltStreams = options.AltStreams;
di.NtSecurity = options.NtSecurity;
if (options.SetArcMTime)
di.SetArcMTime.SetTrueTrue();
if (options.PreserveATime)
di.PreserveATime.SetTrueTrue();
if (callback->PasswordIsDefined)
di.Password = callback->Password;
@@ -373,6 +438,8 @@ static HRESULT ShowDialog(
di.UpdateMode = g_UpdateMode_Pairs[(unsigned)index].UpdateMode;
}
ParseProperties(options.MethodMode.Properties, di);
if (dialog.Create(hwndParent) != IDOK)
return E_ABORT;
@@ -382,6 +449,9 @@ static HRESULT ShowDialog(
options.HardLinks = di.HardLinks;
options.AltStreams = di.AltStreams;
options.NtSecurity = di.NtSecurity;
options.SetArcMTime = di.SetArcMTime.Val;
if (di.PreserveATime.Def)
options.PreserveATime = di.PreserveATime.Val;
#if defined(_WIN32) && !defined(UNDER_CE)
curDirRestorer.NeedRestore = dialog.CurrentDirWasChanged;
@@ -411,29 +481,21 @@ static HRESULT ShowDialog(
if (callback->PasswordIsDefined)
callback->Password = di.Password;
// we clear command line options, and fill options form Dialog
options.MethodMode.Properties.Clear();
bool is7z = archiverInfo.Name.IsEqualTo_Ascii_NoCase("7z");
bool methodOverride = IsThereMethodOverride(is7z, di.Options);
const bool is7z = archiverInfo.Is_7z();
SetOutProperties(
options.MethodMode.Properties,
UStringVector optionStrings;
SplitOptionsToStrings(di.Options, optionStrings);
const bool methodOverride = IsThereMethodOverride(is7z, optionStrings);
SetOutProperties(options.MethodMode.Properties, di,
is7z,
di.Level,
!methodOverride,
di.Method,
di.Dict64,
di.OrderMode, di.Order,
di.SolidIsSpecified, di.SolidBlockSize,
// di.MultiThreadIsAllowed,
di.NumThreads,
di.EncryptionMethod,
di.EncryptHeadersIsAllowed, di.EncryptHeaders,
di.MemUsage,
di.SFXMode);
!methodOverride); // setMethod
options.OpenShareForWrite = di.OpenShareForWrite;
ParseAndAddPropertires(options.MethodMode.Properties, di.Options);
ParseAndAddPropertires(options.MethodMode.Properties, optionStrings);
if (di.SFXMode)
options.SfxMode = true;