This commit is contained in:
Igor Pavlov
2022-06-23 11:43:16 +01:00
committed by Kornel
parent c3529a41f5
commit ec44a8a070
1248 changed files with 15242 additions and 2443 deletions

105
CPP/7zip/UI/Common/ZipRegistry.cpp Normal file → Executable file
View File

@@ -33,12 +33,45 @@ static LONG CreateMainKey(CKey &key, LPCTSTR keyName)
return key.Create(HKEY_CURRENT_USER, GetKeyPath(keyName));
}
static void Key_Set_UInt32(CKey &key, LPCTSTR name, UInt32 value)
{
if (value == (UInt32)(Int32)-1)
key.DeleteValue(name);
else
key.SetValue(name, value);
}
static void Key_Get_UInt32(CKey &key, LPCTSTR name, UInt32 &value)
{
if (key.QueryValue(name, value) != ERROR_SUCCESS)
value = (UInt32)(Int32)-1;
}
static void Key_Set_BoolPair(CKey &key, LPCTSTR name, const CBoolPair &b)
{
if (b.Def)
key.SetValue(name, b.Val);
}
static void Key_Set_bool_if_Changed(CKey &key, LPCTSTR name, bool val)
{
bool oldVal = false;
if (key.GetValue_IfOk(name, oldVal) == ERROR_SUCCESS)
if (val == oldVal)
return;
key.SetValue(name, val);
}
static void Key_Set_BoolPair_Delete_IfNotDef(CKey &key, LPCTSTR name, const CBoolPair &b)
{
if (b.Def)
Key_Set_bool_if_Changed(key, name, b.Val);
else
key.DeleteValue(name);
}
static void Key_Get_BoolPair(CKey &key, LPCTSTR name, CBoolPair &b)
{
b.Val = false;
@@ -169,6 +202,13 @@ static LPCTSTR const kNtSecur = TEXT("Security");
static LPCTSTR const kAltStreams = TEXT("AltStreams");
static LPCTSTR const kHardLinks = TEXT("HardLinks");
static LPCTSTR const kSymLinks = TEXT("SymLinks");
static LPCTSTR const kPreserveATime = TEXT("PreserveATime");
static LPCTSTR const kTimePrec = TEXT("TimePrec");
static LPCTSTR const kMTime = TEXT("MTime");
static LPCTSTR const kATime = TEXT("ATime");
static LPCTSTR const kCTime = TEXT("CTime");
static LPCTSTR const kSetArcMTime = TEXT("SetArcMTime");
static void SetRegString(CKey &key, LPCWSTR name, const UString &value)
{
@@ -178,26 +218,12 @@ static void SetRegString(CKey &key, LPCWSTR name, const UString &value)
key.SetValue(name, value);
}
static void SetRegUInt32(CKey &key, LPCTSTR name, UInt32 value)
{
if (value == (UInt32)(Int32)-1)
key.DeleteValue(name);
else
key.SetValue(name, value);
}
static void GetRegString(CKey &key, LPCWSTR name, UString &value)
{
if (key.QueryValue(name, value) != ERROR_SUCCESS)
value.Empty();
}
static void GetRegUInt32(CKey &key, LPCTSTR name, UInt32 &value)
{
if (key.QueryValue(name, value) != ERROR_SUCCESS)
value = (UInt32)(Int32)-1;
}
static LPCWSTR const kMemUse = L"MemUse"
#if defined(MY_CPU_SIZEOF_POINTER) && (MY_CPU_SIZEOF_POINTER == 4)
L"32";
@@ -212,10 +238,11 @@ void CInfo::Save() const
CKey key;
CreateMainKey(key, kKeyName);
Key_Set_BoolPair(key, kNtSecur, NtSecurity);
Key_Set_BoolPair(key, kAltStreams, AltStreams);
Key_Set_BoolPair(key, kHardLinks, HardLinks);
Key_Set_BoolPair(key, kSymLinks, SymLinks);
Key_Set_BoolPair_Delete_IfNotDef (key, kNtSecur, NtSecurity);
Key_Set_BoolPair_Delete_IfNotDef (key, kAltStreams, AltStreams);
Key_Set_BoolPair_Delete_IfNotDef (key, kHardLinks, HardLinks);
Key_Set_BoolPair_Delete_IfNotDef (key, kSymLinks, SymLinks);
Key_Set_BoolPair_Delete_IfNotDef (key, kPreserveATime, PreserveATime);
key.SetValue(kShowPassword, ShowPassword);
key.SetValue(kLevel, (UInt32)Level);
@@ -235,16 +262,22 @@ void CInfo::Save() const
CKey fk;
fk.Create(optionsKey, fo.FormatID);
SetRegUInt32(fk, kLevel, fo.Level);
SetRegUInt32(fk, kDictionary, fo.Dictionary);
SetRegUInt32(fk, kOrder, fo.Order);
SetRegUInt32(fk, kBlockSize, fo.BlockLogSize);
SetRegUInt32(fk, kNumThreads, fo.NumThreads);
SetRegString(fk, kMethod, fo.Method);
SetRegString(fk, kOptions, fo.Options);
SetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
SetRegString(fk, kMemUse, fo.MemUse);
Key_Set_UInt32(fk, kLevel, fo.Level);
Key_Set_UInt32(fk, kDictionary, fo.Dictionary);
Key_Set_UInt32(fk, kOrder, fo.Order);
Key_Set_UInt32(fk, kBlockSize, fo.BlockLogSize);
Key_Set_UInt32(fk, kNumThreads, fo.NumThreads);
Key_Set_UInt32(fk, kTimePrec, fo.TimePrec);
Key_Set_BoolPair_Delete_IfNotDef (fk, kMTime, fo.MTime);
Key_Set_BoolPair_Delete_IfNotDef (fk, kATime, fo.ATime);
Key_Set_BoolPair_Delete_IfNotDef (fk, kCTime, fo.CTime);
Key_Set_BoolPair_Delete_IfNotDef (fk, kSetArcMTime, fo.SetArcMTime);
}
}
}
@@ -269,6 +302,7 @@ void CInfo::Load()
Key_Get_BoolPair(key, kAltStreams, AltStreams);
Key_Get_BoolPair(key, kHardLinks, HardLinks);
Key_Get_BoolPair(key, kSymLinks, SymLinks);
Key_Get_BoolPair(key, kPreserveATime, PreserveATime);
key.GetValue_Strings(kArcHistory, ArcPaths);
@@ -290,11 +324,17 @@ void CInfo::Load()
GetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
GetRegString(fk, kMemUse, fo.MemUse);
GetRegUInt32(fk, kLevel, fo.Level);
GetRegUInt32(fk, kDictionary, fo.Dictionary);
GetRegUInt32(fk, kOrder, fo.Order);
GetRegUInt32(fk, kBlockSize, fo.BlockLogSize);
GetRegUInt32(fk, kNumThreads, fo.NumThreads);
Key_Get_UInt32(fk, kLevel, fo.Level);
Key_Get_UInt32(fk, kDictionary, fo.Dictionary);
Key_Get_UInt32(fk, kOrder, fo.Order);
Key_Get_UInt32(fk, kBlockSize, fo.BlockLogSize);
Key_Get_UInt32(fk, kNumThreads, fo.NumThreads);
Key_Get_UInt32(fk, kTimePrec, fo.TimePrec);
Key_Get_BoolPair(fk, kMTime, fo.MTime);
Key_Get_BoolPair(fk, kATime, fo.ATime);
Key_Get_BoolPair(fk, kCTime, fo.CTime);
Key_Get_BoolPair(fk, kSetArcMTime, fo.SetArcMTime);
Formats.Add(fo);
}
@@ -478,6 +518,7 @@ static LPCTSTR const kCascadedMenu = TEXT("CascadedMenu");
static LPCTSTR const kContextMenu = TEXT("ContextMenu");
static LPCTSTR const kMenuIcons = TEXT("MenuIcons");
static LPCTSTR const kElimDup = TEXT("ElimDupExtract");
static LPCTSTR const kWriteZoneId = TEXT("WriteZoneIdExtract");
void CContextMenuInfo::Save() const
{
@@ -488,6 +529,8 @@ void CContextMenuInfo::Save() const
Key_Set_BoolPair(key, kCascadedMenu, Cascaded);
Key_Set_BoolPair(key, kMenuIcons, MenuIcons);
Key_Set_BoolPair(key, kElimDup, ElimDup);
Key_Set_UInt32(key, kWriteZoneId, WriteZone);
if (Flags_Def)
key.SetValue(kContextMenu, Flags);
@@ -504,6 +547,8 @@ void CContextMenuInfo::Load()
ElimDup.Val = true;
ElimDup.Def = false;
WriteZone = (UInt32)(Int32)-1;
Flags = (UInt32)(Int32)-1;
Flags_Def = false;
@@ -517,5 +562,7 @@ void CContextMenuInfo::Load()
Key_Get_BoolPair_true(key, kElimDup, ElimDup);
Key_Get_BoolPair(key, kMenuIcons, MenuIcons);
Key_Get_UInt32(key, kWriteZoneId, WriteZone);
Flags_Def = (key.GetValue_IfOk(kContextMenu, Flags) == ERROR_SUCCESS);
}