Update to 7-Zip 17.00 Beta

This commit is contained in:
Tino Reichardt
2017-04-30 14:14:14 +02:00
parent 54389d6e2f
commit aa5ba75da0
451 changed files with 15746 additions and 8574 deletions

View File

@@ -23,9 +23,7 @@
using namespace NWindows;
void GetCpuName(AString &s);
static LPCWSTR kHelpTopic = L"fm/benchmark.htm";
#define kHelpTopic "fm/benchmark.htm"
static const UINT_PTR kTimerID = 4;
static const UINT kTimerElapse = 1000;
@@ -66,10 +64,10 @@ static const UInt32 kLangIDs_Colon[] =
#endif
static const LPCTSTR kProcessingString = TEXT("...");
static const LPCTSTR kMB = TEXT(" MB");
static const LPCTSTR kMIPS = TEXT(" MIPS");
static const LPCTSTR kKBs = TEXT(" KB/s");
static LPCTSTR const kProcessingString = TEXT("...");
static LPCTSTR const kMB = TEXT(" MB");
static LPCTSTR const kMIPS = TEXT(" MIPS");
static LPCTSTR const kKBs = TEXT(" KB/s");
static const unsigned kMinDicLogSize =
#ifdef UNDER_CE
@@ -119,35 +117,67 @@ bool CBenchmarkDialog::OnInit()
_consoleEdit.SendMsg(WM_SETFONT, (WPARAM)_font._font, TRUE);
}
UInt32 numCPUs = 1;
{
TCHAR s[40];
s[0] = '/';
s[1] = ' ';
ConvertUInt32ToString(NSystem::GetNumberOfProcessors(), s + 2);
UString s ("/ ");
NSystem::CProcessAffinity threadsInfo;
threadsInfo.InitST();
#ifndef _7ZIP_ST
if (threadsInfo.Get() && threadsInfo.processAffinityMask != 0)
numCPUs = threadsInfo.GetNumProcessThreads();
else
numCPUs = NSystem::GetNumberOfProcessors();
#endif
s.Add_UInt32(numCPUs);
s += GetProcessThreadsInfo(threadsInfo);
SetItemText(IDT_BENCH_HARDWARE_THREADS, s);
}
{
UString s;
{
AString cpuName;
GetCpuName(cpuName);
s.SetFromAscii(cpuName);
AString s1, s2;
GetSysInfo(s1, s2);
s = s1;
SetItemText(IDT_BENCH_SYS1, s);
if (s1 != s2 && !s2.IsEmpty())
{
s = s2;
SetItemText(IDT_BENCH_SYS2, s);
}
}
/*
{
GetVersionString(s);
SetItemText(IDT_BENCH_SYSTEM, s);
}
*/
{
AString s2;
GetCpuName(s2);
s = s2;
SetItemText(IDT_BENCH_CPU, s);
}
/*
{
AString s2;
GetCpuFeatures(s2);
s = s2;
SetItemText(IDT_BENCH_CPU_FEATURE, s);
}
*/
s.SetFromAscii("7-Zip " MY_VERSION " ["
#ifdef MY_CPU_64BIT
"64-bit"
#elif defined MY_CPU_32BIT
"32-bit"
#endif
"]");
s = "7-Zip " MY_VERSION_CPU;
SetItemText(IDT_BENCH_VER, s);
}
UInt32 numCPUs = NSystem::GetNumberOfProcessors();
if (numCPUs < 1)
numCPUs = 1;
numCPUs = MyMin(numCPUs, (UInt32)(1 << 8));
@@ -178,8 +208,8 @@ bool CBenchmarkDialog::OnInit()
m_Dictionary.Attach(GetItem(IDC_BENCH_DICTIONARY));
cur = 0;
UInt64 ramSize = (UInt64)(sizeof(size_t)) << 29;
bool ramSize_Defined = NSystem::GetRamSize(ramSize);
ramSize = (UInt64)(sizeof(size_t)) << 29;
ramSize_Defined = NSystem::GetRamSize(ramSize);
#ifdef UNDER_CE
const UInt32 kNormalizedCeSize = (16 << 20);
@@ -208,10 +238,10 @@ bool CBenchmarkDialog::OnInit()
for (unsigned i = kMinDicLogSize; i <= 30; i++)
for (unsigned j = 0; j < 2; j++)
{
UInt32 dict = (1 << i) + (j << (i - 1));
UInt32 dict = ((UInt32)1 << i) + ((UInt32)j << (i - 1));
if (dict > kMaxDicSize)
continue;
TCHAR s[16];
TCHAR s[32];
ConvertUInt32ToString((dict >> 20), s);
lstrcat(s, kMB);
int index = (int)m_Dictionary.AddString(s);
@@ -276,15 +306,43 @@ UInt32 CBenchmarkDialog::GetNumberOfThreads()
return (UInt32)m_NumThreads.GetItemData_of_CurSel();
}
void CBenchmarkDialog::SetItemText_Number(int itemID, UInt64 val, LPCTSTR post)
{
TCHAR s[64];
ConvertUInt64ToString(val, s);
if (post)
lstrcat(s, post);
SetItemText(itemID, s);
}
static void PrintSize_MB(UString &s, UInt64 size)
{
char temp[32];
ConvertUInt64ToString((size + (1 << 20) - 1) >> 20, temp);
s += temp;
s += kMB;
}
extern bool g_LargePagesMode;
UInt32 CBenchmarkDialog::OnChangeDictionary()
{
UInt32 dict = (UInt32)m_Dictionary.GetItemData_of_CurSel();
UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dict);
memUsage = (memUsage + (1 << 20) - 1) >> 20;
TCHAR s[40];
ConvertUInt64ToString(memUsage, s);
lstrcat(s, kMB);
const UInt32 dict = (UInt32)m_Dictionary.GetItemData_of_CurSel();
const UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dict);
UString s;
PrintSize_MB(s, memUsage);
if (ramSize_Defined)
{
s += " / ";
PrintSize_MB(s, ramSize);
}
if (g_LargePagesMode)
s += " LP";
SetItemText(IDT_BENCH_MEMORY_VAL, s);
return dict;
}
@@ -311,6 +369,9 @@ static const UInt32 g_IDs[] =
IDT_BENCH_TOTAL_USAGE_VAL,
IDT_BENCH_TOTAL_RATING_VAL,
IDT_BENCH_TOTAL_RPU_VAL
// IDT_BENCH_FREQ_CUR,
// IDT_BENCH_FREQ_RES
};
void CBenchmarkDialog::OnChangeSettings()
@@ -342,7 +403,7 @@ void CBenchmarkDialog::OnStopButton()
void CBenchmarkDialog::OnHelp()
{
ShowHelpWindow(NULL, kHelpTopic);
ShowHelpWindow(kHelpTopic);
}
void CBenchmarkDialog::OnCancel()
@@ -368,18 +429,12 @@ void CBenchmarkDialog::PrintTime()
void CBenchmarkDialog::PrintRating(UInt64 rating, UINT controlID)
{
TCHAR s[40];
ConvertUInt64ToString(rating / 1000000, s);
lstrcat(s, kMIPS);
SetItemText(controlID, s);
SetItemText_Number(controlID, rating / 1000000, kMIPS);
}
void CBenchmarkDialog::PrintUsage(UInt64 usage, UINT controlID)
{
TCHAR s[40];
ConvertUInt64ToString((usage + 5000) / 10000, s);
lstrcat(s, TEXT("%"));
SetItemText(controlID, s);
SetItemText_Number(controlID, (usage + 5000) / 10000, TEXT("%"));
}
void CBenchmarkDialog::PrintResults(
@@ -391,12 +446,9 @@ void CBenchmarkDialog::PrintResults(
if (info.GlobalTime == 0)
return;
TCHAR s[40];
{
UInt64 speed = info.UnpackSize * info.NumIterations * info.GlobalFreq / info.GlobalTime;
ConvertUInt64ToString(speed / 1024, s);
lstrcat(s, kKBs);
SetItemText(speedID, s);
const UInt64 speed = info.UnpackSize * info.NumIterations * info.GlobalFreq / info.GlobalTime;
SetItemText_Number(speedID, speed >> 10, kKBs);
}
UInt64 rating;
if (decompressMode)
@@ -419,25 +471,36 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
}
if (printTime)
PrintTime();
NWindows::NSynchronization::CCriticalSectionLock lock(Sync.CS);
if (TotalMode)
{
if (Sync.TextWasChanged)
bool wasChanged = false;
{
_consoleEdit.SetText(GetSystemString(Sync.Text));
Sync.TextWasChanged = false;
NWindows::NSynchronization::CCriticalSectionLock lock(Sync.CS);
if (Sync.TextWasChanged)
{
wasChanged = true;
Bench2Text += Sync.Text;
Sync.Text.Empty();
Sync.TextWasChanged = false;
}
}
if (wasChanged)
_consoleEdit.SetText(Bench2Text);
return true;
}
TCHAR s[40];
ConvertUInt64ToString((Sync.ProcessedSize >> 20), s);
lstrcat(s, kMB);
SetItemText(IDT_BENCH_SIZE_VAL, s);
SetItemText_Number(IDT_BENCH_SIZE_VAL, (Sync.ProcessedSize >> 20), kMB);
ConvertUInt64ToString(Sync.NumPasses, s);
SetItemText(IDT_BENCH_PASSES_VAL, s);
SetItemText_Number(IDT_BENCH_PASSES_VAL, Sync.NumPasses);
/*
if (Sync.FirstPath)
SetItemText_Number(IDT_BENCH_FREQ_CUR, Sync.Freq, TEXT(" MHz"));
else
SetItemText_Number(IDT_BENCH_FREQ_RES, Sync.Freq, TEXT(" MHz"));
*/
/*
if (Sync.FreqWasChanged)
@@ -549,7 +612,7 @@ struct CThreadBenchmark
struct CBenchCallback: public IBenchCallback
{
UInt32 dictionarySize;
CProgressSyncInfo *Sync;
CBenchProgressSync *Sync;
// void AddCpuFreq(UInt64 cpuFreq);
HRESULT SetFreq(bool showFreq, UInt64 cpuFreq);
@@ -613,7 +676,8 @@ HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
struct CBenchCallback2: public IBenchPrintCallback
{
CProgressSyncInfo *Sync;
CBenchProgressSync *Sync;
bool TotalMode;
void Print(const char *s);
void NewLine();
@@ -622,9 +686,12 @@ struct CBenchCallback2: public IBenchPrintCallback
void CBenchCallback2::Print(const char *s)
{
NSynchronization::CCriticalSectionLock lock(Sync->CS);
Sync->Text += s;
Sync->TextWasChanged = true;
if (TotalMode)
{
NSynchronization::CCriticalSectionLock lock(Sync->CS);
Sync->Text += s;
Sync->TextWasChanged = true;
}
}
void CBenchCallback2::NewLine()
@@ -640,9 +707,27 @@ HRESULT CBenchCallback2::CheckBreak()
}
/*
struct CFreqCallback: public IBenchFreqCallback
{
CBenchProgressSync *Sync;
virtual void AddCpuFreq(UInt64 freq);
};
void CFreqCallback::AddCpuFreq(UInt64 freq)
{
NSynchronization::CCriticalSectionLock lock(Sync->CS);
Sync->Freq = freq;
}
*/
HRESULT CThreadBenchmark::Process()
{
CProgressSyncInfo &sync = BenchmarkDialog->Sync;
CBenchProgressSync &sync = BenchmarkDialog->Sync;
sync.WaitCreating();
try
{
@@ -665,13 +750,20 @@ HRESULT CThreadBenchmark::Process()
sync.Init();
dictionarySize = sync.DictionarySize;
numThreads = sync.NumThreads;
/*
if (sync.CompressingInfo.GlobalTime != 0)
sync.FirstPath = false;
*/
}
CBenchCallback callback;
callback.dictionarySize = dictionarySize;
callback.Sync = &sync;
CBenchCallback2 callback2;
callback2.TotalMode = BenchmarkDialog->TotalMode;
callback2.Sync = &sync;
// CFreqCallback freqCallback;
// freqCallback.Sync = &sync;
HRESULT result;
try
@@ -685,26 +777,25 @@ HRESULT CThreadBenchmark::Process()
{
{
CProperty prop;
prop.Name = L"mt";
wchar_t s[16];
ConvertUInt32ToString(numThreads, s);
prop.Value = s;
prop.Name = "mt";
prop.Value.Add_UInt32(numThreads);
props.Add(prop);
}
{
CProperty prop;
prop.Name = L'd';
wchar_t s[16];
ConvertUInt32ToString(dictionarySize, s);
prop.Name += s;
prop.Name += L'b';
prop.Name = 'd';
prop.Name.Add_UInt32(dictionarySize);
prop.Name += 'b';
props.Add(prop);
}
}
result = Bench(EXTERNAL_CODECS_LOC_VARS
BenchmarkDialog->TotalMode ? &callback2 : NULL,
BenchmarkDialog->TotalMode ? NULL : &callback,
// &freqCallback,
props, 1, false);
if (BenchmarkDialog->TotalMode)
{
sync.Stop();
@@ -725,9 +816,9 @@ HRESULT CThreadBenchmark::Process()
}
UString message;
if (result == S_FALSE)
message = L"Decoding error";
message = "Decoding error";
else if (result == CLASS_E_CLASSNOTAVAILABLE)
message = L"Can't find 7z.dll";
message = "Can't find 7z.dll";
else
message = HResultToMessage(result);
BenchmarkDialog->MessageBoxError(message);
@@ -820,7 +911,13 @@ HRESULT Benchmark(
RINOK(method.ParseMethodFromPROPVARIANT(name, propVariant));
}
// bool totalBenchMode = (method.MethodName == L"*");
if (bd.TotalMode)
{
// bd.Bench2Text.Empty();
bd.Bench2Text = "7-Zip " MY_VERSION_CPU;
bd.Bench2Text += (char)0xD;
bd.Bench2Text.Add_LF();
}
{
UInt32 dict;

View File

@@ -29,7 +29,7 @@ struct CBenchInfo2 : public CBenchInfo
}
};
class CProgressSyncInfo
class CBenchProgressSync
{
public:
bool Stopped;
@@ -51,10 +51,12 @@ public:
AString Text;
bool TextWasChanged;
// bool FirstPath;
// UInt64 Freq;
// UString Freq;
// bool FreqWasChanged;
CProgressSyncInfo()
CBenchProgressSync()
{
if (_startEvent.Create() != S_OK)
throw 3986437;
@@ -74,6 +76,8 @@ public:
NumPasses = 0;
// FirstPath = true;
// Freq = 0;
// Freq.SetFromAscii("MHz: ");
// FreqWasChanged = true;
@@ -135,6 +139,9 @@ class CBenchmarkDialog:
UInt32 _startTime;
CMyFont _font;
UInt64 ramSize;
bool ramSize_Defined;
bool OnSize(WPARAM /* wParam */, int xSize, int ySize);
bool OnTimer(WPARAM timerID, LPARAM callback);
virtual bool OnInit();
@@ -156,11 +163,16 @@ class CBenchmarkDialog:
UInt32 GetNumberOfThreads();
UInt32 OnChangeDictionary();
void OnChangeSettings();
void SetItemText_Number(int itemID, UInt64 val, LPCTSTR post = NULL);
public:
CProgressSyncInfo Sync;
CBenchProgressSync Sync;
bool TotalMode;
CObjectVector<CProperty> Props;
CSysString Bench2Text;
CBenchmarkDialog(): _timer(0), TotalMode(false) {}
INT_PTR Create(HWND wndParent = 0)
{

View File

@@ -16,7 +16,7 @@
#define gSpace 24
#define g0xs 90
#define g1xs 44
#define g1xs 48
#define g1x (m + g0xs)
#define gc2x (g1x + g1xs + m)
#define gc2xs 80
@@ -27,12 +27,15 @@
#define sSpeed 60
#define sUsage 60
#define sRpu 60
#define sFreq 34
#define xRating (xs - m - m - sRating)
#define xRpu (xRating - sRpu)
#define xUsage (xRpu - sUsage)
#define xSpeed (xUsage - sSpeed)
#define xFreq (xUsage - sFreq)
#define sLabel (xUsage - g4x)
#define sTotalRating (sUsage + sRpu + sRating + m + m)
#define xTotalRating (xs - m - sTotalRating)
@@ -51,6 +54,8 @@
#define GROUP_Y2_SIZE 32
#endif
#define g7xs bx1 - m - g0xs - g1xs - m
IDD_BENCH DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
CAPTION "Benchmark"
MY_FONT
@@ -64,12 +69,12 @@ BEGIN
LTEXT "&Dictionary size:", IDT_BENCH_DICTIONARY, m, m + 1, g0xs, 8
COMBOBOX IDC_BENCH_DICTIONARY, g1x, m, g1xs, 140, MY_COMBO
LTEXT "Memory usage:", IDT_BENCH_MEMORY, gc2x, m + 1, gc2xs, 8
LTEXT "", IDT_BENCH_MEMORY_VAL, gc2x + gc2xs, m + 1, 40, 8
LTEXT "Memory usage:", IDT_BENCH_MEMORY, gc2x, m - 2, g7xs, 8
LTEXT "", IDT_BENCH_MEMORY_VAL, gc2x, m + 8, g7xs, 8
LTEXT "&Number of CPU threads:", IDT_BENCH_NUM_THREADS, m, 28, g0xs, 8
COMBOBOX IDC_BENCH_NUM_THREADS, g1x, 27, g1xs, 140, MY_COMBO
LTEXT "", IDT_BENCH_HARDWARE_THREADS, gc2x, 28, 40, 8
LTEXT "&Number of CPU threads:", IDT_BENCH_NUM_THREADS, m, 30, g0xs, 8
COMBOBOX IDC_BENCH_NUM_THREADS, g1x, 29, g1xs, 140, MY_COMBO
LTEXT "", IDT_BENCH_HARDWARE_THREADS, gc2x, 32, g7xs, 8
RTEXT "CPU Usage", IDT_BENCH_USAGE_LABEL, xUsage, 54, sUsage, 8
RTEXT "Speed", IDT_BENCH_SPEED, xSpeed, 54, sSpeed, 8
@@ -111,7 +116,17 @@ BEGIN
RTEXT "", IDT_BENCH_TOTAL_RATING_VAL, xRating, 176, sRating, 8
RTEXT "", IDT_BENCH_CPU, m, 202, xc, 8
RTEXT "", IDT_BENCH_VER, m, 216, xc, 8
RTEXT "", IDT_BENCH_VER, m + xc - 80, 216, 80, 8
LTEXT "", IDT_BENCH_CPU_FEATURE, m, 212, xc - 80, 26
LTEXT "", IDT_BENCH_SYS1, m, 238, xc - 140, 8
LTEXT "", IDT_BENCH_SYS2, m, 248, xc - 140, 8
// LTEXT "", IDT_BENCH_SYSTEM, m, 232, xc - 80, 8
// LTEXT "", IDT_BENCH_FREQ_RES, m, 242, 80, 8
LTEXT "Elapsed time:", IDT_BENCH_ELAPSED, m, 163, g2xs, 8
LTEXT "Size:", IDT_BENCH_SIZE, m, 176, g2xs, 8

View File

@@ -11,6 +11,9 @@
#define IDT_BENCH_VER 105
#define IDT_BENCH_CPU 106
#define IDT_BENCH_SYS1 107
#define IDT_BENCH_SYS2 108
#define IDT_BENCH_CPU_FEATURE 109
#define IDT_BENCH_COMPRESS_SPEED1 110
#define IDT_BENCH_COMPRESS_SPEED2 111
@@ -39,6 +42,9 @@
#define IDT_BENCH_PASSES_VAL 142
// #define IDT_BENCH_FREQ_CUR 150
// #define IDT_BENCH_FREQ_RES 151
#define IDB_STOP 442
#define IDB_RESTART 443

View File

@@ -80,8 +80,9 @@ using namespace NDir;
static const unsigned kHistorySize = 20;
static LPCWSTR kExeExt = L".exe";
static LPCWSTR k7zFormat = L"7z";
static LPCSTR const kExeExt = ".exe";
#define k7zFormat "7z"
static const UInt32 g_Levels[] =
{
@@ -108,21 +109,35 @@ enum EMethodID
kPPMdZip
};
static const LPCWSTR kMethodsNames[] =
static LPCSTR const kMethodsNames[] =
{
L"Copy",
L"ZSTD",
L"LZ4",
L"LZ5",
L"LZMA",
L"LZMA2",
L"PPMd",
L"BZip2",
L"Deflate",
L"Deflate64",
L"PPMd"
"Copy"
, "ZSTD"
, "LZ4"
, "LZ5"
, "LZMA"
, "LZMA2"
, "PPMd"
, "BZip2"
, "Deflate"
, "Deflate64"
, "PPMd"
};
static const EMethodID g_ZstdMethods[] =
{
kZSTD
};
static const EMethodID g_Lz4Methods[] =
{
kLZ4
};
static const EMethodID g_Lz5Methods[] =
{
kLZ5
};
static const EMethodID g_7zMethods[] =
{
kZSTD,
@@ -169,47 +184,33 @@ static const EMethodID g_XzMethods[] =
kLZMA2
};
static const EMethodID g_ZstdMethods[] =
{
kZSTD
};
static const EMethodID g_Lz4Methods[] =
{
kLZ4
};
static const EMethodID g_Lz5Methods[] =
{
kLZ5
};
static const EMethodID g_SwfcMethods[] =
{
kDeflate
// kLZMA
};
struct CFormatInfo
{
LPCWSTR Name;
LPCSTR Name;
UInt32 LevelsMask;
const EMethodID *MethodIDs;
unsigned NumMethods;
const EMethodID *MathodIDs;
bool Filter;
bool Solid;
bool MultiThread;
bool SFX;
bool Encrypt;
bool EncryptFileNames;
};
#define METHODS_PAIR(x) x, ARRAY_SIZE(x)
#define METHODS_PAIR(x) ARRAY_SIZE(x), x
static const CFormatInfo g_Formats[] =
{
{
L"",
"",
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
0, 0,
false, false, false, false, false, false
@@ -221,61 +222,61 @@ static const CFormatInfo g_Formats[] =
true, true, true, true, true, true
},
{
L"Zip",
"Zip",
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_ZipMethods),
false, false, true, false, true, false
},
{
L"GZip",
"GZip",
(1 << 1) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_GZipMethods),
false, false, false, false, false, false
},
{
L"BZip2",
"BZip2",
(1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_BZip2Methods),
false, false, true, false, false, false
},
{
L"xz",
"xz",
(1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_XzMethods),
false, false, true, false, false, false
},
{
L"zstd",
"zstd",
(1 << 0) | (1 << 1) | (1 << 5) | (1 << 11) | (1 << 17) | (1 << 22),
METHODS_PAIR(g_ZstdMethods),
false, false, true, false, false, false
},
{
L"lz4",
"lz4",
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 7) | (1 << 11) | (1 << 16),
METHODS_PAIR(g_Lz4Methods),
false, false, true, false, false, false
},
},
{
L"lz5",
"lz5",
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 7) | (1 << 11) | (1 << 16),
METHODS_PAIR(g_Lz5Methods),
false, false, true, false, false, false
},
{
L"Swfc",
"Swfc",
(1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_SwfcMethods),
false, false, true, false, false, false
},
{
L"Tar",
"Tar",
(1 << 0),
0, 0,
false, false, false, false, false, false
},
{
L"wim",
"wim",
(1 << 0),
0, 0,
false, false, false, false, false, false
@@ -423,6 +424,8 @@ bool CCompressDialog::OnInit()
}
}
CheckButton(IDX_COMPRESS_SFX, Info.SFXMode);
{
UString fileName;
SetArcPathFields(Info.ArcPath, fileName, true);
@@ -448,7 +451,6 @@ bool CCompressDialog::OnInit()
ConvertUInt32ToString(NSystem::GetNumberOfProcessors(), s + 2);
SetItemText(IDT_COMPRESS_HARDWARE_THREADS, s);
CheckButton(IDX_COMPRESS_SFX, Info.SFXMode);
CheckButton(IDX_COMPRESS_SHARED, Info.OpenShareForWrite);
CheckButton(IDX_COMPRESS_DEL, Info.DeleteAfterCompressing);
@@ -620,7 +622,7 @@ void CCompressDialog::OnButtonSFX()
if (dotPos >= 0)
{
UString ext = fileName.Ptr(dotPos);
if (ext.IsEqualTo_NoCase(kExeExt))
if (ext.IsEqualTo_Ascii_NoCase(kExeExt))
{
fileName.DeleteFrom(dotPos);
m_ArchivePath.SetText(fileName);
@@ -679,7 +681,7 @@ bool CCompressDialog::SetArcPathFields(const UString &path, UString &name, bool
return res;
}
static const wchar_t *k_IncorrectPathMessage = L"Incorrect archive path";
static const wchar_t * const k_IncorrectPathMessage = L"Incorrect archive path";
void CCompressDialog::OnButtonSetArchive()
{
@@ -692,7 +694,7 @@ void CCompressDialog::OnButtonSetArchive()
UString title = LangString(IDS_COMPRESS_SET_ARCHIVE_BROWSE);
UString filterDescription = LangString(IDS_OPEN_TYPE_ALL_FILES);
filterDescription += L" (*.*)";
filterDescription += " (*.*)";
UString resPath;
CurrentDirWasChanged = true;
if (!MyBrowseForFile(*this, title,
@@ -852,11 +854,11 @@ void CCompressDialog::OnOK()
CModalDialog::OnOK();
}
static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/add.htm";
#define kHelpTopic "fm/plugins/7-zip/add.htm"
void CCompressDialog::OnHelp()
{
ShowHelpWindow(NULL, kHelpTopic);
ShowHelpWindow(kHelpTopic);
}
bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
@@ -956,7 +958,10 @@ void CCompressDialog::SetArchiveName2(bool prevWasSFX)
if (prevWasSFX)
prevExtension = kExeExt;
else
prevExtension = UString(L'.') + prevArchiverInfo.GetMainExt();
{
prevExtension += '.';
prevExtension += prevArchiverInfo.GetMainExt();
}
const unsigned prevExtensionLen = prevExtension.Len();
if (fileName.Len() >= prevExtensionLen)
if (StringsAreEqualNoCase(fileName.RightPtr(prevExtensionLen), prevExtension))
@@ -993,7 +998,7 @@ void CCompressDialog::SetArchiveName(const UString &name)
fileName += kExeExt;
else
{
fileName += L'.';
fileName += '.';
fileName += ai.GetMainExt();
}
m_ArchivePath.SetText(fileName);
@@ -1026,7 +1031,7 @@ int CCompressDialog::GetStaticFormatIndex()
{
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
for (unsigned i = 0; i < ARRAY_SIZE(g_Formats); i++)
if (ai.Name.IsEqualTo_NoCase(g_Formats[i].Name))
if (ai.Name.IsEqualTo_Ascii_NoCase(g_Formats[i].Name))
return i;
return 0; // -1;
}
@@ -1062,7 +1067,7 @@ void CCompressDialog::SetLevel()
level = 5;
}
}
m_Level.ResetContent();
if (GetMethodID() == kZSTD)
LevelsMask = g_Formats[6].LevelsMask;
@@ -1099,11 +1104,17 @@ void CCompressDialog::SetLevel()
m_Level.SetItemData(index, i);
}
}
SetNearestSelectComboBox(m_Level, level);
return;
}
static LRESULT ComboBox_AddStringAscii(NControl::CComboBox &cb, const char *s)
{
return cb.AddString((CSysString)s);
}
void CCompressDialog::SetMethod(int keepMethodId)
{
m_Method.ResetContent();
@@ -1125,29 +1136,26 @@ void CCompressDialog::SetMethod(int keepMethodId)
}
bool isSfx = IsSFX();
bool weUseSameMethod = false;
for (unsigned m = 0; m < fi.NumMethods; m++)
{
EMethodID methodID = fi.MethodIDs[m];
EMethodID methodID = fi.MathodIDs[m];
if (isSfx)
if (!IsMethodSupportedBySfx(methodID))
continue;
const LPCWSTR method = kMethodsNames[methodID];
int itemIndex = (int)m_Method.AddString(GetSystemString(method));
const char *method = kMethodsNames[methodID];
int itemIndex = (int)ComboBox_AddStringAscii(m_Method, method);
m_Method.SetItemData(itemIndex, methodID);
if (keepMethodId == methodID)
{
m_Method.SetCurSel(itemIndex);
weUseSameMethod = true;
continue;
}
if ((defaultMethod.IsEqualTo_NoCase(method) || m == 0) && !weUseSameMethod)
if ((defaultMethod.IsEqualTo_Ascii_NoCase(method) || m == 0) && !weUseSameMethod)
m_Method.SetCurSel(itemIndex);
}
if (!weUseSameMethod)
{
SetDictionary();
@@ -1167,7 +1175,7 @@ void CCompressDialog::SetEncryptionMethod()
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
if (ai.Name.IsEqualTo_Ascii_NoCase("7z"))
{
_encryptionMethod.AddString(TEXT("AES-256"));
ComboBox_AddStringAscii(_encryptionMethod, "AES-256");
_encryptionMethod.SetCurSel(0);
}
else if (ai.Name.IsEqualTo_Ascii_NoCase("zip"))
@@ -1179,8 +1187,8 @@ void CCompressDialog::SetEncryptionMethod()
const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
encryptionMethod = fo.EncryptionMethod;
}
_encryptionMethod.AddString(TEXT("ZipCrypto"));
_encryptionMethod.AddString(TEXT("AES-256"));
ComboBox_AddStringAscii(_encryptionMethod, "ZipCrypto");
ComboBox_AddStringAscii(_encryptionMethod, "AES-256");
_encryptionMethod.SetCurSel(encryptionMethod.IsPrefixedBy_Ascii_NoCase("aes") ? 1 : 0);
}
}
@@ -1194,21 +1202,22 @@ int CCompressDialog::GetMethodID()
UString CCompressDialog::GetMethodSpec()
{
if (m_Method.GetCount() <= 1)
return UString();
return kMethodsNames[GetMethodID()];
UString s;
if (m_Method.GetCount() > 1)
s = kMethodsNames[GetMethodID()];
return s;
}
UString CCompressDialog::GetEncryptionMethodSpec()
{
if (_encryptionMethod.GetCount() <= 1)
return UString();
if (_encryptionMethod.GetCurSel() <= 0)
return UString();
UString result;
_encryptionMethod.GetText(result);
result.RemoveChar(L'-');
return result;
UString s;
if (_encryptionMethod.GetCount() > 1
&& _encryptionMethod.GetCurSel() > 0)
{
_encryptionMethod.GetText(s);
s.RemoveChar(L'-');
}
return s;
}
void CCompressDialog::AddDictionarySize(UInt32 size)

View File

@@ -143,7 +143,7 @@ bool CExtractDialog::OnInit()
GetText(s);
if (!ArcPath.IsEmpty())
{
s.AddAscii(" : ");
s += " : ";
s += ArcPath;
}
SetText(s);
@@ -409,10 +409,10 @@ void CExtractDialog::OnOK()
}
#ifndef NO_REGISTRY
static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/extract.htm";
#define kHelpTopic "fm/plugins/7-zip/extract.htm"
void CExtractDialog::OnHelp()
{
ShowHelpWindow(NULL, kHelpTopic);
ShowHelpWindow(kHelpTopic);
CModalDialog::OnHelp();
}
#endif

View File

@@ -34,7 +34,7 @@ using namespace NWindows;
using namespace NFile;
using namespace NDir;
static const wchar_t *kIncorrectOutDir = L"Incorrect output directory path";
static const wchar_t * const kIncorrectOutDir = L"Incorrect output directory path";
#ifndef _SFX
@@ -42,28 +42,31 @@ static void AddValuePair(UString &s, UINT resourceID, UInt64 value, bool addColo
{
AddLangString(s, resourceID);
if (addColon)
s += L':';
s += ':';
s.Add_Space();
char sz[32];
ConvertUInt64ToString(value, sz);
s.AddAscii(sz);
s += sz;
s.Add_LF();
}
static void AddSizePair(UString &s, UINT resourceID, UInt64 value)
{
wchar_t sz[32];
AddLangString(s, resourceID);
s += L": ";
ConvertUInt64ToString(value, sz);
s += MyFormatNew(IDS_FILE_SIZE, sz);
{
wchar_t sz[32];
AddLangString(s, resourceID);
s += ": ";
ConvertUInt64ToString(value, sz);
s += MyFormatNew(IDS_FILE_SIZE, sz);
}
// s += sz;
if (value >= (1 << 20))
{
char sz[32];
ConvertUInt64ToString(value >> 20, sz);
s += L" (";
s += " (";
s += sz;
s += L" MB)";
s += " MB)";
}
s.Add_LF();
}

View File

@@ -11,7 +11,6 @@
#include "../../../Common/MyInitGuid.h"
#include "../../../Common/CommandLineParser.h"
#include "../../../Common/IntToString.h"
#include "../../../Common/MyException.h"
#include "../../../Common/StringConvert.h"
@@ -37,8 +36,8 @@
using namespace NWindows;
HINSTANCE g_hInstance;
#ifndef _UNICODE
#endif
bool g_LargePagesMode = false;
#ifndef UNDER_CE
@@ -74,12 +73,17 @@ static void ErrorMessage(LPCWSTR message)
MessageBoxW(NULL, message, L"7-Zip", MB_ICONERROR | MB_OK);
}
static void ErrorMessage(const char *s)
{
ErrorMessage(GetUnicodeString(s));
}
static void ErrorLangMessage(UINT resourceID)
{
ErrorMessage(LangString(resourceID));
}
static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
static const char * const kNoFormats = "7-Zip cannot find the code that works with archives.";
static int ShowMemErrorMessage()
{
@@ -126,7 +130,10 @@ static int Main2()
NSecurity::EnablePrivilege_SymLink();
#ifdef _7ZIP_LARGE_PAGES
if (options.LargePages)
NSecurity::EnablePrivilege_LockMemory();
{
SetLargePageSize();
g_LargePagesMode = NSecurity::EnablePrivilege_LockMemory();
}
#endif
#endif
@@ -146,7 +153,7 @@ static int Main2()
#ifdef EXTERNAL_CODECS
if (!codecs->MainDll_ErrorPath.IsEmpty())
{
UString s = L"7-Zip cannot load module ";
UString s ("7-Zip cannot load module: ");
s += fs2us(codecs->MainDll_ErrorPath);
throw s;
}
@@ -350,7 +357,7 @@ static int Main2()
return 0;
}
#define NT_CHECK_FAIL_ACTION ErrorMessage(L"Unsupported Windows version"); return NExitCode::kFatalError;
#define NT_CHECK_FAIL_ACTION ErrorMessage("Unsupported Windows version"); return NExitCode::kFatalError;
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
#ifdef UNDER_CE
@@ -361,9 +368,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
/* lpCmdLine */, int /* nCmdShow */)
{
g_hInstance = hInstance;
#ifdef _WIN32
NT_CHECK
SetLargePageSize();
#endif
InitCommonControls();
@@ -407,7 +414,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
}
catch(const AString &s)
{
ErrorMessage(GetUnicodeString(s));
ErrorMessage(s);
return NExitCode::kFatalError;
}
catch(const wchar_t *s)
@@ -417,19 +424,19 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
}
catch(const char *s)
{
ErrorMessage(GetUnicodeString(s));
ErrorMessage(s);
return NExitCode::kFatalError;
}
catch(int v)
{
wchar_t s[32];
ConvertUInt32ToString(v, s);
ErrorMessage(UString(L"Error: ") + s);
AString e ("Error: ");
e.Add_UInt32(v);
ErrorMessage(e);
return NExitCode::kFatalError;
}
catch(...)
{
ErrorMessage(L"Unknown error");
ErrorMessage("Unknown error");
return NExitCode::kFatalError;
}
}

View File

@@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /FAcs /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -835,10 +835,6 @@ SOURCE=..\..\..\..\C\Threads.h
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Common\Buffer.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\CommandLineParser.cpp
# End Source File
# Begin Source File
@@ -875,6 +871,10 @@ SOURCE=..\..\..\Common\ListFileUtils.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyBuffer.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyString.cpp
# End Source File
# Begin Source File

View File

@@ -47,25 +47,30 @@ public:
static void AddValuePair(UString &s, UINT resourceID, UInt64 value)
{
AddLangString(s, resourceID);
s.AddAscii(": ");
s += ": ";
char sz[32];
ConvertUInt64ToString(value, sz);
s.AddAscii(sz);
s += sz;
s.Add_LF();
}
static void AddSizeValuePair(UString &s, UINT resourceID, UInt64 value)
{
AddLangString(s, resourceID);
s.AddAscii(": ");
wchar_t sz[32];
ConvertUInt64ToString(value, sz);
s += MyFormatNew(IDS_FILE_SIZE, sz);
ConvertUInt64ToString(value >> 20, sz);
s.AddAscii(" (");
s += sz;
s.AddAscii(" MB)");
s.Add_LF();
s += ": ";
{
wchar_t sz[32];
ConvertUInt64ToString(value, sz);
s += MyFormatNew(IDS_FILE_SIZE, sz);
}
{
char sz[32];
ConvertUInt64ToString(value >> 20, sz);
s += " (";
s += sz;
s += " MB)";
s.Add_LF();
}
}
HRESULT CHashCallbackGUI::StartScanning()
@@ -155,15 +160,14 @@ static void AddHashString(UString &s, const CHasherState &h, unsigned digestInde
s.Add_Space();
char temp[k_HashCalc_DigestSize_Max * 2 + 4];
AddHashHexToString(temp, h.Digests[digestIndex], h.DigestSize);
s.AddAscii(temp);
s += temp;
s.Add_LF();
}
static void AddHashResString(UString &s, const CHasherState &h, unsigned digestIndex, UInt32 resID)
{
UString s2 = LangString(resID);
UString name;
name.SetFromAscii(h.Name);
UString name (h.Name);
s2.Replace(L"CRC", name);
AddHashString(s, h, digestIndex, s2);
}
@@ -179,7 +183,7 @@ void AddHashBundleRes(UString &s, const CHashBundle &hb, const UString &firstFil
if (hb.NumFiles == 1 && hb.NumDirs == 0 && !firstFileName.IsEmpty())
{
AddLangString(s, IDS_PROP_NAME);
s.AddAscii(": ");
s += ": ";
s += firstFileName;
s.Add_LF();
}
@@ -210,7 +214,7 @@ void AddHashBundleRes(UString &s, const CHashBundle &hb, const UString &firstFil
const CHasherState &h = hb.Hashers[i];
if (hb.NumFiles == 1 && hb.NumDirs == 0)
{
s.AddAscii(h.Name);
s += h.Name;
AddHashString(s, h, k_HashCalc_Index_DataSum, L":");
}
else
@@ -268,7 +272,7 @@ HRESULT HashCalcGUI(
const UString title = LangString(IDS_CHECKSUM_CALCULATING);
t.ProgressDialog.MainTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
t.ProgressDialog.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
t.ProgressDialog.MainAddTitle = title;
t.ProgressDialog.MainAddTitle.Add_Space();

View File

@@ -97,9 +97,9 @@ HRESULT CUpdateCallbackGUI::Finalize()
}
*/
HRESULT CUpdateCallbackGUI::SetNumItems(UInt64 numItems)
HRESULT CUpdateCallbackGUI::SetNumItems(const CArcToDoStat &stat)
{
ProgressDialog->Sync.Set_NumFilesTotal(numItems);
ProgressDialog->Sync.Set_NumFilesTotal(stat.Get_NumDataItems_Total());
return S_OK;
}

View File

@@ -28,8 +28,8 @@ using namespace NWindows;
using namespace NFile;
using namespace NDir;
static CFSTR kDefaultSfxModule = FTEXT("7z.sfx");
static const wchar_t *kSFXExtension = L"exe";
static const char * const kDefaultSfxModule = "7z.sfx";
static const char * const kSFXExtension = "exe";
extern void AddMessageToString(UString &dest, const UString &src);
@@ -54,14 +54,14 @@ HRESULT CThreadUpdating::ProcessVirt()
HRESULT res = UpdateArchive(codecs, *formatIndices, *cmdArcPath,
*WildcardCensor, *Options,
ei, UpdateCallbackGUI, UpdateCallbackGUI, needSetPath);
FinalMessage.ErrorMessage.Message.SetFromAscii(ei.Message);
FinalMessage.ErrorMessage.Message = ei.Message.Ptr();
ErrorPaths = ei.FileNames;
if (ei.SystemError != S_OK && ei.SystemError != E_FAIL && ei.SystemError != E_ABORT)
return ei.SystemError;
return res;
}
static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value)
static void AddProp(CObjectVector<CProperty> &properties, const char *name, const UString &value)
{
CProperty prop;
prop.Name = name;
@@ -69,16 +69,16 @@ static void AddProp(CObjectVector<CProperty> &properties, const UString &name, c
properties.Add(prop);
}
static void AddProp(CObjectVector<CProperty> &properties, const UString &name, UInt32 value)
static void AddProp(CObjectVector<CProperty> &properties, const char *name, UInt32 value)
{
wchar_t tmp[32];
char tmp[32];
ConvertUInt64ToString(value, tmp);
AddProp(properties, name, tmp);
AddProp(properties, name, UString(tmp));
}
static void AddProp(CObjectVector<CProperty> &properties, const UString &name, bool value)
static void AddProp(CObjectVector<CProperty> &properties, const char *name, bool value)
{
AddProp(properties, name, value ? UString(L"on"): UString(L"off"));
AddProp(properties, name, UString(value ? "on": "off"));
}
static bool IsThereMethodOverride(bool is7z, const UString &propertiesString)
@@ -128,12 +128,12 @@ static void ParseAndAddPropertires(CObjectVector<CProperty> &properties,
static UString GetNumInBytesString(UInt64 v)
{
wchar_t s[32];
char s[32];
ConvertUInt64ToString(v, s);
size_t len = wcslen(s);
s[len++] = L'B';
s[len] = L'\0';
return s;
size_t len = MyStringLen(s);
s[len++] = 'B';
s[len] = '\0';
return UString(s);
}
static void SetOutProperties(
@@ -152,44 +152,38 @@ static void SetOutProperties(
bool /* sfxMode */)
{
if (level != (UInt32)(Int32)-1)
AddProp(properties, L"x", (UInt32)level);
AddProp(properties, "x", (UInt32)level);
if (setMethod)
{
if (!method.IsEmpty())
AddProp(properties, is7z ? L"0": L"m", method);
AddProp(properties, is7z ? "0": "m", method);
if (dictionary != (UInt32)(Int32)-1)
{
UString name;
AString name;
if (is7z)
name = L"0";
if (orderMode)
name += L"mem";
else
name += L"d";
name = "0";
name += (orderMode ? "mem" : "d");
AddProp(properties, name, GetNumInBytesString(dictionary));
}
if (order != (UInt32)(Int32)-1)
{
UString name;
AString name;
if (is7z)
name = L"0";
if (orderMode)
name += L"o";
else
name += L"fb";
name = "0";
name += (orderMode ? "o" : "fb");
AddProp(properties, name, (UInt32)order);
}
}
if (!encryptionMethod.IsEmpty())
AddProp(properties, L"em", encryptionMethod);
AddProp(properties, "em", encryptionMethod);
if (encryptHeadersIsAllowed)
AddProp(properties, L"he", encryptHeaders);
AddProp(properties, "he", encryptHeaders);
if (solidIsSpecified)
AddProp(properties, L"s", GetNumInBytesString(solidBlockSize));
AddProp(properties, "s", GetNumInBytesString(solidBlockSize));
if (multiThreadIsAllowed)
AddProp(properties, L"mt", numThreads);
AddProp(properties, "mt", numThreads);
}
struct C_UpdateMode_ToAction_Pair
@@ -453,8 +447,8 @@ HRESULT UpdateGUI(
}
if (options.SfxMode && options.SfxModule.IsEmpty())
{
FString folder = NWindows::NDLL::GetModuleDirPrefix();
options.SfxModule = folder + kDefaultSfxModule;
options.SfxModule = NWindows::NDLL::GetModuleDirPrefix();
options.SfxModule += kDefaultSfxModule;
}
CThreadUpdating tu;