mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-09 02:07:06 -06:00
4.20
This commit is contained in:
committed by
Kornel Lesiński
parent
8c1b5c7b7e
commit
3c510ba80b
@@ -5,13 +5,14 @@
|
||||
#include "resource.h"
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/StringToInt.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#include "../../FileManager/HelpUtils.h"
|
||||
#include "../../FileManager/SplitUtils.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "CompressDialog.h"
|
||||
@@ -63,8 +64,8 @@ static LPCWSTR k7zFormat = L"7z";
|
||||
|
||||
struct CLevelInfo
|
||||
{
|
||||
UINT32 ResourceID;
|
||||
UINT32 LangID;
|
||||
UInt32 ResourceID;
|
||||
UInt32 LangID;
|
||||
};
|
||||
|
||||
enum ELevel
|
||||
@@ -115,8 +116,14 @@ static const EMethodID g_7zMethods[] =
|
||||
{
|
||||
kLZMA,
|
||||
kPPMd,
|
||||
kBZip2,
|
||||
kDeflate
|
||||
kBZip2
|
||||
};
|
||||
|
||||
static const EMethodID g_7zSfxMethods[] =
|
||||
{
|
||||
kCopy,
|
||||
kLZMA,
|
||||
kPPMd
|
||||
};
|
||||
|
||||
static EMethodID g_ZipMethods[] =
|
||||
@@ -139,7 +146,7 @@ static EMethodID g_BZip2Methods[] =
|
||||
struct CFormatInfo
|
||||
{
|
||||
LPCWSTR Name;
|
||||
UINT32 LevelsMask;
|
||||
UInt32 LevelsMask;
|
||||
const EMethodID *MathodIDs;
|
||||
int NumMethods;
|
||||
bool Solid;
|
||||
@@ -177,7 +184,7 @@ static const CFormatInfo g_Formats[] =
|
||||
},
|
||||
{
|
||||
L"BZip2",
|
||||
(1 << 5),
|
||||
(1 << 5) | (1 << 7) | (1 << 9),
|
||||
g_BZip2Methods,
|
||||
MY_SIZE_OF_ARRAY(g_BZip2Methods),
|
||||
false, false, false, false, false
|
||||
@@ -190,6 +197,14 @@ static const CFormatInfo g_Formats[] =
|
||||
}
|
||||
};
|
||||
|
||||
static bool IsMethodSupportedBySfx(int methodID)
|
||||
{
|
||||
for (int i = 0; i < MY_SIZE_OF_ARRAY(g_7zSfxMethods); i++)
|
||||
if (methodID == g_7zSfxMethods[i])
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
class CDoubleZeroStringList
|
||||
{
|
||||
CRecordVector<int> m_Indexes;
|
||||
@@ -222,7 +237,7 @@ bool CCompressDialog::OnInit()
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, MY_SIZE_OF_ARRAY(kIDLangPairs) );
|
||||
#endif
|
||||
_passwordControl.Attach(GetItem(IDC_COMPRESS_EDIT_PASSWORD));
|
||||
_passwordControl.SetText(TEXT(""));
|
||||
_passwordControl.SetText(Info.Password);
|
||||
|
||||
m_ArchivePath.Attach(GetItem(IDC_COMPRESS_COMBO_ARCHIVE));
|
||||
m_Format.Attach(GetItem(IDC_COMPRESS_COMBO_FORMAT));
|
||||
@@ -235,9 +250,7 @@ bool CCompressDialog::OnInit()
|
||||
m_Volume.Attach(GetItem(IDC_COMPRESS_COMBO_VOLUME));
|
||||
m_Params.Attach(GetItem(IDC_COMPRESS_EDIT_PARAMETERS));
|
||||
|
||||
m_Volume.AddString(TEXT("1457664 - 3.5 Floppy"));
|
||||
m_Volume.AddString(TEXT("650M - CD-650MB"));
|
||||
m_Volume.AddString(TEXT("700M - CD-700MB"));
|
||||
AddVolumeItems(m_Volume);
|
||||
|
||||
ReadCompressionInfo(m_RegistryInfo);
|
||||
CheckButton(IDC_COMPRESS_CHECK_SHOW_PASSWORD, m_RegistryInfo.ShowPassword);
|
||||
@@ -245,7 +258,7 @@ bool CCompressDialog::OnInit()
|
||||
|
||||
UpdatePasswordControl();
|
||||
|
||||
m_Info.ArchiverInfoIndex = 0;
|
||||
Info.ArchiverInfoIndex = 0;
|
||||
int i;
|
||||
for(i = 0; i < m_ArchiverInfoList.Size(); i++)
|
||||
{
|
||||
@@ -253,11 +266,11 @@ bool CCompressDialog::OnInit()
|
||||
m_Format.AddString(GetSystemString(ai.Name));
|
||||
if (ai.Name.CollateNoCase(
|
||||
m_RegistryInfo.ArchiveType) == 0)
|
||||
m_Info.ArchiverInfoIndex = i;
|
||||
Info.ArchiverInfoIndex = i;
|
||||
}
|
||||
m_Format.SetCurSel(m_Info.ArchiverInfoIndex);
|
||||
m_Format.SetCurSel(Info.ArchiverInfoIndex);
|
||||
|
||||
SetArchiveName(m_Info.ArchiveName);
|
||||
SetArchiveName(Info.ArchiveName);
|
||||
SetLevel();
|
||||
SetParams();
|
||||
|
||||
@@ -271,12 +284,12 @@ bool CCompressDialog::OnInit()
|
||||
|
||||
m_UpdateMode.SetCurSel(0);
|
||||
|
||||
m_Info.Solid = m_RegistryInfo.Solid;
|
||||
m_Info.MultiThread = m_RegistryInfo.MultiThread;
|
||||
Info.Solid = m_RegistryInfo.Solid;
|
||||
Info.MultiThread = m_RegistryInfo.MultiThread;
|
||||
|
||||
CheckButton(IDC_COMPRESS_SOLID, m_Info.Solid);
|
||||
CheckButton(IDC_COMPRESS_MULTI_THREAD, m_Info.MultiThread);
|
||||
CheckButton(IDC_COMPRESS_SFX, m_Info.SFXMode);
|
||||
CheckButton(IDC_COMPRESS_SOLID, Info.Solid);
|
||||
CheckButton(IDC_COMPRESS_MULTI_THREAD, Info.MultiThread);
|
||||
CheckButton(IDC_COMPRESS_SFX, Info.SFXMode);
|
||||
|
||||
CheckControlsEnable();
|
||||
|
||||
@@ -339,16 +352,8 @@ void CCompressDialog::CheckSFXControlsEnable()
|
||||
bool enable = fi.SFX;
|
||||
if (enable)
|
||||
{
|
||||
switch(GetMethodID())
|
||||
{
|
||||
case -1:
|
||||
case kLZMA:
|
||||
case kPPMd:
|
||||
case kCopy:
|
||||
break;
|
||||
default:
|
||||
enable = false;
|
||||
}
|
||||
int methodID = GetMethodID();
|
||||
enable = (methodID == -1 || IsMethodSupportedBySfx(methodID));
|
||||
}
|
||||
if (!enable)
|
||||
CheckButton(IDC_COMPRESS_SFX, false);
|
||||
@@ -358,10 +363,10 @@ void CCompressDialog::CheckSFXControlsEnable()
|
||||
void CCompressDialog::CheckControlsEnable()
|
||||
{
|
||||
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
|
||||
m_Info.SolidIsAllowed = fi.Solid;
|
||||
Info.SolidIsAllowed = fi.Solid;
|
||||
bool multiThreadEnable = fi.MultiThread & IsMultiProcessor();
|
||||
m_Info.MultiThreadIsAllowed = multiThreadEnable;
|
||||
EncryptHeadersIsAllowed = fi.EncryptFileNames;
|
||||
Info.MultiThreadIsAllowed = multiThreadEnable;
|
||||
Info.EncryptHeadersIsAllowed = fi.EncryptFileNames;
|
||||
|
||||
EnableItem(IDC_COMPRESS_SOLID, fi.Solid);
|
||||
EnableItem(IDC_COMPRESS_MULTI_THREAD, multiThreadEnable);
|
||||
@@ -384,13 +389,16 @@ bool CCompressDialog::IsSFX()
|
||||
|
||||
void CCompressDialog::OnButtonSFX()
|
||||
{
|
||||
SetMethod();
|
||||
|
||||
UString fileName;
|
||||
m_ArchivePath.GetText(fileName);
|
||||
int dotPos = fileName.ReverseFind(L'.');
|
||||
int slashPos = fileName.ReverseFind(L'\\');
|
||||
if (dotPos < 0 || dotPos <= slashPos)
|
||||
dotPos = -1;
|
||||
if (IsSFX())
|
||||
bool isSFX = IsSFX();
|
||||
if (isSFX)
|
||||
{
|
||||
if (dotPos >= 0)
|
||||
fileName = fileName.Left(dotPos);
|
||||
@@ -410,6 +418,10 @@ void CCompressDialog::OnButtonSFX()
|
||||
}
|
||||
SetArchiveName2(false); // it's for OnInit
|
||||
}
|
||||
|
||||
m_Volume.Enable(!isSFX);
|
||||
if (isSFX)
|
||||
m_Volume.SetText(TEXT(""));
|
||||
}
|
||||
|
||||
void CCompressDialog::OnButtonSetArchive()
|
||||
@@ -420,11 +432,11 @@ void CCompressDialog::OnButtonSetArchive()
|
||||
m_ArchivePath.GetText(fileName);
|
||||
fileName.TrimLeft();
|
||||
fileName.TrimRight();
|
||||
m_Info.ArchiveName = fileName;
|
||||
Info.ArchiveName = fileName;
|
||||
UString fullFileName;
|
||||
if (!m_Info.GetFullPathName(fullFileName))
|
||||
if (!Info.GetFullPathName(fullFileName))
|
||||
{
|
||||
fullFileName = m_Info.ArchiveName;
|
||||
fullFileName = Info.ArchiveName;
|
||||
// throw "Incorrect archive path";
|
||||
return;
|
||||
}
|
||||
@@ -482,42 +494,10 @@ void CCompressDialog::OnButtonSetArchive()
|
||||
// in ExtractDialog.cpp
|
||||
extern void AddUniqueString(CSysStringVector &strings, const CSysString &srcString);
|
||||
|
||||
bool ParseVolumeSize(const CSysString &s, UINT64 &value)
|
||||
{
|
||||
const TCHAR *start = s;
|
||||
const TCHAR *end;
|
||||
value = ConvertStringToUINT64(start, &end);
|
||||
if (start == end)
|
||||
return false;
|
||||
while (true)
|
||||
{
|
||||
TCHAR c = *end++;
|
||||
c = MyCharUpper(c);
|
||||
switch(c)
|
||||
{
|
||||
case TEXT('\0'):
|
||||
case TEXT('B'):
|
||||
return true;
|
||||
case TEXT('K'):
|
||||
value <<= 10;
|
||||
return true;
|
||||
case TEXT('M'):
|
||||
value <<= 20;
|
||||
return true;
|
||||
case TEXT('G'):
|
||||
value <<= 30;
|
||||
return true;
|
||||
case TEXT(' '):
|
||||
continue;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCompressDialog::OnOK()
|
||||
{
|
||||
_passwordControl.GetText(Password);
|
||||
_passwordControl.GetText(Info.Password);
|
||||
|
||||
SaveOptionsInMem();
|
||||
int currentItem = m_ArchivePath.GetCurSel();
|
||||
@@ -537,32 +517,33 @@ void CCompressDialog::OnOK()
|
||||
s.Trim();
|
||||
m_RegistryInfo.HistoryArchives.Clear();
|
||||
AddUniqueString(m_RegistryInfo.HistoryArchives, GetSystemString(s));
|
||||
m_Info.ArchiveName = s;
|
||||
m_Info.UpdateMode = NCompressDialog::NUpdateMode::EEnum(m_UpdateMode.GetCurSel());
|
||||
Info.ArchiveName = s;
|
||||
Info.UpdateMode = NCompressDialog::NUpdateMode::EEnum(m_UpdateMode.GetCurSel());
|
||||
|
||||
m_Info.Level = GetLevelSpec();
|
||||
m_Info.Dictionary = GetDictionarySpec();
|
||||
m_Info.Order = GetOrderSpec();
|
||||
m_Info.OrderMode = GetOrderMode();
|
||||
m_Info.Method = GetUnicodeString(GetMethodSpec());
|
||||
Info.Level = GetLevelSpec();
|
||||
Info.Dictionary = GetDictionarySpec();
|
||||
Info.Order = GetOrderSpec();
|
||||
Info.OrderMode = GetOrderMode();
|
||||
Info.Method = GetUnicodeString(GetMethodSpec());
|
||||
|
||||
m_Info.ArchiverInfoIndex = m_Format.GetCurSel();
|
||||
Info.ArchiverInfoIndex = m_Format.GetCurSel();
|
||||
|
||||
m_Info.SFXMode = IsSFX();
|
||||
m_RegistryInfo.Solid = m_Info.Solid = IsButtonCheckedBool(IDC_COMPRESS_SOLID);
|
||||
m_RegistryInfo.MultiThread = m_Info.MultiThread = IsButtonCheckedBool(IDC_COMPRESS_MULTI_THREAD);
|
||||
m_RegistryInfo.EncryptHeaders = EncryptHeaders = IsButtonCheckedBool(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES);
|
||||
Info.SFXMode = IsSFX();
|
||||
m_RegistryInfo.Solid = Info.Solid = IsButtonCheckedBool(IDC_COMPRESS_SOLID);
|
||||
m_RegistryInfo.MultiThread = Info.MultiThread = IsButtonCheckedBool(IDC_COMPRESS_MULTI_THREAD);
|
||||
m_RegistryInfo.EncryptHeaders = Info.EncryptHeaders = IsButtonCheckedBool(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES);
|
||||
|
||||
m_Params.GetText(m_Info.Options);
|
||||
CSysString volumeString;
|
||||
m_Params.GetText(Info.Options);
|
||||
UString volumeString;
|
||||
m_Volume.GetText(volumeString);
|
||||
volumeString.Trim();
|
||||
m_Info.VolumeSizeIsDefined = ParseVolumeSize(
|
||||
volumeString, m_Info.VolumeSize);
|
||||
/*
|
||||
if (!m_Info.VolumeSizeIsDefined && !volumeString.IsEmpty())
|
||||
MessageBox(0, TEXT("Incorrect volume size"), TEXT("7-Zip"), 0);
|
||||
*/
|
||||
Info.VolumeSizes.Clear();
|
||||
if (!volumeString.IsEmpty())
|
||||
if (!ParseVolumeSizes(volumeString, Info.VolumeSizes))
|
||||
{
|
||||
MessageBox(*this, TEXT("Incorrect volume size"), TEXT("7-Zip"), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < m_ArchivePath.GetCount(); i++)
|
||||
if(i != currentItem)
|
||||
@@ -576,8 +557,8 @@ void CCompressDialog::OnOK()
|
||||
////////////////////
|
||||
// Method
|
||||
|
||||
m_RegistryInfo.Level = m_Info.Level;
|
||||
m_RegistryInfo.ArchiveType = m_ArchiverInfoList[m_Info.ArchiverInfoIndex].Name;
|
||||
m_RegistryInfo.Level = Info.Level;
|
||||
m_RegistryInfo.ArchiveType = m_ArchiverInfoList[Info.ArchiverInfoIndex].Name;
|
||||
|
||||
m_RegistryInfo.ShowPassword = (IsButtonChecked(
|
||||
IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED);
|
||||
@@ -646,7 +627,7 @@ void CCompressDialog::SetArchiveName2(bool prevWasSFX)
|
||||
UString fileName;
|
||||
m_ArchivePath.GetText(fileName);
|
||||
const CArchiverInfo &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat];
|
||||
if (prevArchiverInfo.KeepName || m_Info.KeepName)
|
||||
if (prevArchiverInfo.KeepName || Info.KeepName)
|
||||
{
|
||||
UString prevExtension = prevArchiverInfo.GetMainExtension();
|
||||
if (prevWasSFX)
|
||||
@@ -671,19 +652,23 @@ void CCompressDialog::OnChangeFormat()
|
||||
SetArchiveName2(isSFX);
|
||||
}
|
||||
|
||||
// if type.KeepName then use OriginalFileName
|
||||
// else if !KeepName remove extension
|
||||
// add new extension
|
||||
|
||||
void CCompressDialog::SetArchiveName(const UString &name)
|
||||
{
|
||||
UString fileName = name;
|
||||
m_Info.ArchiverInfoIndex = m_Format.GetCurSel();
|
||||
const CArchiverInfo &ai = m_ArchiverInfoList[m_Info.ArchiverInfoIndex];
|
||||
m_PrevFormat = m_Info.ArchiverInfoIndex;
|
||||
Info.ArchiverInfoIndex = m_Format.GetCurSel();
|
||||
const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
|
||||
m_PrevFormat = Info.ArchiverInfoIndex;
|
||||
if (ai.KeepName)
|
||||
{
|
||||
fileName = OriginalFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_Info.KeepName)
|
||||
if (!Info.KeepName)
|
||||
{
|
||||
int dotPos = fileName.ReverseFind('.');
|
||||
int slashPos = MyMax(fileName.ReverseFind('\\'), fileName.ReverseFind('/'));
|
||||
@@ -736,10 +721,10 @@ int CCompressDialog::GetStaticFormatIndex()
|
||||
}
|
||||
|
||||
void CCompressDialog::SetNearestSelectComboBox(
|
||||
NControl::CComboBox &comboBox, UINT32 value)
|
||||
NControl::CComboBox &comboBox, UInt32 value)
|
||||
{
|
||||
for (int i = comboBox.GetCount() - 1; i >= 0; i--)
|
||||
if (comboBox.GetItemData(i) <= value)
|
||||
if ((UInt32)comboBox.GetItemData(i) <= value)
|
||||
{
|
||||
comboBox.SetCurSel(i);
|
||||
return;
|
||||
@@ -754,7 +739,7 @@ void CCompressDialog::SetLevel()
|
||||
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
|
||||
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
|
||||
int index = FindRegistryFormat(ai.Name);
|
||||
UINT32 level = kNormal;
|
||||
UInt32 level = kNormal;
|
||||
if (index >= 0)
|
||||
{
|
||||
const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
|
||||
@@ -817,9 +802,14 @@ void CCompressDialog::SetMethod()
|
||||
const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
|
||||
defaultMethod = GetUnicodeString(fo.Method);
|
||||
}
|
||||
bool isSfx = IsSFX();
|
||||
for(int m = 0; m < fi.NumMethods; m++)
|
||||
{
|
||||
const LPCWSTR method = kMethodsNames[fi.MathodIDs[m]];
|
||||
EMethodID methodID = fi.MathodIDs[m];
|
||||
if (isSfx)
|
||||
if (!IsMethodSupportedBySfx(methodID))
|
||||
continue;
|
||||
const LPCWSTR method = kMethodsNames[methodID];
|
||||
int itemIndex = m_Method.AddString(GetSystemString(method));
|
||||
if (defaultMethod.CompareNoCase(method) == 0 || m == 0)
|
||||
m_Method.SetCurSel(itemIndex);
|
||||
@@ -848,15 +838,15 @@ CSysString CCompressDialog::GetMethodSpec()
|
||||
return result;
|
||||
}
|
||||
|
||||
int CCompressDialog::AddDictionarySize(UINT32 size, bool kilo, bool maga)
|
||||
int CCompressDialog::AddDictionarySize(UInt32 size, bool kilo, bool maga)
|
||||
{
|
||||
UINT32 sizePrint = size;
|
||||
UInt32 sizePrint = size;
|
||||
if (kilo)
|
||||
sizePrint >>= 10;
|
||||
else if (maga)
|
||||
sizePrint >>= 20;
|
||||
TCHAR s[40];
|
||||
ConvertUINT64ToString(sizePrint, s);
|
||||
ConvertUInt64ToString(sizePrint, s);
|
||||
if (kilo)
|
||||
lstrcat(s, TEXT(" K"));
|
||||
else if (maga)
|
||||
@@ -869,7 +859,7 @@ int CCompressDialog::AddDictionarySize(UINT32 size, bool kilo, bool maga)
|
||||
return index;
|
||||
}
|
||||
|
||||
int CCompressDialog::AddDictionarySize(UINT32 size)
|
||||
int CCompressDialog::AddDictionarySize(UInt32 size)
|
||||
{
|
||||
if (size > 0)
|
||||
{
|
||||
@@ -887,7 +877,7 @@ void CCompressDialog::SetDictionary()
|
||||
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
|
||||
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
|
||||
int index = FindRegistryFormat(ai.Name);
|
||||
UINT32 defaultDictionary = UINT32(-1);
|
||||
UInt32 defaultDictionary = UInt32(-1);
|
||||
if (index >= 0)
|
||||
{
|
||||
const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
|
||||
@@ -905,7 +895,7 @@ void CCompressDialog::SetDictionary()
|
||||
{
|
||||
case kLZMA:
|
||||
{
|
||||
if (defaultDictionary == UINT32(-1))
|
||||
if (defaultDictionary == UInt32(-1))
|
||||
{
|
||||
if (level >= 9)
|
||||
defaultDictionary = (32 << 20);
|
||||
@@ -923,7 +913,7 @@ void CCompressDialog::SetDictionary()
|
||||
{
|
||||
if (i == 20 && j > 0)
|
||||
continue;
|
||||
UINT32 dictionary = (1 << i) + (j << (i - 1));
|
||||
UInt32 dictionary = (1 << i) + (j << (i - 1));
|
||||
AddDictionarySize(dictionary);
|
||||
}
|
||||
SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
|
||||
@@ -931,7 +921,7 @@ void CCompressDialog::SetDictionary()
|
||||
}
|
||||
case kPPMd:
|
||||
{
|
||||
if (defaultDictionary == UINT32(-1))
|
||||
if (defaultDictionary == UInt32(-1))
|
||||
{
|
||||
if (level >= 9)
|
||||
defaultDictionary = (192 << 20);
|
||||
@@ -948,7 +938,7 @@ void CCompressDialog::SetDictionary()
|
||||
{
|
||||
if (i == 20 && j > 0)
|
||||
continue;
|
||||
UINT32 dictionary = (1 << i) + (j << (i - 1));
|
||||
UInt32 dictionary = (1 << i) + (j << (i - 1));
|
||||
if (dictionary >= (1 << 31))
|
||||
continue;
|
||||
AddDictionarySize(dictionary);
|
||||
@@ -978,24 +968,24 @@ void CCompressDialog::SetDictionary()
|
||||
SetMemoryUsage();
|
||||
}
|
||||
|
||||
UINT32 CCompressDialog::GetDictionary()
|
||||
UInt32 CCompressDialog::GetDictionary()
|
||||
{
|
||||
if (m_Dictionary.GetCount() <= 0)
|
||||
return -1;
|
||||
return m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
|
||||
}
|
||||
|
||||
UINT32 CCompressDialog::GetDictionarySpec()
|
||||
UInt32 CCompressDialog::GetDictionarySpec()
|
||||
{
|
||||
if (m_Dictionary.GetCount() <= 1)
|
||||
return -1;
|
||||
return GetDictionary();
|
||||
}
|
||||
|
||||
int CCompressDialog::AddOrder(UINT32 size)
|
||||
int CCompressDialog::AddOrder(UInt32 size)
|
||||
{
|
||||
TCHAR s[40];
|
||||
ConvertUINT64ToString(size, s);
|
||||
ConvertUInt64ToString(size, s);
|
||||
int index = m_Order.AddString(s);
|
||||
m_Order.SetItemData(index, size);
|
||||
return index;
|
||||
@@ -1007,7 +997,7 @@ void CCompressDialog::SetOrder()
|
||||
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
|
||||
const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
|
||||
int index = FindRegistryFormat(ai.Name);
|
||||
UINT32 defaultOrder = UINT32(-1);
|
||||
UInt32 defaultOrder = UInt32(-1);
|
||||
if (index >= 0)
|
||||
{
|
||||
const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
|
||||
@@ -1025,7 +1015,7 @@ void CCompressDialog::SetOrder()
|
||||
{
|
||||
case kLZMA:
|
||||
{
|
||||
if (defaultOrder == UINT32(-1))
|
||||
if (defaultOrder == UInt32(-1))
|
||||
{
|
||||
if (level >= 7)
|
||||
defaultOrder = 64;
|
||||
@@ -1036,7 +1026,7 @@ void CCompressDialog::SetOrder()
|
||||
for (i = 3; i < 8; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
UINT32 order = (1 << i) + (j << (i - 1));
|
||||
UInt32 order = (1 << i) + (j << (i - 1));
|
||||
if (order < 255)
|
||||
AddOrder(order);
|
||||
}
|
||||
@@ -1046,7 +1036,7 @@ void CCompressDialog::SetOrder()
|
||||
}
|
||||
case kPPMd:
|
||||
{
|
||||
if (defaultOrder == UINT32(-1))
|
||||
if (defaultOrder == UInt32(-1))
|
||||
{
|
||||
if (level >= 9)
|
||||
defaultOrder = 32;
|
||||
@@ -1063,7 +1053,7 @@ void CCompressDialog::SetOrder()
|
||||
for (i = 2; i < 8; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
UINT32 order = (1 << i) + (j << (i - 2));
|
||||
UInt32 order = (1 << i) + (j << (i - 2));
|
||||
if (order < 32)
|
||||
AddOrder(order);
|
||||
}
|
||||
@@ -1074,7 +1064,7 @@ void CCompressDialog::SetOrder()
|
||||
case kDeflate:
|
||||
case kDeflate64:
|
||||
{
|
||||
if (defaultOrder == UINT32(-1))
|
||||
if (defaultOrder == UInt32(-1))
|
||||
{
|
||||
if (level >= 7)
|
||||
defaultOrder = 64;
|
||||
@@ -1085,7 +1075,7 @@ void CCompressDialog::SetOrder()
|
||||
for (i = 3; i < 8; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
UINT32 order = (1 << i) + (j << (i - 1));
|
||||
UInt32 order = (1 << i) + (j << (i - 1));
|
||||
if (order < 255)
|
||||
AddOrder(order);
|
||||
}
|
||||
@@ -1105,34 +1095,30 @@ bool CCompressDialog::GetOrderMode()
|
||||
{
|
||||
switch (GetMethodID())
|
||||
{
|
||||
case kLZMA:
|
||||
case kDeflate:
|
||||
case kDeflate64:
|
||||
return false;
|
||||
case kPPMd:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 CCompressDialog::GetOrder()
|
||||
UInt32 CCompressDialog::GetOrder()
|
||||
{
|
||||
if (m_Order.GetCount() <= 0)
|
||||
return -1;
|
||||
return m_Order.GetItemData(m_Order.GetCurSel());
|
||||
}
|
||||
|
||||
UINT32 CCompressDialog::GetOrderSpec()
|
||||
UInt32 CCompressDialog::GetOrderSpec()
|
||||
{
|
||||
if (m_Order.GetCount() <= 1)
|
||||
return -1;
|
||||
return GetOrder();
|
||||
}
|
||||
|
||||
UINT64 CCompressDialog::GetMemoryUsage(UINT64 &decompressMemory)
|
||||
UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
|
||||
{
|
||||
decompressMemory = UINT64(INT64(-1));
|
||||
UINT32 dictionary = GetDictionary();
|
||||
decompressMemory = UInt64(Int64(-1));
|
||||
UInt32 dictionary = GetDictionary();
|
||||
int level = GetLevel2();
|
||||
if (level == 0)
|
||||
{
|
||||
@@ -1143,17 +1129,17 @@ UINT64 CCompressDialog::GetMemoryUsage(UINT64 &decompressMemory)
|
||||
{
|
||||
case kLZMA:
|
||||
{
|
||||
UINT64 size;
|
||||
UInt64 size;
|
||||
if (level >= 5)
|
||||
{
|
||||
size = ((UINT64)dictionary * 19 / 2) + (2 << 20);
|
||||
size = ((UInt64)dictionary * 19 / 2) + (2 << 20);
|
||||
if (level >= 9)
|
||||
size += (34 << 20) + (12 << 20) * 2 + (5 << 20);
|
||||
else
|
||||
size += (6 << 20);
|
||||
}
|
||||
else
|
||||
size = ((UINT64)dictionary * 11 / 2) + (2 << 20);
|
||||
size = ((UInt64)dictionary * 11 / 2) + (2 << 20);
|
||||
decompressMemory = dictionary + (2 << 20);
|
||||
return size;
|
||||
}
|
||||
@@ -1165,10 +1151,10 @@ UINT64 CCompressDialog::GetMemoryUsage(UINT64 &decompressMemory)
|
||||
case kDeflate:
|
||||
case kDeflate64:
|
||||
{
|
||||
UINT32 order = GetOrder();
|
||||
if (order == UINT32(-1))
|
||||
UInt32 order = GetOrder();
|
||||
if (order == UInt32(-1))
|
||||
order = 32;
|
||||
UINT64 size = 0;
|
||||
UInt64 size = 0;
|
||||
if (level >= 7)
|
||||
size = (order * 2 + 4) * (64 << 10);
|
||||
size += 3 << 20;
|
||||
@@ -1181,27 +1167,27 @@ UINT64 CCompressDialog::GetMemoryUsage(UINT64 &decompressMemory)
|
||||
return 10 << 20;
|
||||
}
|
||||
}
|
||||
return UINT64(INT64(-1));
|
||||
return UInt64(Int64(-1));
|
||||
}
|
||||
|
||||
void CCompressDialog::PrintMemUsage(UINT res, UINT64 value)
|
||||
void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
|
||||
{
|
||||
if (value == (UINT64)INT64(-1))
|
||||
if (value == (UInt64)Int64(-1))
|
||||
{
|
||||
SetItemText(res, TEXT("?"));
|
||||
return;
|
||||
}
|
||||
value = (value + (1 << 20) - 1) >> 20;
|
||||
TCHAR s[40];
|
||||
ConvertUINT64ToString(value, s);
|
||||
ConvertUInt64ToString(value, s);
|
||||
lstrcat(s, TEXT(" MB"));
|
||||
SetItemText(res, s);
|
||||
}
|
||||
|
||||
void CCompressDialog::SetMemoryUsage()
|
||||
{
|
||||
UINT64 decompressMem;
|
||||
UINT64 memUsage = GetMemoryUsage(decompressMem);
|
||||
UInt64 decompressMem;
|
||||
UInt64 memUsage = GetMemoryUsage(decompressMem);
|
||||
PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_VALUE, memUsage);
|
||||
PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, decompressMem);
|
||||
}
|
||||
@@ -1220,12 +1206,12 @@ void CCompressDialog::SetParams()
|
||||
|
||||
void CCompressDialog::SaveOptionsInMem()
|
||||
{
|
||||
const CArchiverInfo &ai = m_ArchiverInfoList[m_Info.ArchiverInfoIndex];
|
||||
const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
|
||||
int index = FindRegistryFormatAlways(ai.Name);
|
||||
m_Params.GetText(m_Info.Options);
|
||||
m_Info.Options.Trim();
|
||||
m_Params.GetText(Info.Options);
|
||||
Info.Options.Trim();
|
||||
NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
|
||||
fo.Options = m_Info.Options;
|
||||
fo.Options = GetSystemString(Info.Options);
|
||||
fo.Level = GetLevelSpec();
|
||||
fo.Dictionary = GetDictionarySpec();
|
||||
fo.Order = GetOrderSpec();
|
||||
|
||||
Reference in New Issue
Block a user