Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/UI/Common/ZipRegistry.cpp')
-rw-r--r--CPP/7zip/UI/Common/ZipRegistry.cpp124
1 files changed, 123 insertions, 1 deletions
diff --git a/CPP/7zip/UI/Common/ZipRegistry.cpp b/CPP/7zip/UI/Common/ZipRegistry.cpp
index 558a159c..ab4871fb 100644
--- a/CPP/7zip/UI/Common/ZipRegistry.cpp
+++ b/CPP/7zip/UI/Common/ZipRegistry.cpp
@@ -2,7 +2,10 @@
#include "StdAfx.h"
+#include "../../../../C/CpuArch.h"
+
#include "../../../Common/IntToString.h"
+#include "../../../Common/StringToInt.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/Registry.h"
@@ -195,6 +198,13 @@ static void GetRegUInt32(CKey &key, LPCTSTR name, UInt32 &value)
value = (UInt32)(Int32)-1;
}
+static LPCWSTR const kMemUse = L"MemUse"
+ #if defined(MY_CPU_SIZEOF_POINTER) && (MY_CPU_SIZEOF_POINTER == 4)
+ L"32";
+ #else
+ L"64";
+ #endif
+
void CInfo::Save() const
{
CS_LOCK
@@ -234,6 +244,7 @@ void CInfo::Save() const
SetRegString(fk, kMethod, fo.Method);
SetRegString(fk, kOptions, fo.Options);
SetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
+ SetRegString(fk, kMemUse, fo.MemUse);
}
}
}
@@ -274,9 +285,10 @@ void CInfo::Load()
fo.FormatID = formatIDs[i];
if (fk.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS)
{
- GetRegString(fk, kOptions, fo.Options);
GetRegString(fk, kMethod, fo.Method);
+ GetRegString(fk, kOptions, fo.Options);
GetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
+ GetRegString(fk, kMemUse, fo.MemUse);
GetRegUInt32(fk, kLevel, fo.Level);
GetRegUInt32(fk, kDictionary, fo.Dictionary);
@@ -298,6 +310,116 @@ void CInfo::Load()
key.GetValue_IfOk(kEncryptHeaders, EncryptHeaders);
}
+
+static bool ParseMemUse(const wchar_t *s, CMemUse &mu)
+{
+ mu.Clear();
+
+ bool percentMode = false;
+ {
+ const wchar_t c = *s;
+ if (MyCharLower_Ascii(c) == 'p')
+ {
+ percentMode = true;
+ s++;
+ }
+ }
+ const wchar_t *end;
+ UInt64 number = ConvertStringToUInt64(s, &end);
+ if (end == s)
+ return false;
+
+ wchar_t c = *end;
+
+ if (percentMode)
+ {
+ if (c != 0)
+ return false;
+ mu.IsPercent = true;
+ mu.Val = number;
+ return true;
+ }
+
+ if (c == 0)
+ {
+ mu.Val = number;
+ return true;
+ }
+
+ c = MyCharLower_Ascii(c);
+
+ const wchar_t c1 = end[1];
+
+ if (c == '%')
+ {
+ if (c1 != 0)
+ return false;
+ mu.IsPercent = true;
+ mu.Val = number;
+ return true;
+ }
+
+ if (c == 'b')
+ {
+ if (c1 != 0)
+ return false;
+ mu.Val = number;
+ return true;
+ }
+
+ if (c1 != 0)
+ if (MyCharLower_Ascii(c1) != 'b' || end[2] != 0)
+ return false;
+
+ unsigned numBits;
+ switch (c)
+ {
+ case 'k': numBits = 10; break;
+ case 'm': numBits = 20; break;
+ case 'g': numBits = 30; break;
+ case 't': numBits = 40; break;
+ default: return false;
+ }
+ if (number >= ((UInt64)1 << (64 - numBits)))
+ return false;
+ mu.Val = number << numBits;
+ return true;
+}
+
+
+void CMemUse::Parse(const UString &s)
+{
+ IsDefined = ParseMemUse(s, *this);
+}
+
+/*
+void MemLimit_Save(const UString &s)
+{
+ CS_LOCK
+ CKey key;
+ CreateMainKey(key, kKeyName);
+ SetRegString(key, kMemUse, s);
+}
+
+bool MemLimit_Load(NCompression::CMemUse &mu)
+{
+ mu.Clear();
+ UString a;
+ {
+ CS_LOCK
+ CKey key;
+ if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS)
+ return false;
+ if (key.QueryValue(kMemUse, a) != ERROR_SUCCESS)
+ return false;
+ }
+ if (a.IsEmpty())
+ return false;
+ mu.Parse(a);
+ return mu.IsDefined;
+}
+*/
+
}
static LPCTSTR const kOptionsInfoKeyName = TEXT("Options");