mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 09:15:00 -06:00
Update to 7-Zip Version 22.00
See: https://sourceforge.net/p/sevenzip/discussion/45797/thread/9c2d9061ce/
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user