4.45 beta

This commit is contained in:
Igor Pavlov
2007-04-17 00:00:00 +00:00
committed by Kornel Lesiński
parent d9666cf046
commit a145bfc7cf
458 changed files with 13144 additions and 18608 deletions
+179 -156
View File
@@ -45,8 +45,8 @@ static CIDLangPair kIDLangPairs[] =
{ IDC_STATIC_COMPRESS_ORDER, 0x02000D0D },
{ IDC_STATIC_COMPRESS_MEMORY, 0x02000D0E },
{ IDC_STATIC_COMPRESS_MEMORY_DE, 0x02000D0F },
{ IDC_COMPRESS_SOLID, 0x02000D05 },
{ IDC_COMPRESS_MULTI_THREAD, 0x02000D09 },
{ IDC_STATIC_COMPRESS_THREADS, 0x02000D12 },
{ IDC_STATIC_COMPRESS_SOLID, 0x02000D13 },
{ IDC_STATIC_COMPRESS_VOLUME, 0x02000D40 },
{ IDC_STATIC_COMPRESS_PARAMETERS, 0x02000D06 },
@@ -221,38 +221,9 @@ static bool IsMethodSupportedBySfx(int methodID)
return false;
};
#ifndef _WIN64
typedef BOOL (WINAPI *GlobalMemoryStatusExP)(LPMEMORYSTATUSEX lpBuffer);
#endif
static UInt64 GetPhysicalRamSize()
{
MEMORYSTATUSEX stat;
stat.dwLength = sizeof(stat);
// return (128 << 20);
#ifdef _WIN64
if (!::GlobalMemoryStatusEx(&stat))
return 0;
return stat.ullTotalPhys;
#else
GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
"GlobalMemoryStatusEx");
if (globalMemoryStatusEx != 0)
if (globalMemoryStatusEx(&stat))
return stat.ullTotalPhys;
{
MEMORYSTATUS stat;
stat.dwLength = sizeof(stat);
GlobalMemoryStatus(&stat);
return stat.dwTotalPhys;
}
#endif
}
static UInt64 GetMaxRamSizeForProgram()
{
UInt64 physSize = GetPhysicalRamSize();
UInt64 physSize = NSystem::GetRamSize();
const UInt64 kMinSysSize = (1 << 24);
if (physSize <= kMinSysSize)
physSize = 0;
@@ -282,6 +253,8 @@ bool CCompressDialog::OnInit()
m_Method.Attach(GetItem(IDC_COMPRESS_COMBO_METHOD));
m_Dictionary.Attach(GetItem(IDC_COMPRESS_COMBO_DICTIONARY));
m_Order.Attach(GetItem(IDC_COMPRESS_COMBO_ORDER));
m_Solid.Attach(GetItem(IDC_COMPRESS_COMBO_SOLID));
m_NumThreads.Attach(GetItem(IDC_COMPRESS_COMBO_THREADS));
m_UpdateMode.Attach(GetItem(IDC_COMPRESS_COMBO_UPDATE_MODE));
m_Volume.Attach(GetItem(IDC_COMPRESS_COMBO_VOLUME));
@@ -299,7 +272,7 @@ bool CCompressDialog::OnInit()
int i;
for(i = 0; i < m_ArchiverInfoList.Size(); i++)
{
const CArchiverInfo &ai = m_ArchiverInfoList[i];
const CArcInfoEx &ai = m_ArchiverInfoList[i];
m_Format.AddString(ai.Name);
if (ai.Name.CompareNoCase(m_RegistryInfo.ArchiveType) == 0)
Info.ArchiverInfoIndex = i;
@@ -320,11 +293,13 @@ bool CCompressDialog::OnInit()
m_UpdateMode.SetCurSel(0);
Info.Solid = m_RegistryInfo.Solid;
Info.MultiThread = m_RegistryInfo.MultiThread;
SetSolidBlockSize();
SetNumThreads();
TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 };
ConvertUInt64ToString(NSystem::GetNumberOfProcessors(), s + 2);
SetItemText(IDC_COMPRESS_HARDWARE_THREADS, s);
CheckButton(IDC_COMPRESS_SOLID, Info.Solid);
CheckButton(IDC_COMPRESS_MULTI_THREAD, Info.MultiThread);
CheckButton(IDC_COMPRESS_SFX, Info.SFXMode);
CheckControlsEnable();
@@ -380,20 +355,10 @@ bool CCompressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
UpdatePasswordControl();
return true;
}
case IDC_COMPRESS_MULTI_THREAD:
{
SetMemoryUsage();
return true;
}
}
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
static bool IsMultiProcessor()
{
return NSystem::GetNumberOfProcessors() > 1;
}
void CCompressDialog::CheckSFXControlsEnable()
{
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
@@ -419,13 +384,13 @@ void CCompressDialog::CheckVolumeEnable()
void CCompressDialog::CheckControlsEnable()
{
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
Info.SolidIsAllowed = fi.Solid;
bool multiThreadEnable = fi.MultiThread & IsMultiProcessor();
Info.SolidIsSpecified = fi.Solid;
bool multiThreadEnable = fi.MultiThread;
Info.MultiThreadIsAllowed = multiThreadEnable;
Info.EncryptHeadersIsAllowed = fi.EncryptFileNames;
EnableItem(IDC_COMPRESS_SOLID, fi.Solid);
EnableItem(IDC_COMPRESS_MULTI_THREAD, multiThreadEnable);
EnableItem(IDC_COMPRESS_COMBO_SOLID, fi.Solid);
EnableItem(IDC_COMPRESS_COMBO_THREADS, multiThreadEnable);
CheckSFXControlsEnable();
CheckVolumeEnable();
@@ -563,14 +528,17 @@ void CCompressDialog::OnOK()
Info.Dictionary = GetDictionarySpec();
Info.Order = GetOrderSpec();
Info.OrderMode = GetOrderMode();
Info.NumThreads = GetNumThreadsSpec();
UInt32 solidLogSize = GetBlockSizeSpec();
Info.SolidBlockSize = 0;
if (solidLogSize > 0)
Info.SolidBlockSize = (solidLogSize >= 64) ? (UInt64)(Int64)-1 : ((UInt64)1 << solidLogSize);
Info.Method = GetMethodSpec();
Info.EncryptionMethod = GetEncryptionMethodSpec();
Info.ArchiverInfoIndex = m_Format.GetCurSel();
Info.SFXMode = IsSFX();
m_RegistryInfo.Solid = Info.Solid = IsButtonCheckedBool(IDC_COMPRESS_SOLID);
m_RegistryInfo.MultiThread = Info.MultiThread = IsMultiThread();
m_RegistryInfo.EncryptHeaders = Info.EncryptHeaders = IsButtonCheckedBool(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES);
m_Params.GetText(Info.Options);
@@ -609,12 +577,7 @@ void CCompressDialog::OnOK()
if (m_RegistryInfo.HistoryArchives.Size() > kHistorySize)
m_RegistryInfo.HistoryArchives.DeleteBack();
////////////////////
// Method
m_RegistryInfo.Level = Info.Level;
m_RegistryInfo.ArchiveType = m_ArchiverInfoList[Info.ArchiverInfoIndex].Name;
m_RegistryInfo.ShowPassword = IsShowPasswordChecked();
SaveCompressionInfo(m_RegistryInfo);
@@ -642,11 +605,13 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
}
case IDC_COMPRESS_COMBO_LEVEL:
{
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormatAlways(ai.Name);
NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
fo.ResetForLevelChange();
SetMethod();
SetSolidBlockSize();
SetNumThreads();
CheckSFXNameChange();
return true;
}
@@ -654,11 +619,19 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
{
SetDictionary();
SetOrder();
SetSolidBlockSize();
SetNumThreads();
CheckSFXNameChange();
return true;
}
case IDC_COMPRESS_COMBO_DICTIONARY:
case IDC_COMPRESS_COMBO_ORDER:
{
SetSolidBlockSize();
SetMemoryUsage();
return true;
}
case IDC_COMPRESS_COMBO_THREADS:
{
SetMemoryUsage();
return true;
@@ -680,10 +653,10 @@ void CCompressDialog::SetArchiveName2(bool prevWasSFX)
{
UString fileName;
m_ArchivePath.GetText(fileName);
const CArchiverInfo &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat];
const CArcInfoEx &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat];
if (prevArchiverInfo.KeepName || Info.KeepName)
{
UString prevExtension = prevArchiverInfo.GetMainExtension();
UString prevExtension = prevArchiverInfo.GetMainExt();
if (prevWasSFX)
prevExtension = kExeExt;
else
@@ -701,6 +674,8 @@ void CCompressDialog::OnChangeFormat()
bool isSFX = IsSFX();
SaveOptionsInMem();
SetLevel();
SetSolidBlockSize();
SetNumThreads();
SetParams();
CheckControlsEnable();
SetArchiveName2(isSFX);
@@ -715,7 +690,7 @@ void CCompressDialog::SetArchiveName(const UString &name)
{
UString fileName = name;
Info.ArchiverInfoIndex = m_Format.GetCurSel();
const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
m_PrevFormat = Info.ArchiverInfoIndex;
if (ai.KeepName)
{
@@ -737,7 +712,7 @@ void CCompressDialog::SetArchiveName(const UString &name)
else
{
fileName += L'.';
fileName += ai.GetMainExtension();
fileName += ai.GetMainExt();
}
m_ArchivePath.SetText(fileName);
}
@@ -768,15 +743,14 @@ int CCompressDialog::FindRegistryFormatAlways(const UString &name)
int CCompressDialog::GetStaticFormatIndex()
{
int formatIndex = m_Format.GetCurSel();
const CArchiverInfo &ai = m_ArchiverInfoList[formatIndex];
const CArcInfoEx &ai = m_ArchiverInfoList[formatIndex];
for (int i = 0; i < MY_SIZE_OF_ARRAY(g_Formats); i++)
if (ai.Name.CompareNoCase(g_Formats[i].Name) == 0)
return i;
return 0; // -1;
}
void CCompressDialog::SetNearestSelectComboBox(
NControl::CComboBox &comboBox, UInt32 value)
void CCompressDialog::SetNearestSelectComboBox(NControl::CComboBox &comboBox, UInt32 value)
{
for (int i = comboBox.GetCount() - 1; i >= 0; i--)
if ((UInt32)comboBox.GetItemData(i) <= value)
@@ -792,7 +766,7 @@ void CCompressDialog::SetLevel()
{
m_Level.ResetContent();
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
UInt32 level = kNormal;
if (index >= 0)
@@ -817,50 +791,18 @@ void CCompressDialog::SetLevel()
SetMethod();
}
int CCompressDialog::GetLevel()
{
if (m_Level.GetCount() <= 0)
return -1;
return (int)m_Level.GetItemData(m_Level.GetCurSel());
}
int CCompressDialog::GetLevelSpec()
{
if (m_Level.GetCount() <= 1)
return -1;
return GetLevel();
}
int CCompressDialog::GetLevel2()
{
int level = GetLevel();
if (level < 0)
level = 5;
return level;
}
bool CCompressDialog::IsMultiThread()
{
/*
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
bool multiThreadEnable = fi.MultiThread & IsMultiProcessor();
if (!multiThreadEnable)
return false;
*/
return IsButtonCheckedBool(IDC_COMPRESS_MULTI_THREAD);
}
void CCompressDialog::SetMethod()
{
m_Method.ResetContent();
if (GetLevel() <= 0)
UInt32 level = GetLevel();
if (level == 0)
{
SetDictionary();
SetOrder();
return;
}
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
UString defaultMethod;
if (index >= 0)
@@ -886,14 +828,14 @@ void CCompressDialog::SetMethod()
bool CCompressDialog::IsZipFormat()
{
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
return (ai.Name.CompareNoCase(L"zip") == 0);
}
void CCompressDialog::SetEncryptionMethod()
{
_encryptionMethod.ResetContent();
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
if (ai.Name.CompareNoCase(L"7z") == 0)
{
_encryptionMethod.AddString(TEXT("AES-256"));
@@ -935,7 +877,7 @@ UString CCompressDialog::GetMethodSpec()
UString CCompressDialog::GetEncryptionMethodSpec()
{
if (m_Method.GetCount() <= 1)
if (_encryptionMethod.GetCount() <= 1)
return UString();
if (_encryptionMethod.GetCurSel() <= 0)
return UString();
@@ -981,7 +923,7 @@ int CCompressDialog::AddDictionarySize(UInt32 size)
void CCompressDialog::SetDictionary()
{
m_Dictionary.ResetContent();
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
UInt32 defaultDictionary = UInt32(-1);
if (index >= 0)
@@ -991,7 +933,7 @@ void CCompressDialog::SetDictionary()
defaultDictionary = fo.Dictionary;
}
int methodID = GetMethodID();
int level = GetLevel2();
UInt32 level = GetLevel2();
if (methodID < 0)
{
SetMemoryUsage();
@@ -1005,16 +947,11 @@ void CCompressDialog::SetDictionary()
static const UInt32 kMinDicSize = (1 << 16);
if (defaultDictionary == UInt32(-1))
{
if (level >= 9)
defaultDictionary = (1 << 26);
else if (level >= 7)
defaultDictionary = (1 << 24);
else if (level >= 5)
defaultDictionary = (1 << 22);
else if (level >= 3)
defaultDictionary = (1 << 20);
else
defaultDictionary = (kMinDicSize);
if (level >= 9) defaultDictionary = (1 << 26);
else if (level >= 7) defaultDictionary = (1 << 25);
else if (level >= 5) defaultDictionary = (1 << 24);
else if (level >= 3) defaultDictionary = (1 << 20);
else defaultDictionary = (kMinDicSize);
}
int i;
AddDictionarySize(kMinDicSize);
@@ -1029,13 +966,13 @@ void CCompressDialog::SetDictionary()
#ifdef _WIN64
(1 << 30)
#else
(1 << 27)
(1 << 26)
#endif
)
continue;
AddDictionarySize(dictionary);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize);
if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
@@ -1047,14 +984,10 @@ void CCompressDialog::SetDictionary()
{
if (defaultDictionary == UInt32(-1))
{
if (level >= 9)
defaultDictionary = (192 << 20);
else if (level >= 7)
defaultDictionary = (64 << 20);
else if (level >= 5)
defaultDictionary = (16 << 20);
else
defaultDictionary = (4 << 20);
if (level >= 9) defaultDictionary = (192 << 20);
else if (level >= 7) defaultDictionary = ( 64 << 20);
else if (level >= 5) defaultDictionary = ( 16 << 20);
else defaultDictionary = ( 4 << 20);
}
int i;
for (i = 20; i < 31; i++)
@@ -1067,7 +1000,7 @@ void CCompressDialog::SetDictionary()
continue;
AddDictionarySize(dictionary);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize);
if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
@@ -1108,18 +1041,19 @@ void CCompressDialog::SetDictionary()
SetMemoryUsage();
}
UInt32 CCompressDialog::GetDictionary()
UInt32 CCompressDialog::GetComboValue(NWindows::NControl::CComboBox &c, int defMax)
{
if (m_Dictionary.GetCount() <= 0)
if (c.GetCount() <= defMax)
return (UInt32)-1;
return (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
return (UInt32)c.GetItemData(c.GetCurSel());
}
UInt32 CCompressDialog::GetDictionarySpec()
UInt32 CCompressDialog::GetLevel2()
{
if (m_Dictionary.GetCount() <= 1)
return (UInt32)-1;
return GetDictionary();
UInt32 level = GetLevel();
if (level == (UInt32)-1)
level = 5;
return level;
}
int CCompressDialog::AddOrder(UInt32 size)
@@ -1134,7 +1068,7 @@ int CCompressDialog::AddOrder(UInt32 size)
void CCompressDialog::SetOrder()
{
m_Order.ResetContent();
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
UInt32 defaultOrder = UInt32(-1);
if (index >= 0)
@@ -1144,7 +1078,7 @@ void CCompressDialog::SetOrder()
defaultOrder = fo.Order;
}
int methodID = GetMethodID();
int level = GetLevel2();
UInt32 level = GetLevel2();
if (methodID < 0)
{
SetMemoryUsage();
@@ -1236,24 +1170,107 @@ bool CCompressDialog::GetOrderMode()
return false;
}
UInt32 CCompressDialog::GetOrder()
static const UInt32 kNoSolidBlockSize = 0;
static const UInt32 kSolidBlockSize = 64;
void CCompressDialog::SetSolidBlockSize()
{
if (m_Order.GetCount() <= 0)
return (UInt32)-1;
return (UInt32)m_Order.GetItemData(m_Order.GetCurSel());
m_Solid.ResetContent();
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
if (!fi.Solid)
return;
UInt32 dictionary = GetDictionarySpec();
if (dictionary == UInt32(-1))
dictionary = 1;
UInt32 defaultBlockSize = (UInt32)-1;
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
{
const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
defaultBlockSize = fo.BlockLogSize;
}
index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_NON_SOLID, 0x02000D14));
m_Solid.SetItemData(index, (UInt32)kNoSolidBlockSize);
m_Solid.SetCurSel(0);
bool needSet = defaultBlockSize == (UInt32)-1;
for (int i = 20; i <= 36; i++)
{
if (needSet && dictionary >= (((UInt64)1 << (i - 7))) && i <= 32)
defaultBlockSize = i;
TCHAR s[40];
ConvertUInt64ToString(1 << (i % 10), s);
if (i < 30) lstrcat(s, TEXT(" M"));
else lstrcat(s, TEXT(" G"));
lstrcat(s, TEXT("B"));
int index = (int)m_Solid.AddString(s);
m_Solid.SetItemData(index, (UInt32)i);
}
index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_SOLID, 0x02000D15));
m_Solid.SetItemData(index, kSolidBlockSize);
if (defaultBlockSize == (UInt32)-1)
defaultBlockSize = kSolidBlockSize;
if (defaultBlockSize != kNoSolidBlockSize)
SetNearestSelectComboBox(m_Solid, defaultBlockSize);
}
UInt32 CCompressDialog::GetOrderSpec()
void CCompressDialog::SetNumThreads()
{
if (m_Order.GetCount() <= 1)
return (UInt32)-1;
return GetOrder();
m_NumThreads.ResetContent();
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
if (!fi.MultiThread)
return;
UInt32 numHardwareThreads = NSystem::GetNumberOfProcessors();
UInt32 defaultValue = numHardwareThreads;
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
{
const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
defaultValue = fo.NumThreads;
}
UInt32 numAlgoThreadsMax = 1;
int methodID = GetMethodID();
switch (methodID)
{
case kLZMA:
{
numAlgoThreadsMax = 2;
break;
}
case kBZip2:
{
numAlgoThreadsMax = 32;
break;
}
}
if (IsZipFormat())
numAlgoThreadsMax = 128;
for (UInt32 i = 1; i <= numHardwareThreads * 2 && i <= numAlgoThreadsMax; i++)
{
TCHAR s[40];
ConvertUInt64ToString(i, s);
int index = (int)m_NumThreads.AddString(s);
m_NumThreads.SetItemData(index, (UInt32)i);
}
SetNearestSelectComboBox(m_NumThreads, defaultValue);
}
UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory)
UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory)
{
decompressMemory = UInt64(Int64(-1));
int level = GetLevel2();
UInt32 level = GetLevel2();
if (level == 0)
{
decompressMemory = (1 << 20);
@@ -1264,6 +1281,12 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UI
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
if (fi.Filter && level >= 9)
size += (12 << 20) * 2 + (5 << 20);
UInt32 numThreads = GetNumThreads2();
if (IsZipFormat())
{
if (numThreads > 1)
size += (UInt64)numThreads << 25;
}
switch (GetMethodID())
{
case kLZMA:
@@ -1283,7 +1306,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UI
if (level >= 5)
size += dictionary * 4;
size += (2 << 20);
if (isMultiThread && level >= 5)
if (numThreads > 1 && level >= 5)
size += (2 << 20) + (4 << 20);
decompressMemory = dictionary + (2 << 20);
@@ -1310,9 +1333,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UI
{
decompressMemory = (7 << 20);
UInt64 memForOneThread = (10 << 20);
if (isMultiThread)
memForOneThread *= NSystem::GetNumberOfProcessors();
return size + (10 << 20);
return size + memForOneThread * numThreads;
}
}
return UInt64(Int64(-1));
@@ -1320,7 +1341,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UI
UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
{
return GetMemoryUsage(GetDictionary(), IsMultiThread(), decompressMemory);
return GetMemoryUsage(GetDictionary(), decompressMemory);
}
void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
@@ -1347,7 +1368,7 @@ void CCompressDialog::SetMemoryUsage()
void CCompressDialog::SetParams()
{
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
m_Params.SetText(TEXT(""));
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
@@ -1359,7 +1380,7 @@ void CCompressDialog::SetParams()
void CCompressDialog::SaveOptionsInMem()
{
const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
int index = FindRegistryFormatAlways(ai.Name);
m_Params.GetText(Info.Options);
Info.Options.Trim();
@@ -1370,4 +1391,6 @@ void CCompressDialog::SaveOptionsInMem()
fo.Order = GetOrderSpec();
fo.Method = GetMethodSpec();
fo.EncryptionMethod = GetEncryptionMethodSpec();
fo.NumThreads = GetNumThreadsSpec();
fo.BlockLogSize = GetBlockSizeSpec();
}
+24 -15
View File
@@ -4,7 +4,7 @@
#define __COMPRESSDIALOG_H
#include "../Common/ZipRegistry.h"
#include "../Common/ArchiverInfo.h"
#include "../Common/LoadCodecs.h"
#include "../Resource/CompressDialog/resource.h"
#include "Windows/Control/Dialog.h"
@@ -26,11 +26,10 @@ namespace NCompressDialog
struct CInfo
{
NUpdateMode::EEnum UpdateMode;
bool SolidIsAllowed;
bool Solid;
bool SolidIsSpecified;
bool MultiThreadIsAllowed;
bool MultiThread;
UInt64 SolidBlockSize;
UInt32 NumThreads;
CRecordVector<UInt64> VolumeSizes;
@@ -80,6 +79,8 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
NWindows::NControl::CComboBox m_Method;
NWindows::NControl::CComboBox m_Dictionary;
NWindows::NControl::CComboBox m_Order;
NWindows::NControl::CComboBox m_Solid;
NWindows::NControl::CComboBox m_NumThreads;
NWindows::NControl::CComboBox m_UpdateMode;
NWindows::NControl::CComboBox m_Volume;
NWindows::NControl::CDialogChildControl m_Params;
@@ -104,10 +105,6 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void SetNearestSelectComboBox(NWindows::NControl::CComboBox &comboBox, UInt32 value);
void SetLevel();
int GetLevel();
int GetLevelSpec();
int GetLevel2();
bool IsMultiThread();
void SetMethod();
int GetMethodID();
@@ -122,16 +119,28 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
int AddDictionarySize(UInt32 size);
void SetDictionary();
UInt32 GetDictionary();
UInt32 GetDictionarySpec();
UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);
UInt32 GetLevel() { return GetComboValue(m_Level); }
UInt32 GetLevelSpec() { return GetComboValue(m_Level, 1); }
UInt32 GetLevel2();
UInt32 GetDictionary() { return GetComboValue(m_Dictionary); }
UInt32 GetDictionarySpec() { return GetComboValue(m_Dictionary, 1); }
UInt32 GetOrder() { return GetComboValue(m_Order); }
UInt32 GetOrderSpec() { return GetComboValue(m_Order, 1); }
UInt32 GetNumThreadsSpec() { return GetComboValue(m_NumThreads, 1); }
UInt32 GetNumThreads2() { UInt32 num = GetNumThreadsSpec(); if (num == UInt32(-1)) num = 1; return num; }
UInt32 GetBlockSizeSpec() { return GetComboValue(m_Solid, 1); }
int AddOrder(UInt32 size);
void SetOrder();
bool GetOrderMode();
UInt32 GetOrder();
UInt32 GetOrderSpec();
UInt64 GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory);
void SetSolidBlockSize();
void SetNumThreads();
UInt64 GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory);
UInt64 GetMemoryUsage(UInt64 &decompressMemory);
void PrintMemUsage(UINT res, UInt64 value);
void SetMemoryUsage();
@@ -142,7 +151,7 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
bool IsShowPasswordChecked() const
{ return IsButtonChecked(IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED; }
public:
CObjectVector<CArchiverInfo> m_ArchiverInfoList;
CObjectVector<CArcInfoEx> m_ArchiverInfoList;
NCompressDialog::CInfo Info;
UString OriginalFileName; // for bzip2, gzip2
+6 -2
View File
@@ -28,8 +28,8 @@ static const wchar_t *kIncorrectOutDir = L"Incorrect output directory path";
struct CThreadExtracting
{
CCodecs *codecs;
CExtractCallbackImp *ExtractCallbackSpec;
UStringVector *ArchivePaths;
UStringVector *ArchivePathsFull;
const NWildcard::CCensorNode *WildcardCensor;
@@ -45,7 +45,9 @@ struct CThreadExtracting
ExtractCallbackSpec->ProgressDialog.WaitCreating();
try
{
Result = DecompressArchives(*ArchivePaths, *ArchivePathsFull,
Result = DecompressArchives(
codecs,
*ArchivePaths, *ArchivePathsFull,
*WildcardCensor, *Options, OpenCallback, ExtractCallback, ErrorMessage);
}
catch(const UString &s)
@@ -77,6 +79,7 @@ struct CThreadExtracting
};
HRESULT ExtractGUI(
CCodecs *codecs,
UStringVector &archivePaths,
UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
@@ -86,6 +89,7 @@ HRESULT ExtractGUI(
CExtractCallbackImp *extractCallback)
{
CThreadExtracting extracter;
extracter.codecs = codecs;
if (!options.TestMode)
{
+1
View File
@@ -9,6 +9,7 @@
#include "../../FileManager/ExtractCallback.h"
HRESULT ExtractGUI(
CCodecs *codecs,
UStringVector &archivePaths,
UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
+27 -3
View File
@@ -4,6 +4,11 @@
#include <initguid.h>
extern "C"
{
#include "../../../../C/Alloc.h"
}
#include "Common/NewHandler.h"
#include "Common/StringConvert.h"
#include "Common/CommandLineParser.h"
@@ -17,7 +22,6 @@
#include "Windows/FileName.h"
#ifdef _WIN32
#include "Windows/MemoryLock.h"
#include "Common/Alloc.h"
#endif
#include "../../IStream.h"
@@ -33,6 +37,7 @@
#include "ExtractGUI.h"
#include "UpdateGUI.h"
#include "Resource/BenchmarkDialog/BenchmarkDialog.h"
using namespace NWindows;
@@ -83,10 +88,26 @@ int Main2()
if (options.LargePages)
NSecurity::EnableLockMemoryPrivilege();
#endif
CCodecs *codecs = new CCodecs;
CMyComPtr<IUnknown> compressCodecsInfo = codecs;
HRESULT result = codecs->Load();
if (result != S_OK)
throw CSystemException(result);
bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
if (isExtractGroupCommand)
if (options.Command.CommandType == NCommandType::kBenchmark)
{
HRESULT res = Benchmark(
#ifdef EXTERNAL_LZMA
codecs,
#endif
options.NumThreads, options.DictionarySize);
if (res != S_OK)
throw CSystemException(res);
}
else if (isExtractGroupCommand)
{
CExtractCallbackImp *ecs = new CExtractCallbackImp;
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
@@ -109,7 +130,7 @@ int Main2()
eo.Properties = options.ExtractProperties;
#endif
HRESULT result = ExtractGUI(
HRESULT result = ExtractGUI(codecs,
options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
options.WildcardCensor.Pairs.Front().Head,
@@ -138,7 +159,10 @@ int Main2()
CUpdateErrorInfo errorInfo;
if (!options.UpdateOptions.Init(codecs, options.ArchiveName, options.ArcType))
throw "Unsupported archive type";
HRESULT result = UpdateGUI(
codecs,
options.WildcardCensor, options.UpdateOptions,
options.ShowDialog,
errorInfo, &openCallback, &callback);
+519 -458
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,584 @@
// BenchmarkDialog.cpp
#include "StdAfx.h"
#include "Common/IntToString.h"
#include "Common/StringToInt.h"
#include "Common/Exception.h"
#include "Windows/Thread.h"
#include "Windows/Error.h"
#include "Windows/System.h"
#include "../../../../FileManager/HelpUtils.h"
#include "resource.h"
#include "BenchmarkDialog.h"
using namespace NWindows;
// const int kNumBenchDictionaryBitsStart = 21;
static LPCWSTR kHelpTopic = L"fm/benchmark.htm";
static const UINT_PTR kTimerID = 4;
static const UINT kTimerElapse = 1000;
#ifdef LANG
#include "../../../../FileManager/LangUtils.h"
#endif
using namespace NWindows;
#ifdef LANG
static CIDLangPair kIDLangPairs[] =
{
{ IDC_BENCHMARK_DICTIONARY, 0x02000D0C },
{ IDC_BENCHMARK_MEMORY, 0x03080001 },
{ IDC_BENCHMARK_NUM_THREADS, 0x02000D12 },
{ IDC_BENCHMARK_SPEED_LABEL, 0x03080004 },
{ IDC_BENCHMARK_RATING_LABEL, 0x03080005 },
{ IDC_BENCHMARK_COMPRESSING, 0x03080002 },
{ IDC_BENCHMARK_DECOMPRESSING, 0x03080003 },
{ IDC_BENCHMARK_CURRENT, 0x03080007 },
{ IDC_BENCHMARK_RESULTING, 0x03080008 },
{ IDC_BENCHMARK_CURRENT2, 0x03080007 },
{ IDC_BENCHMARK_RESULTING2, 0x03080008 },
{ IDC_BENCHMARK_TOTAL_RATING, 0x03080006 },
{ IDC_BENCHMARK_ELAPSED, 0x02000C01 },
{ IDC_BENCHMARK_SIZE, 0x02000C03 },
{ IDC_BENCHMARK_PASSES, 0x03080009 },
// { IDC_BENCHMARK_ERRORS, 0x0308000A },
{ IDC_BENCHMARK_USAGE_LABEL, 0x0308000B },
{ IDC_BENCHMARK_RPU_LABEL, 0x0308000C },
{ IDC_BENCHMARK_COMBO_NUM_THREADS, 0x02000D12},
{ IDC_BUTTON_STOP, 0x02000714 },
{ IDC_BUTTON_RESTART, 0x02000715 },
{ IDHELP, 0x02000720 },
{ IDCANCEL, 0x02000710 }
};
#endif
static void MyMessageBoxError(HWND hwnd, LPCWSTR message)
{
MessageBoxW(hwnd, message, L"7-Zip", MB_ICONERROR);
}
const LPCTSTR kProcessingString = TEXT("...");
const LPCTSTR kMB = TEXT(" MB");
const LPCTSTR kMIPS = TEXT(" MIPS");
const LPCTSTR kKBs = TEXT(" KB/s");
static const int kMinDicLogSize = 21;
static const UInt32 kMinDicSize = (1 << kMinDicLogSize);
static const UInt32 kMaxDicSize =
#ifdef _WIN64
(1 << 30);
#else
(1 << 27);
#endif
static const int kDefaultDictionary = 22;
bool CBenchmarkDialog::OnInit()
{
#ifdef LANG
LangSetWindowText(HWND(*this), 0x03080000);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_syncInfo.Init();
m_Dictionary.Attach(GetItem(IDC_BENCHMARK_COMBO_DICTIONARY));
int cur = 0;
// _syncInfo.DictionarySize = (1 << kNumBenchDictionaryBitsStart);
UInt32 numCPUs = NSystem::GetNumberOfProcessors();
if (numCPUs < 1)
numCPUs = 1;
numCPUs = MyMin(numCPUs, (UInt32)(1 << 8));
cur = 0;
bool setDefaultThreads = (_syncInfo.NumThreads == (UInt32)(-1));
if (setDefaultThreads)
{
_syncInfo.NumThreads = numCPUs;
if (_syncInfo.NumThreads > 1)
_syncInfo.NumThreads &= ~1;
}
UInt64 ramSize = NSystem::GetRamSize();
bool setDefaultDictionary = (_syncInfo.DictionarySize == (UInt32)(-1));
if (setDefaultDictionary)
{
int dicSizeLog;
for (dicSizeLog = 25; dicSizeLog >= kBenchMinDicLogSize; dicSizeLog--)
if (GetBenchMemoryUsage(_syncInfo.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
break;
_syncInfo.DictionarySize = (1 << dicSizeLog);
}
if (_syncInfo.DictionarySize < kMinDicSize)
_syncInfo.DictionarySize = kMinDicSize;
if (_syncInfo.DictionarySize > kMaxDicSize)
_syncInfo.DictionarySize = kMaxDicSize;
for (int i = kMinDicLogSize; i <= 30; i++)
for (int j = 0; j < 2; j++)
{
UInt32 dictionary = (1 << i) + (j << (i - 1));
if (dictionary > kMaxDicSize)
continue;
TCHAR s[40];
ConvertUInt64ToString((dictionary >> 20), s);
lstrcat(s, kMB);
int index = (int)m_Dictionary.AddString(s);
m_Dictionary.SetItemData(index, dictionary);
if (dictionary <= _syncInfo.DictionarySize)
cur = index;
}
m_Dictionary.SetCurSel(cur);
m_NumThreads.Attach(GetItem(IDC_BENCHMARK_COMBO_NUM_THREADS));
for (UInt32 num = 1; ;)
{
if (num > numCPUs * 2)
break;
TCHAR s[40];
ConvertUInt64ToString(num, s);
int index = (int)m_NumThreads.AddString(s);
m_NumThreads.SetItemData(index, num);
if (num <= numCPUs && setDefaultThreads)
{
_syncInfo.NumThreads = num;
cur = index;
}
if (num > 1)
num++;
num++;
}
m_NumThreads.SetCurSel(cur);
OnChangeSettings();
_syncInfo._startEvent.Set();
_timer = SetTimer(kTimerID, kTimerElapse);
return CModalDialog::OnInit();
}
UInt32 CBenchmarkDialog::GetNumberOfThreads()
{
return (UInt32)m_NumThreads.GetItemData(m_NumThreads.GetCurSel());
}
UInt32 CBenchmarkDialog::OnChangeDictionary()
{
UInt32 dictionary = (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dictionary);
memUsage = (memUsage + (1 << 20) - 1) >> 20;
TCHAR s[40];
ConvertUInt64ToString(memUsage, s);
lstrcat(s, kMB);
SetItemText(IDC_BENCHMARK_MEMORY_VALUE, s);
return dictionary;
}
static const UInt32 g_IDs[] =
{
IDC_BENCHMARK_COMPRESSING_USAGE,
IDC_BENCHMARK_COMPRESSING_USAGE2,
IDC_BENCHMARK_COMPRESSING_SPEED,
IDC_BENCHMARK_COMPRESSING_SPEED2,
IDC_BENCHMARK_COMPRESSING_RATING,
IDC_BENCHMARK_COMPRESSING_RATING2,
IDC_BENCHMARK_COMPRESSING_RPU,
IDC_BENCHMARK_COMPRESSING_RPU2,
IDC_BENCHMARK_DECOMPRESSING_SPEED,
IDC_BENCHMARK_DECOMPRESSING_SPEED2,
IDC_BENCHMARK_DECOMPRESSING_RATING,
IDC_BENCHMARK_DECOMPRESSING_RATING2,
IDC_BENCHMARK_DECOMPRESSING_USAGE,
IDC_BENCHMARK_DECOMPRESSING_USAGE2,
IDC_BENCHMARK_DECOMPRESSING_RPU,
IDC_BENCHMARK_DECOMPRESSING_RPU2,
IDC_BENCHMARK_TOTAL_USAGE_VALUE,
IDC_BENCHMARK_TOTAL_RATING_VALUE,
IDC_BENCHMARK_TOTAL_RPU_VALUE
};
void CBenchmarkDialog::OnChangeSettings()
{
EnableItem(IDC_BUTTON_STOP, true);
UInt32 dictionary = OnChangeDictionary();
TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 };
ConvertUInt64ToString(NSystem::GetNumberOfProcessors(), s + 2);
SetItemText(IDC_BENCHMARK_HARDWARE_THREADS, s);
for (int i = 0; i < sizeof(g_IDs) / sizeof(g_IDs[0]); i++)
SetItemText(g_IDs[i], kProcessingString);
_startTime = GetTickCount();
PrintTime();
NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
_syncInfo.Init();
_syncInfo.DictionarySize = dictionary;
_syncInfo.Changed = true;
_syncInfo.NumThreads = GetNumberOfThreads();
}
void CBenchmarkDialog::OnRestartButton()
{
OnChangeSettings();
}
void CBenchmarkDialog::OnStopButton()
{
EnableItem(IDC_BUTTON_STOP, false);
_syncInfo.Pause();
}
void CBenchmarkDialog::OnHelp()
{
ShowHelpWindow(NULL, kHelpTopic);
}
void CBenchmarkDialog::OnCancel()
{
_syncInfo.Stop();
KillTimer(_timer);
CModalDialog::OnCancel();
}
static void GetTimeString(UInt64 timeValue, TCHAR *s)
{
wsprintf(s, TEXT("%02d:%02d:%02d"),
UInt32(timeValue / 3600),
UInt32((timeValue / 60) % 60),
UInt32(timeValue % 60));
}
void CBenchmarkDialog::PrintTime()
{
UInt32 curTime = ::GetTickCount();
UInt32 elapsedTime = (curTime - _startTime);
UInt32 elapsedSec = elapsedTime / 1000;
if (elapsedSec != 0 && _syncInfo.WasPaused())
return;
TCHAR s[40];
GetTimeString(elapsedSec, s);
SetItemText(IDC_BENCHMARK_ELAPSED_VALUE, s);
}
void CBenchmarkDialog::PrintRating(UInt64 rating, UINT controlID)
{
TCHAR s[40];
ConvertUInt64ToString(rating / 1000000, s);
lstrcat(s, kMIPS);
SetItemText(controlID, s);
}
void CBenchmarkDialog::PrintUsage(UInt64 usage, UINT controlID)
{
TCHAR s[40];
ConvertUInt64ToString((usage + 5000) / 10000, s);
lstrcat(s, TEXT("%"));
SetItemText(controlID, s);
}
void CBenchmarkDialog::PrintResults(
UInt32 dictionarySize,
const CBenchInfo2 &info,
UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
bool decompressMode)
{
if (info.GlobalTime == 0)
return;
UInt64 size = info.UnpackSize;
TCHAR s[40];
{
UInt64 speed = size * info.GlobalFreq / info.GlobalTime;
ConvertUInt64ToString(speed / 1024, s);
lstrcat(s, kKBs);
SetItemText(speedID, s);
}
UInt64 rating;
if (decompressMode)
rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, size, info.PackSize, 1);
else
rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, size * info.NumIterations);
PrintRating(rating, ratingID);
PrintRating(GetRatingPerUsage(info, rating), rpuID);
PrintUsage(GetUsage(info), usageID);
}
bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
{
PrintTime();
NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
TCHAR s[40];
ConvertUInt64ToString((_syncInfo.ProcessedSize >> 20), s);
lstrcat(s, kMB);
SetItemText(IDC_BENCHMARK_SIZE_VALUE, s);
ConvertUInt64ToString(_syncInfo.NumPasses, s);
SetItemText(IDC_BENCHMARK_PASSES_VALUE, s);
/*
ConvertUInt64ToString(_syncInfo.NumErrors, s);
SetItemText(IDC_BENCHMARK_ERRORS_VALUE, s);
*/
{
UInt32 dicSizeTemp = (UInt32)MyMax(_syncInfo.ProcessedSize, UInt64(1) << 20);
dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize),
PrintResults(dicSizeTemp,
_syncInfo.CompressingInfoTemp,
IDC_BENCHMARK_COMPRESSING_USAGE,
IDC_BENCHMARK_COMPRESSING_SPEED,
IDC_BENCHMARK_COMPRESSING_RPU,
IDC_BENCHMARK_COMPRESSING_RATING);
}
{
PrintResults(
_syncInfo.DictionarySize,
_syncInfo.CompressingInfo,
IDC_BENCHMARK_COMPRESSING_USAGE2,
IDC_BENCHMARK_COMPRESSING_SPEED2,
IDC_BENCHMARK_COMPRESSING_RPU2,
IDC_BENCHMARK_COMPRESSING_RATING2);
}
{
PrintResults(
_syncInfo.DictionarySize,
_syncInfo.DecompressingInfoTemp,
IDC_BENCHMARK_DECOMPRESSING_USAGE,
IDC_BENCHMARK_DECOMPRESSING_SPEED,
IDC_BENCHMARK_DECOMPRESSING_RPU,
IDC_BENCHMARK_DECOMPRESSING_RATING,
true);
}
{
PrintResults(
_syncInfo.DictionarySize,
_syncInfo.DecompressingInfo,
IDC_BENCHMARK_DECOMPRESSING_USAGE2,
IDC_BENCHMARK_DECOMPRESSING_SPEED2,
IDC_BENCHMARK_DECOMPRESSING_RPU2,
IDC_BENCHMARK_DECOMPRESSING_RATING2,
true);
if (_syncInfo.DecompressingInfo.GlobalTime > 0 &&
_syncInfo.CompressingInfo.GlobalTime > 0)
{
UInt64 comprRating = GetCompressRating(_syncInfo.DictionarySize,
_syncInfo.CompressingInfo.GlobalTime, _syncInfo.CompressingInfo.GlobalFreq, _syncInfo.CompressingInfo.UnpackSize);
UInt64 decomprRating = GetDecompressRating(_syncInfo.DecompressingInfo.GlobalTime,
_syncInfo.DecompressingInfo.GlobalFreq, _syncInfo.DecompressingInfo.UnpackSize,
_syncInfo.DecompressingInfo.PackSize, 1);
PrintRating((comprRating + decomprRating) / 2, IDC_BENCHMARK_TOTAL_RATING_VALUE);
PrintRating((
GetRatingPerUsage(_syncInfo.CompressingInfo, comprRating) +
GetRatingPerUsage(_syncInfo.DecompressingInfo, decomprRating)) / 2, IDC_BENCHMARK_TOTAL_RPU_VALUE);
PrintUsage((GetUsage(_syncInfo.CompressingInfo) + GetUsage(_syncInfo.DecompressingInfo)) / 2, IDC_BENCHMARK_TOTAL_USAGE_VALUE);
}
}
return true;
}
bool CBenchmarkDialog::OnCommand(int code, int itemID, LPARAM lParam)
{
if (code == CBN_SELCHANGE &&
(itemID == IDC_BENCHMARK_COMBO_DICTIONARY ||
itemID == IDC_BENCHMARK_COMBO_NUM_THREADS))
{
OnChangeSettings();
return true;
}
return CModalDialog::OnCommand(code, itemID, lParam);
}
bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
{
switch(buttonID)
{
case IDC_BUTTON_RESTART:
OnRestartButton();
return true;
case IDC_BUTTON_STOP:
OnStopButton();
return true;
}
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
struct CThreadBenchmark
{
CProgressSyncInfo *SyncInfo;
UInt64 _startTime;
#ifdef EXTERNAL_LZMA
CCodecs *codecs;
#endif
// UInt32 dictionarySize;
// UInt32 numThreads;
HRESULT Process();
HRESULT Result;
static DWORD WINAPI MyThreadFunction(void *param)
{
((CThreadBenchmark *)param)->Result = ((CThreadBenchmark *)param)->Process();
return 0;
}
};
struct CBenchCallback: public IBenchCallback
{
UInt32 dictionarySize;
CProgressSyncInfo *SyncInfo;
HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
};
HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
{
NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped)
return E_ABORT;
SyncInfo->ProcessedSize = info.UnpackSize;
if (final && SyncInfo->CompressingInfo.GlobalTime == 0)
{
(CBenchInfo&)SyncInfo->CompressingInfo = info;
if (SyncInfo->CompressingInfo.GlobalTime == 0)
SyncInfo->CompressingInfo.GlobalTime = 1;
}
else
(CBenchInfo&)SyncInfo->CompressingInfoTemp = info;
return S_OK;
}
HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
{
NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped)
return E_ABORT;
CBenchInfo info2 = info;
if (info2.NumIterations == 0)
info2.NumIterations = 1;
info2.GlobalTime /= info2.NumIterations;
info2.UserTime /= info2.NumIterations;
if (final && SyncInfo->DecompressingInfo.GlobalTime == 0)
{
(CBenchInfo&)SyncInfo->DecompressingInfo = info2;
if (SyncInfo->DecompressingInfo.GlobalTime == 0)
SyncInfo->DecompressingInfo.GlobalTime = 1;
}
else
(CBenchInfo&)SyncInfo->DecompressingInfoTemp = info2;
return S_OK;
}
HRESULT CThreadBenchmark::Process()
{
try
{
SyncInfo->WaitCreating();
for (;;)
{
if (SyncInfo->WasStopped())
return 0;
if (SyncInfo->WasPaused())
{
Sleep(200);
continue;
}
UInt32 dictionarySize;
UInt32 numThreads;
{
NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
if (SyncInfo->Stopped || SyncInfo->Paused)
continue;
if (SyncInfo->Changed)
SyncInfo->Init();
dictionarySize = SyncInfo->DictionarySize;
numThreads = SyncInfo->NumThreads;
}
CBenchCallback callback;
callback.dictionarySize = dictionarySize;
callback.SyncInfo = SyncInfo;
HRESULT result;
try
{
result = LzmaBench(
#ifdef EXTERNAL_LZMA
codecs,
#endif
numThreads, dictionarySize, &callback);
}
catch(...)
{
result = E_FAIL;
}
if (result != S_OK)
{
if (result != E_ABORT)
{
// SyncInfo->NumErrors++;
{
NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
SyncInfo->Pause();
}
CSysString message;
if (result == S_FALSE)
message = TEXT("Decoding error");
else
message = NError::MyFormatMessage(result);
MessageBox(0, message, TEXT("7-Zip"), MB_ICONERROR);
}
}
else
{
NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
SyncInfo->NumPasses++;
}
}
// return S_OK;
}
catch(CSystemException &e)
{
MessageBox(0, NError::MyFormatMessage(e.ErrorCode), TEXT("7-Zip"), MB_ICONERROR);
return E_FAIL;
}
catch(...)
{
MyMessageBoxError(0, L"Some error");
return E_FAIL;
}
}
HRESULT Benchmark(
#ifdef EXTERNAL_LZMA
CCodecs *codecs,
#endif
UInt32 numThreads, UInt32 dictionarySize)
{
CThreadBenchmark benchmarker;
#ifdef EXTERNAL_LZMA
benchmarker.codecs = codecs;
#endif
CBenchmarkDialog benchmarkDialog;
benchmarkDialog._syncInfo.DictionarySize = dictionarySize;
benchmarkDialog._syncInfo.NumThreads = numThreads;
benchmarker.SyncInfo = &benchmarkDialog._syncInfo;
CThread thread;
if (!thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker))
return E_FAIL;
benchmarkDialog.Create(0);
thread.Wait();
return S_OK;
}
+126
View File
@@ -0,0 +1,126 @@
// BenchmarkDialog.h
#ifndef __BENCHMARKDIALOG_H
#define __BENCHMARKDIALOG_H
#include "resource.h"
#include "Windows/Control/Dialog.h"
#include "Windows/Control/ComboBox.h"
#include "Windows/Synchronization.h"
#include "../../../../Compress/LZMA_Alone/LzmaBench.h"
#ifdef EXTERNAL_LZMA
#include "../../../../UI/Common/LoadCodecs.h"
#endif
struct CBenchInfo2 : public CBenchInfo
{
void Init() { GlobalTime = UserTime = 0; }
};
class CProgressSyncInfo
{
public:
bool Stopped;
bool Paused;
bool Changed;
UInt32 DictionarySize;
UInt32 NumThreads;
UInt64 NumPasses;
// UInt64 NumErrors;
NWindows::NSynchronization::CManualResetEvent _startEvent;
NWindows::NSynchronization::CCriticalSection CS;
CBenchInfo2 CompressingInfoTemp;
CBenchInfo2 CompressingInfo;
UInt64 ProcessedSize;
CBenchInfo2 DecompressingInfoTemp;
CBenchInfo2 DecompressingInfo;
void Init()
{
Changed = false;
Stopped = false;
Paused = false;
CompressingInfoTemp.Init();
CompressingInfo.Init();
ProcessedSize = 0;
DecompressingInfoTemp.Init();
DecompressingInfo.Init();
NumPasses = 0;
// NumErrors = 0;
}
void Stop()
{
NWindows::NSynchronization::CCriticalSectionLock lock(CS);
Stopped = true;
}
bool WasStopped()
{
NWindows::NSynchronization::CCriticalSectionLock lock(CS);
return Stopped;
}
void Pause()
{
NWindows::NSynchronization::CCriticalSectionLock lock(CS);
Paused = true;
}
void Start()
{
NWindows::NSynchronization::CCriticalSectionLock lock(CS);
Paused = false;
}
bool WasPaused()
{
NWindows::NSynchronization::CCriticalSectionLock lock(CS);
return Paused;
}
void WaitCreating() { _startEvent.Lock(); }
};
class CBenchmarkDialog:
public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox m_Dictionary;
NWindows::NControl::CComboBox m_NumThreads;
UINT_PTR _timer;
UINT32 _startTime;
bool OnTimer(WPARAM timerID, LPARAM callback);
virtual bool OnInit();
void OnRestartButton();
void OnStopButton();
void OnHelp();
virtual void OnCancel();
bool OnButtonClicked(int buttonID, HWND buttonHWND);
bool OnCommand(int code, int itemID, LPARAM lParam);
void PrintTime();
void PrintRating(UInt64 rating, UINT controlID);
void PrintUsage(UInt64 usage, UINT controlID);
void PrintResults(
UINT32 dictionarySize,
const CBenchInfo2 &info, UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
bool decompressMode = false);
UInt32 GetNumberOfThreads();
UInt32 OnChangeDictionary();
void OnChangeSettings();
public:
CProgressSyncInfo _syncInfo;
CBenchmarkDialog(): _timer(0) {}
INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
};
HRESULT Benchmark(
#ifdef EXTERNAL_LZMA
CCodecs *codecs,
#endif
UInt32 dictionarySize, UInt32 numThreads);
#endif
+16
View File
@@ -0,0 +1,16 @@
// stdafx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#define _WIN32_WINNT 0x0400
// it's for Windows NT supporting (MENUITEMINFOW)
#define WINVER 0x0400
#include <windows.h>
#include <commctrl.h>
#include "Common/NewHandler.h"
#endif
+54
View File
@@ -0,0 +1,54 @@
#define IDD_DIALOG_BENCHMARK 800
#define IDC_BUTTON_STOP 1001
#define IDC_BUTTON_RESTART 1002
#define IDC_BENCHMARK_DICTIONARY 1010
#define IDC_BENCHMARK_COMBO_DICTIONARY 1011
#define IDC_BENCHMARK_MEMORY 1012
#define IDC_BENCHMARK_MEMORY_VALUE 1013
#define IDC_BENCHMARK_NUM_THREADS 1014
#define IDC_BENCHMARK_COMBO_NUM_THREADS 1015
#define IDC_BENCHMARK_HARDWARE_THREADS 1016
#define IDC_BENCHMARK_SPEED_LABEL 1020
#define IDC_BENCHMARK_RATING_LABEL 1021
#define IDC_BENCHMARK_COMPRESSING 1022
#define IDC_BENCHMARK_DECOMPRESSING 1023
#define IDC_BENCHMARK_CURRENT 1024
#define IDC_BENCHMARK_RESULTING 1025
#define IDC_BENCHMARK_CURRENT2 1026
#define IDC_BENCHMARK_RESULTING2 1027
#define IDC_BENCHMARK_USAGE_LABEL 1028
#define IDC_BENCHMARK_RPU_LABEL 1029
#define IDC_BENCHMARK_COMPRESSING_SPEED 1030
#define IDC_BENCHMARK_COMPRESSING_SPEED2 1031
#define IDC_BENCHMARK_COMPRESSING_RATING 1032
#define IDC_BENCHMARK_COMPRESSING_RATING2 1033
#define IDC_BENCHMARK_COMPRESSING_USAGE 1034
#define IDC_BENCHMARK_COMPRESSING_USAGE2 1035
#define IDC_BENCHMARK_COMPRESSING_RPU 1036
#define IDC_BENCHMARK_COMPRESSING_RPU2 1037
#define IDC_BENCHMARK_DECOMPRESSING_SPEED 1040
#define IDC_BENCHMARK_DECOMPRESSING_SPEED2 1041
#define IDC_BENCHMARK_DECOMPRESSING_RATING 1042
#define IDC_BENCHMARK_DECOMPRESSING_RATING2 1043
#define IDC_BENCHMARK_DECOMPRESSING_USAGE 1044
#define IDC_BENCHMARK_DECOMPRESSING_USAGE2 1045
#define IDC_BENCHMARK_DECOMPRESSING_RPU 1046
#define IDC_BENCHMARK_DECOMPRESSING_RPU2 1047
#define IDC_BENCHMARK_TOTAL_RATING 1050
#define IDC_BENCHMARK_TOTAL_RATING_VALUE 1051
#define IDC_BENCHMARK_TOTAL_RPU_VALUE 1052
#define IDC_BENCHMARK_TOTAL_USAGE_VALUE 1053
#define IDC_BENCHMARK_ELAPSED 1060
#define IDC_BENCHMARK_ELAPSED_VALUE 1061
#define IDC_BENCHMARK_SIZE 1062
#define IDC_BENCHMARK_SIZE_VALUE 1063
#define IDC_BENCHMARK_PASSES 1066
#define IDC_BENCHMARK_PASSES_VALUE 1067
+116
View File
@@ -0,0 +1,116 @@
#include "resource.h"
#include "../../../../GuiCommon.rc"
#define xSize2 330
#define ySize2 228
#define xSize (xSize2 + marg + marg)
#define ySize (ySize2 + marg + marg)
#undef g0XSize
#undef g1XPos
#undef g1XSize
#undef g2XSize
#undef g3XPos
#undef g3XSize
#define bXPos1 (xSize - marg - bXSize)
#define bXPos2 (bXPos1 - 10 - bXSize)
#define bYPos (ySize - marg - bYSize)
#define gSize 160
#define gSpace 24
#define g0XSize 90
#define g1XSize 44
#define g1XPos (marg + g0XSize)
#define gc2XPos (g1XPos + g1XSize + 10)
#define gc2XSize 80
#define g10XPos (marg + marg)
#define gRatingSize 60
#define gSpeedSize 60
#define gUsageSize 60
#define gRpuSize 60
#define gRatingPos (xSize - marg - marg - gRatingSize)
#define gRpuPos (gRatingPos - gRpuSize)
#define gUsagePos (gRpuPos - gUsageSize)
#define gSpeedPos (gUsagePos - gSpeedSize)
#define gLabelSize (gUsagePos - g10XPos)
#define gTotalRatingSize (gUsageSize + gRpuSize + gRatingSize + marg + marg)
#define gTotalRatingPos (xSize - marg - gTotalRatingSize)
#define g2XSize 58
#define g3XSize 36
#define g3XPos (marg + g2XSize)
IDD_DIALOG_BENCHMARK DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
CAPTION "Benchmark"
MY_FONT
BEGIN
PUSHBUTTON "&Restart", IDC_BUTTON_RESTART, bXPos1, marg, bXSize, bYSize
PUSHBUTTON "&Stop", IDC_BUTTON_STOP, bXPos1, 27, bXSize, bYSize
PUSHBUTTON "&Help", IDHELP, bXPos2, bYPos, bXSize,bYSize
PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize
LTEXT "&Dictionary size:", IDC_BENCHMARK_DICTIONARY, marg, marg + 1, g0XSize, 8
COMBOBOX IDC_BENCHMARK_COMBO_DICTIONARY, g1XPos, marg, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Number of CPU threads:", IDC_BENCHMARK_NUM_THREADS, marg, 24, g0XSize, 8
COMBOBOX IDC_BENCHMARK_COMBO_NUM_THREADS, g1XPos, 23, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Memory usage:", IDC_BENCHMARK_MEMORY, gc2XPos, marg + 1, gc2XSize, 8
LTEXT "0 MB", IDC_BENCHMARK_MEMORY_VALUE, gc2XPos + gc2XSize, marg + 1, 40, 8
LTEXT "1", IDC_BENCHMARK_HARDWARE_THREADS, gc2XPos, 24, 40, 8
RTEXT "CPU Usage", IDC_BENCHMARK_USAGE_LABEL, gUsagePos, 53, gUsageSize, 8
RTEXT "Speed", IDC_BENCHMARK_SPEED_LABEL, gSpeedPos, 53, gSpeedSize, 8
RTEXT "Rating / Usage", IDC_BENCHMARK_RPU_LABEL, gRpuPos, 53, gRpuSize, 8
RTEXT "Rating", IDC_BENCHMARK_RATING_LABEL, gRatingPos, 53, gRatingSize, 8
GROUPBOX "Compressing", IDC_BENCHMARK_COMPRESSING, marg, 64, xSize2, 40
LTEXT "Current", IDC_BENCHMARK_CURRENT, g10XPos, 76, gLabelSize, 8
RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE, gUsagePos, 76, gUsageSize, 8
RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED, gSpeedPos, 76, gSpeedSize, 8
RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU, gRpuPos, 76, gRpuSize, 8
RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING, gRatingPos, 76, gRatingSize, 8
LTEXT "Resulting", IDC_BENCHMARK_RESULTING, g10XPos, 89, gLabelSize, 8
RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE2, gUsagePos, 89, gUsageSize, 8
RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED2, gSpeedPos, 89, gSpeedSize, 8
RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU2, gRpuPos, 89, gRpuSize, 8
RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING2, gRatingPos, 89, gRatingSize, 8
GROUPBOX "Decompressing", IDC_BENCHMARK_DECOMPRESSING, marg, 111, xSize2, 40
LTEXT "Current", IDC_BENCHMARK_CURRENT2, g10XPos, 123, gLabelSize, 8
RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE, gUsagePos, 123, gUsageSize, 8
RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED, gSpeedPos, 123, gSpeedSize, 8
RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU, gRpuPos, 123, gRpuSize, 8
RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING, gRatingPos, 123, gRatingSize, 8
LTEXT "Resulting", IDC_BENCHMARK_RESULTING2, g10XPos, 136, gLabelSize, 8
RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE2, gUsagePos, 136, gUsageSize, 8
RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED2, gSpeedPos, 136, gSpeedSize, 8
RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU2, gRpuPos, 136, gRpuSize, 8
RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING2, gRatingPos, 136, gRatingSize, 8
GROUPBOX "Total Rating", IDC_BENCHMARK_TOTAL_RATING, gTotalRatingPos, 163, gTotalRatingSize, 38
RTEXT "0", IDC_BENCHMARK_TOTAL_USAGE_VALUE, gUsagePos, 181, gUsageSize, 8
RTEXT "0", IDC_BENCHMARK_TOTAL_RPU_VALUE, gRpuPos, 181, gRpuSize, 8
RTEXT "0", IDC_BENCHMARK_TOTAL_RATING_VALUE, gRatingPos, 181, gRatingSize, 8
LTEXT "Elapsed time:", IDC_BENCHMARK_ELAPSED, marg, 163, g2XSize, 8
LTEXT "Size:", IDC_BENCHMARK_SIZE, marg, 176, g2XSize, 8
LTEXT "Passes:", IDC_BENCHMARK_PASSES, marg, 189, g2XSize, 8
RTEXT "00:00:00", IDC_BENCHMARK_ELAPSED_VALUE, g3XPos, 163, g3XSize, 8
RTEXT "0", IDC_BENCHMARK_SIZE_VALUE, g3XPos, 176, g3XSize, 8
RTEXT "0", IDC_BENCHMARK_PASSES_VALUE, g3XPos, 189, g3XSize, 8
END
+36 -35
View File
@@ -36,8 +36,9 @@ static const wchar_t *kSFXExtension = L"exe";
struct CThreadUpdating
{
CUpdateCallbackGUI *UpdateCallbackGUI;
CCodecs *codecs;
CUpdateCallbackGUI *UpdateCallbackGUI;
const NWildcard::CCensor *WildcardCensor;
CUpdateOptions *Options;
COpenCallbackGUI *OpenCallback;
@@ -50,7 +51,7 @@ struct CThreadUpdating
UpdateCallbackGUI->ProgressDialog.WaitCreating();
try
{
Result = UpdateArchive(*WildcardCensor, *Options,
Result = UpdateArchive(codecs, *WildcardCensor, *Options,
*ErrorInfo, OpenCallback, UpdateCallbackGUI);
}
catch(const UString &s)
@@ -81,8 +82,7 @@ struct CThreadUpdating
}
};
static void AddProp(CObjectVector<CProperty> &properties,
const UString &name, const UString &value)
static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value)
{
CProperty prop;
prop.Name = name;
@@ -90,16 +90,14 @@ static void AddProp(CObjectVector<CProperty> &properties,
properties.Add(prop);
}
static void AddProp(CObjectVector<CProperty> &properties,
const UString &name, UInt32 value)
static void AddProp(CObjectVector<CProperty> &properties, const UString &name, UInt32 value)
{
wchar_t tmp[32];
ConvertUInt64ToString(value, tmp);
AddProp(properties, name, tmp);
}
static void AddProp(CObjectVector<CProperty> &properties,
const UString &name, bool value)
static void AddProp(CObjectVector<CProperty> &properties, const UString &name, bool value)
{
AddProp(properties, name, value ? UString(L"on"): UString(L"off"));
}
@@ -149,6 +147,16 @@ static void ParseAndAddPropertires(CObjectVector<CProperty> &properties,
}
}
static UString GetNumInBytesString(UInt64 v)
{
wchar_t s[32];
ConvertUInt64ToString(v, s);
size_t len = wcslen(s);
s[len++] = L'B';
s[len] = L'\0';
return s;
}
static void SetOutProperties(
CObjectVector<CProperty> &properties,
bool is7z,
@@ -158,8 +166,8 @@ static void SetOutProperties(
UInt32 dictionary,
bool orderMode,
UInt32 order,
bool solidModeIsAllowed, bool solidMode,
bool multiThreadIsAllowed, bool multiThread,
bool solidIsSpecified, UInt64 solidBlockSize,
bool multiThreadIsAllowed, UInt32 numThreads,
const UString &encryptionMethod,
bool encryptHeadersIsAllowed, bool encryptHeaders,
bool /* sfxMode */)
@@ -179,12 +187,7 @@ static void SetOutProperties(
name += L"mem";
else
name += L"d";
wchar_t s[32];
ConvertUInt64ToString(dictionary, s);
size_t len = wcslen(s);
s[len++] = L'B';
s[len] = L'\0';
AddProp(properties, name, UString(s));
AddProp(properties, name, GetNumInBytesString(dictionary));
}
if (order != (UInt32)(Int32)-1)
{
@@ -204,20 +207,19 @@ static void SetOutProperties(
if (encryptHeadersIsAllowed)
AddProp(properties, L"he", encryptHeaders);
if (solidModeIsAllowed)
AddProp(properties, L"s", solidMode);
if (solidIsSpecified)
AddProp(properties, L"s", GetNumInBytesString(solidBlockSize));
if (multiThreadIsAllowed)
AddProp(properties, L"mt", multiThread);
AddProp(properties, L"mt", numThreads);
}
static HRESULT ShowDialog(const NWildcard::CCensor &censor,
static HRESULT ShowDialog(
CCodecs *codecs,
const NWildcard::CCensor &censor,
CUpdateOptions &options, CUpdateCallbackGUI *callback)
{
if (options.Commands.Size() != 1)
throw "It must be one command";
CObjectVector<CArchiverInfo> archivers;
CArchiverInfo archiverInfo;
ReadArchiverInfoList(archivers);
UString currentDirPrefix;
{
if (!NDirectory::MyGetCurrentDirectory(currentDirPrefix))
@@ -253,9 +255,9 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
CCompressDialog dialog;
NCompressDialog::CInfo &di = dialog.Info;
for(int i = 0; i < archivers.Size(); i++)
for(int i = 0; i < codecs->Formats.Size(); i++)
{
const CArchiverInfo &ai = archivers[i];
const CArcInfoEx &ai = codecs->Formats[i];
if (ai.UpdateEnabled && (oneFile || !ai.KeepName))
dialog.m_ArchiverInfoList.Add(ai);
}
@@ -272,9 +274,6 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
di.CurrentDirPrefix = currentDirPrefix;
di.SFXMode = options.SfxMode;
di.Solid = true;
di.MultiThread = false;
if (callback->PasswordIsDefined)
di.Password = callback->Password;
@@ -311,7 +310,7 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
default:
throw 1091756;
}
archiverInfo = dialog.m_ArchiverInfoList[di.ArchiverInfoIndex];
const CArcInfoEx &archiverInfo = dialog.m_ArchiverInfoList[di.ArchiverInfoIndex];
callback->PasswordIsDefined = (!di.Password.IsEmpty());
if (callback->PasswordIsDefined)
callback->Password = di.Password;
@@ -329,8 +328,8 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
di.Method,
di.Dictionary,
di.OrderMode, di.Order,
di.SolidIsAllowed, di.Solid,
di.MultiThreadIsAllowed, di.MultiThread,
di.SolidIsSpecified, di.SolidBlockSize,
di.MultiThreadIsAllowed, di.NumThreads,
di.EncryptionMethod,
di.EncryptHeadersIsAllowed, di.EncryptHeaders,
di.SFXMode);
@@ -339,10 +338,9 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
if (di.SFXMode)
options.SfxMode = true;
options.MethodMode.FilePath = archiverInfo.FilePath;
options.MethodMode.ClassID = archiverInfo.ClassID;
options.MethodMode.FormatIndex = archiverInfo.FormatIndex;
options.ArchivePath.VolExtension = archiverInfo.GetMainExtension();
options.ArchivePath.VolExtension = archiverInfo.GetMainExt();
if(di.SFXMode)
options.ArchivePath.BaseExtension = kSFXExtension;
else
@@ -363,6 +361,7 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
}
HRESULT UpdateGUI(
CCodecs *codecs,
const NWildcard::CCensor &censor,
CUpdateOptions &options,
bool showDialog,
@@ -372,13 +371,15 @@ HRESULT UpdateGUI(
{
if (showDialog)
{
RINOK(ShowDialog(censor, options, callback));
RINOK(ShowDialog(codecs, censor, options, callback));
}
if (options.SfxMode && options.SfxModule.IsEmpty())
options.SfxModule = kDefaultSfxModule;
CThreadUpdating tu;
tu.codecs = codecs;
tu.UpdateCallbackGUI = callback;
tu.UpdateCallbackGUI->Init();
+1
View File
@@ -10,6 +10,7 @@
#include "../../FileManager/UpdateCallback100.h"
HRESULT UpdateGUI(
CCodecs *codecs,
const NWildcard::CCensor &censor,
CUpdateOptions &options,
bool showDialog,
+31 -3
View File
@@ -1,6 +1,13 @@
PROG = 7zG.exe
LIBS = $(LIBS) user32.lib advapi32.lib oleaut32.lib shell32.lib comctl32.lib htmlhelp.lib ole32.lib comdlg32.lib
CFLAGS = $(CFLAGS) -I ../../../ -DLANG -DCOMPRESS_MT -DWIN_LONG_PATH
CFLAGS = $(CFLAGS) -I ../../../ \
-DLANG \
-DCOMPRESS_MT \
-DWIN_LONG_PATH \
-DEXTERNAL_LZMA \
-DEXTERNAL_CODECS \
-DBENCH_MT \
-D_7ZIP_LARGE_PAGES \
GUI_OBJS = \
$O\CompressDialog.obj \
@@ -12,8 +19,8 @@ GUI_OBJS = \
$O\UpdateGUI.obj \
COMMON_OBJS = \
$O\Alloc.obj \
$O\CommandLineParser.obj \
$O\CRC.obj \
$O\IntToString.obj \
$O\Lang.obj \
$O\ListFileUtils.obj \
@@ -58,11 +65,11 @@ UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
$O\ArchiverInfo.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
$O\ExtractingFilePath.obj \
$O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SetProperties.obj \
@@ -76,6 +83,9 @@ UI_COMMON_OBJS = \
$O\WorkDir.obj \
$O\ZipRegistry.obj \
LZMA_BENCH_OBJS = \
$O\LzmaBench.obj \
FM_OBJS = \
$O\ExtractCallback.obj \
$O\FormatUtils.obj \
@@ -88,6 +98,11 @@ FM_OBJS = \
$O\StringUtils.obj \
$O\UpdateCallback100.obj \
C_OBJS = \
$O\Alloc.obj \
!include "../../Crc2.mak"
OBJS = \
$O\StdAfx.obj \
$(GUI_OBJS) \
@@ -102,7 +117,11 @@ OBJS = \
$O\OverwriteDialog.obj \
$O\PasswordDialog.obj \
$O\ProgressDialog.obj \
$O\BenchmarkDialog.obj \
$O\CopyCoder.obj \
$(LZMA_BENCH_OBJS) \
$(C_OBJS) \
$(CRC_OBJS) \
$O\resource.res
!include "../../../Build.mak"
@@ -131,5 +150,14 @@ $O\PasswordDialog.obj: ../../FileManager/Resource/PasswordDialog/$(*B).cpp
$(COMPL)
$O\ProgressDialog.obj: ../../FileManager/Resource/ProgressDialog2/$(*B).cpp
$(COMPL)
$O\BenchmarkDialog.obj: Resource/BenchmarkDialog/$(*B).cpp
$(COMPL)
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
$(COMPL)
$(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*B).cpp
$(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
!include "../../Crc.mak"
+3
View File
@@ -17,6 +17,9 @@
#define IDS_METHOD_FASTEST 85
#define IDS_METHOD_ULTRA 86
#define IDS_COMPRESS_NON_SOLID 88
#define IDS_COMPRESS_SOLID 89
#define IDS_COMPRESS_UPDATE_MODE_ADD 90
#define IDS_COMPRESS_UPDATE_MODE_UPDATE 91
#define IDS_COMPRESS_UPDATE_MODE_FRESH 92
+4
View File
@@ -27,6 +27,9 @@ BEGIN
IDS_METHOD_FAST "Fast"
IDS_METHOD_FASTEST "Fastest"
IDS_METHOD_ULTRA "Ultra"
IDS_COMPRESS_NON_SOLID "Non-solid"
IDS_COMPRESS_SOLID "Solid"
IDS_COMPRESS_UPDATE_MODE_ADD "Add and replace files"
IDS_COMPRESS_UPDATE_MODE_UPDATE "Update and add files"
IDS_COMPRESS_UPDATE_MODE_FRESH "Freshen existing files"
@@ -55,3 +58,4 @@ END
#include "../Resource/Extract/resource.rc"
#include "../Resource/ExtractDialog/resource.rc"
#include "../Resource/CompressDialog/resource.rc"
#include "Resource/BenchmarkDialog/resource.rc"