4.34 beta

This commit is contained in:
Igor Pavlov
2006-03-01 00:00:00 +00:00
committed by Kornel Lesiński
parent 02516d3fce
commit 0f60a4933b
77 changed files with 2173 additions and 832 deletions

View File

@@ -27,7 +27,7 @@ using namespace NCommandLineParser;
using namespace NWindows;
using namespace NFile;
static const int kNumSwitches = 25;
static const int kNumSwitches = 26;
namespace NKey {
enum Enum
@@ -56,7 +56,8 @@ enum Enum
kOverwrite,
kEmail,
kShowDialog,
kLargePages
kLargePages,
kCharSet
};
}
@@ -119,7 +120,8 @@ static const CSwitchForm kSwitchForms[kNumSwitches] =
{ L"AO", NSwitchType::kPostChar, false, 1, 1, kOverwritePostCharSet},
{ L"SEML", NSwitchType::kUnLimitedPostString, false, 0},
{ L"AD", NSwitchType::kSimple, false },
{ L"SLP", NSwitchType::kUnLimitedPostString, false, 0}
{ L"SLP", NSwitchType::kUnLimitedPostString, false, 0},
{ L"SCS", NSwitchType::kUnLimitedPostString, false, 0}
};
static const int kNumCommandForms = 7;
@@ -234,15 +236,13 @@ static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
return true;
}
static inline UINT GetCurrentCodePage()
{ return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
static inline GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
LPCWSTR fileName, bool include, NRecursedType::EEnum type)
LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
{
UStringVector names;
if (!ReadNamesFromListFile(GetSystemString(fileName,
GetCurrentCodePage()), names))
if (!ReadNamesFromListFile(GetSystemString(fileName, GetCurrentCodePage()), names, codePage))
throw kIncorrectListFile;
for (int i = 0; i < names.Size(); i++)
if (!AddNameToCensor(wildcardCensor, names[i], include, type))
@@ -260,7 +260,7 @@ static void AddToCensorFromNonSwitchesStrings(
int startIndex,
NWildcard::CCensor &wildcardCensor,
const UStringVector &nonSwitchStrings, NRecursedType::EEnum type,
bool thereAreSwitchIncludes)
bool thereAreSwitchIncludes, UINT codePage)
{
if(nonSwitchStrings.Size() == startIndex && (!thereAreSwitchIncludes))
AddCommandLineWildCardToCensr(wildcardCensor, kUniversalWildcard, true, type);
@@ -268,7 +268,7 @@ static void AddToCensorFromNonSwitchesStrings(
{
const UString &s = nonSwitchStrings[i];
if (s[0] == kFileListID)
AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type);
AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type, codePage);
else
AddCommandLineWildCardToCensr(wildcardCensor, s, true, type);
}
@@ -341,7 +341,7 @@ static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
const UStringVector &strings, bool include,
NRecursedType::EEnum commonRecursedType)
NRecursedType::EEnum commonRecursedType, UINT codePage)
{
for(int i = 0; i < strings.Size(); i++)
{
@@ -366,7 +366,7 @@ static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
if (name[pos] == kImmediateNameID)
AddCommandLineWildCardToCensr(wildcardCensor, tail, include, recursedType);
else if (name[pos] == kFileListID)
AddToCensorFromListFile(wildcardCensor, tail, include, recursedType);
AddToCensorFromListFile(wildcardCensor, tail, include, recursedType, codePage);
#ifdef _WIN32
else if (name[pos] == kMapNameID)
ParseMapWithPaths(wildcardCensor, tail, include, recursedType);
@@ -632,8 +632,7 @@ static void SetAddCommandOptions(
}
}
static void SetMethodOptions(const CParser &parser,
CUpdateOptions &options)
static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &properties)
{
if (parser[NKey::kProperty].ThereIs)
{
@@ -650,7 +649,7 @@ static void SetMethodOptions(const CParser &parser,
property.Name = postString.Left(index);
property.Value = postString.Mid(index + 1);
}
options.MethodMode.Properties.Add(property);
properties.Add(property);
}
}
}
@@ -723,6 +722,21 @@ void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
#endif
}
struct CCodePagePair
{
const wchar_t *Name;
UINT CodePage;
};
static CCodePagePair g_CodePagePairs[] =
{
{ L"UTF-8", CP_UTF8 },
{ L"WIN", CP_ACP },
{ L"DOS", CP_OEMCP }
};
static const int kNumCodePages = sizeof(g_CodePagePairs) / sizeof(g_CodePagePairs[0]);
void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
{
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
@@ -739,16 +753,35 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
else
recursedType = NRecursedType::kNonRecursed;
UINT codePage = CP_UTF8;
if (parser[NKey::kCharSet].ThereIs)
{
UString name = parser[NKey::kCharSet].PostStrings.Front();
name.MakeUpper();
int i;
for (i = 0; i < kNumCodePages; i++)
{
const CCodePagePair &pair = g_CodePagePairs[i];
if (name.Compare(pair.Name) == 0)
{
codePage = pair.CodePage;
break;
}
}
if (i >= kNumCodePages)
throw kUserErrorMessage;
}
bool thereAreSwitchIncludes = false;
if (parser[NKey::kInclude].ThereIs)
{
thereAreSwitchIncludes = true;
AddSwitchWildCardsToCensor(options.WildcardCensor,
parser[NKey::kInclude].PostStrings, true, recursedType);
parser[NKey::kInclude].PostStrings, true, recursedType, codePage);
}
if (parser[NKey::kExclude].ThereIs)
AddSwitchWildCardsToCensor(options.WildcardCensor,
parser[NKey::kExclude].PostStrings, false, recursedType);
parser[NKey::kExclude].PostStrings, false, recursedType, codePage);
int curCommandIndex = kCommandIndex + 1;
bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs;
@@ -761,7 +794,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
AddToCensorFromNonSwitchesStrings(
curCommandIndex, options.WildcardCensor,
nonSwitchStrings, recursedType, thereAreSwitchIncludes);
nonSwitchStrings, recursedType, thereAreSwitchIncludes, codePage);
options.YesToAll = parser[NKey::kYes].ThereIs;
@@ -787,11 +820,11 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
if (parser[NKey::kArInclude].ThereIs)
{
AddSwitchWildCardsToCensor(archiveWildcardCensor,
parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed);
parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage);
}
if (parser[NKey::kArExclude].ThereIs)
AddSwitchWildCardsToCensor(archiveWildcardCensor,
parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed);
parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage);
if (thereIsArchiveName)
AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);
@@ -840,6 +873,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
if(isExtractGroupCommand)
{
SetMethodOptions(parser, options.ExtractProperties);
if (options.StdOutMode && options.IsStdOutTerminal)
throw kTerminalOutError;
if(parser[NKey::kOutputDir].ThereIs)
@@ -882,10 +916,9 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
updateOptions.ArchivePath.BaseExtension = extension;
updateOptions.ArchivePath.VolExtension = typeExtension;
updateOptions.ArchivePath.ParseFromPath(options.ArchiveName);
SetAddCommandOptions(options.Command.CommandType, parser,
updateOptions);
SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
SetMethodOptions(parser, updateOptions);
SetMethodOptions(parser, updateOptions.MethodMode.Properties);
options.EnablePercents = !parser[NKey::kDisablePercents].ThereIs;

View File

@@ -68,6 +68,7 @@ struct CArchiveCommandLineOptions
NExtract::NOverwriteMode::EEnum OverwriteMode;
UStringVector ArchivePathsSorted;
UStringVector ArchivePathsFullSorted;
CObjectVector<CProperty> ExtractProperties;
CUpdateOptions UpdateOptions;
bool EnablePercents;

View File

@@ -5,10 +5,10 @@
#include "Extract.h"
#include "Windows/Defs.h"
#include "Windows/PropVariant.h"
#include "Windows/FileDir.h"
#include "OpenArchive.h"
#include "SetProperties.h"
#ifndef EXCLUDE_COM
#include "Windows/DLL.h"
@@ -68,6 +68,10 @@ HRESULT DecompressArchive(
options.ArchiveFileInfo.LastWriteTime,
options.ArchiveFileInfo.Attributes);
#ifdef COMPRESS_MT
RINOK(SetProperties(archive, options.Properties));
#endif
HRESULT result = archive->Extract(&realIndices.Front(),
realIndices.Size(), options.TestMode? 1: 0,
extractCallback);

View File

@@ -11,6 +11,7 @@
#include "ArchiveExtractCallback.h"
#include "ArchiveOpenCallback.h"
#include "ExtractMode.h"
#include "Property.h"
class CExtractOptions
{
@@ -27,6 +28,9 @@ public:
// bool ShowDialog;
// bool PasswordEnabled;
// UString Password;
#ifdef COMPRESS_MT
CObjectVector<CProperty> Properties;
#endif
NExtract::NOverwriteMode::EEnum OverwriteMode;

14
7zip/UI/Common/Property.h Executable file
View File

@@ -0,0 +1,14 @@
// Property.h
#ifndef __PROPERTY_H
#define __PROPERTY_H
#include "Common/String.h"
struct CProperty
{
UString Name;
UString Value;
};
#endif

View File

@@ -0,0 +1,65 @@
// SetProperties.cpp
#include "StdAfx.h"
#include "SetProperties.h"
#include "Windows/PropVariant.h"
#include "Common/String.h"
#include "Common/StringToInt.h"
#include "Common/MyCom.h"
#include "../../Archive/IArchive.h"
using namespace NWindows;
using namespace NCOM;
static void ParseNumberString(const UString &s, NCOM::CPropVariant &prop)
{
const wchar_t *endPtr;
UInt64 result = ConvertStringToUInt64(s, &endPtr);
if (endPtr - (const wchar_t *)s != s.Length())
prop = s;
else if (result <= 0xFFFFFFFF)
prop = (UInt32)result;
else
prop = result;
}
HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &properties)
{
if (properties.IsEmpty())
return S_OK;
CMyComPtr<ISetProperties> setProperties;
unknown->QueryInterface(IID_ISetProperties, (void **)&setProperties);
if (!setProperties)
return S_OK;
UStringVector realNames;
CPropVariant *values = new CPropVariant[properties.Size()];
try
{
int i;
for(i = 0; i < properties.Size(); i++)
{
const CProperty &property = properties[i];
NCOM::CPropVariant propVariant;
if (!property.Value.IsEmpty())
ParseNumberString(property.Value, propVariant);
realNames.Add(property.Name);
values[i] = propVariant;
}
CRecordVector<const wchar_t *> names;
for(i = 0; i < realNames.Size(); i++)
names.Add((const wchar_t *)realNames[i]);
RINOK(setProperties->SetProperties(&names.Front(), values, names.Size()));
}
catch(...)
{
delete []values;
throw;
}
delete []values;
return S_OK;
}

10
7zip/UI/Common/SetProperties.h Executable file
View File

@@ -0,0 +1,10 @@
// SetProperties.h
#ifndef __SETPROPERTIES_H
#define __SETPROPERTIES_H
#include "Property.h"
HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &properties);
#endif

View File

@@ -9,7 +9,6 @@
#include "Update.h"
#include "Common/IntToString.h"
#include "Common/StringToInt.h"
#include "Common/StringConvert.h"
#include "Common/CommandLineParser.h"
@@ -36,6 +35,7 @@
#include "TempFiles.h"
#include "UpdateCallback.h"
#include "EnumDirItems.h"
#include "SetProperties.h"
#ifdef FORMAT_7Z
#include "../../Archive/7z/7zHandler.h"
@@ -77,18 +77,6 @@ static const char *kIllegalFileNameMessage = "Illegal file name for temp archive
using namespace NUpdateArchive;
static void ParseNumberString(const UString &s, NCOM::CPropVariant &prop)
{
const wchar_t *endPtr;
UInt64 result = ConvertStringToUInt64(s, &endPtr);
if (endPtr - (const wchar_t *)s != s.Length())
prop = s;
else if (result <= 0xFFFFFFFF)
prop = (UInt32)result;
else
prop = result;
}
static HRESULT CopyBlock(ISequentialInStream *inStream, ISequentialOutStream *outStream)
{
CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
@@ -439,36 +427,7 @@ static HRESULT Compress(
*/
}
CMyComPtr<ISetProperties> setProperties;
if (outArchive.QueryInterface(IID_ISetProperties, &setProperties) == S_OK)
{
UStringVector realNames;
CPropVariant *values = new CPropVariant[compressionMethod.Properties.Size()];
try
{
int i;
for(i = 0; i < compressionMethod.Properties.Size(); i++)
{
const CProperty &property = compressionMethod.Properties[i];
NCOM::CPropVariant propVariant;
if (!property.Value.IsEmpty())
ParseNumberString(property.Value, propVariant);
realNames.Add(property.Name);
values[i] = propVariant;
}
CRecordVector<const wchar_t *> names;
for(i = 0; i < realNames.Size(); i++)
names.Add((const wchar_t *)realNames[i]);
RINOK(setProperties->SetProperties(&names.Front(), values, names.Size()));
}
catch(...)
{
delete []values;
throw;
}
delete []values;
}
RINOK(SetProperties(outArchive, compressionMethod.Properties));
if (sfxMode)
{

View File

@@ -10,6 +10,7 @@
#include "UpdateAction.h"
#include "ArchiveOpenCallback.h"
#include "UpdateCallback.h"
#include "Property.h"
struct CArchivePath
{
@@ -75,12 +76,6 @@ struct CUpdateArchiveCommand
NUpdateArchive::CActionSet ActionSet;
};
struct CProperty
{
UString Name;
UString Value;
};
struct CCompressionMethodMode
{
#ifndef EXCLUDE_COM
@@ -111,7 +106,7 @@ struct CUpdateOptions
bool EMailRemoveAfter;
UString EMailAddress;
UString WorkingDir;
UString WorkingDir;
CUpdateOptions():
UpdateArchiveItself(true),

View File

@@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -69,7 +69,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -94,7 +94,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Yu"StdAfx.h" /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -120,7 +120,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Yu"StdAfx.h" /FD /GZ /c
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -532,6 +532,10 @@ SOURCE=..\Common\OpenArchive.h
# End Source File
# Begin Source File
SOURCE=..\Common\Property.h
# End Source File
# Begin Source File
SOURCE=..\Common\PropIDUtils.cpp
# End Source File
# Begin Source File
@@ -540,6 +544,14 @@ SOURCE=..\Common\PropIDUtils.h
# End Source File
# Begin Source File
SOURCE=..\Common\SetProperties.cpp
# End Source File
# Begin Source File
SOURCE=..\Common\SetProperties.h
# End Source File
# Begin Source File
SOURCE=..\Common\SortUtils.cpp
# End Source File
# Begin Source File

View File

@@ -220,6 +220,9 @@ int Main2(
eo.OverwriteMode = options.OverwriteMode;
eo.OutputDir = options.OutputDir;
eo.YesToAll = options.YesToAll;
#ifdef COMPRESS_MT
eo.Properties = options.ExtractProperties;
#endif
HRESULT result = DecompressArchives(
options.ArchivePathsSorted,
options.ArchivePathsFullSorted,

View File

@@ -131,7 +131,7 @@ HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool isAnti)
m_PercentPrinter.PrintString("Anti item ");
else
m_PercentPrinter.PrintString("Compressing ");
if (wcslen(name) == 0)
if (name[0] == 0)
name = kEmptyFileAlias;
m_PercentPrinter.PrintString(name);
if (EnablePercents)

View File

@@ -1,6 +1,6 @@
PROG = 7z.exe
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib
CFLAGS = $(CFLAGS) -I ../../../
CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
CONSOLE_OBJS = \
$O\ConsoleClose.obj \
@@ -56,6 +56,7 @@ UI_COMMON_OBJS = \
$O\ExtractingFilePath.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SetProperties.obj \
$O\SortUtils.obj \
$O\TempFiles.obj \
$O\Update.obj \

View File

@@ -10,6 +10,7 @@
#include "Windows/FileDir.h"
#include "Windows/FileName.h"
#include "Windows/ResourceString.h"
#include "Windows/System.h"
#include "../../FileManager/HelpUtils.h"
#include "../../FileManager/SplitUtils.h"
@@ -178,9 +179,9 @@ static const CFormatInfo g_Formats[] =
},
{
L"Zip",
(1 << 0) | (1 << 5) | (1 << 7) | (1 << 9),
(1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
g_ZipMethods, MY_SIZE_OF_ARRAY(g_ZipMethods) ,
false, false, false, false, true, false
false, false, true, false, true, false
},
{
L"GZip",
@@ -190,10 +191,10 @@ static const CFormatInfo g_Formats[] =
},
{
L"BZip2",
(1 << 5) | (1 << 7) | (1 << 9),
(1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
g_BZip2Methods,
MY_SIZE_OF_ARRAY(g_BZip2Methods),
false, false, false, false, false
false, false, true, false, false
},
{
L"Tar",
@@ -211,6 +212,49 @@ 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();
const UInt64 kMinSysSize = (1 << 24);
if (physSize <= kMinSysSize)
physSize = 0;
else
physSize -= kMinSysSize;
const UInt64 kMinUseSize = (1 << 25);
if (physSize < kMinUseSize)
physSize = kMinUseSize;
return physSize;
}
bool CCompressDialog::OnInit()
{
#ifdef LANG
@@ -326,9 +370,7 @@ bool CCompressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
static bool IsMultiProcessor()
{
SYSTEM_INFO systemInfo;
GetSystemInfo(&systemInfo);
return systemInfo.dwNumberOfProcessors > 1;
return NSystem::GetNumberOfProcessors() > 1;
}
void CCompressDialog::CheckSFXControlsEnable()
@@ -837,6 +879,7 @@ void CCompressDialog::SetDictionary()
SetMemoryUsage();
return;
}
const UInt64 maxRamSize = GetMaxRamSizeForProgram();
switch (methodID)
{
case kLZMA:
@@ -857,22 +900,29 @@ void CCompressDialog::SetDictionary()
}
int i;
AddDictionarySize(kMinDicSize);
m_Dictionary.SetCurSel(0);
for (i = 20; i <= 30; i++)
for (int j = 0; j < 2; j++)
{
if (i == 20 && j > 0)
continue;
UInt32 dictionary = (1 << i) + (j << (i - 1));
if (dictionary <=
if (dictionary >
#ifdef _WIN64
(1 << 30)
#else
(1 << 27)
#endif
)
AddDictionarySize(dictionary);
continue;
AddDictionarySize(dictionary);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
// SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
break;
}
case kPPMd:
@@ -898,6 +948,10 @@ void CCompressDialog::SetDictionary()
if (dictionary >= (1 << 31))
continue;
AddDictionarySize(dictionary);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
break;
@@ -916,8 +970,20 @@ void CCompressDialog::SetDictionary()
}
case kBZip2:
{
AddDictionarySize(900 << 10);
m_Dictionary.SetCurSel(0);
UInt32 defaultDictionary;
if (level >= 5)
defaultDictionary = (900 << 10);
else if (level >= 3)
defaultDictionary = (500 << 10);
else
defaultDictionary = (100 << 10);
for (int i = 1; i <= 9; i++)
{
UInt32 dictionary = (i * 100) << 10;
AddDictionarySize(dictionary);
if (dictionary <= defaultDictionary || m_Dictionary.GetCount() == 0)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
break;
}
}
@@ -1067,10 +1133,9 @@ UInt32 CCompressDialog::GetOrderSpec()
return GetOrder();
}
UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory)
{
decompressMemory = UInt64(Int64(-1));
UInt32 dictionary = GetDictionary();
int level = GetLevel2();
if (level == 0)
{
@@ -1082,7 +1147,6 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
if (fi.Filter && level >= 9)
size += (12 << 20) * 2 + (5 << 20);
bool isMultiThread = IsMultiThread();
switch (GetMethodID())
{
case kLZMA:
@@ -1128,12 +1192,20 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
case kBZip2:
{
decompressMemory = (7 << 20);
UInt64 memForOneThread = (10 << 20);
if (isMultiThread)
memForOneThread *= NSystem::GetNumberOfProcessors();
return size + (10 << 20);
}
}
return UInt64(Int64(-1));
}
UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
{
return GetMemoryUsage(GetDictionary(), IsMultiThread(), decompressMemory);
}
void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
{
if (value == (UInt64)Int64(-1))

View File

@@ -123,6 +123,7 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
UInt32 GetOrder();
UInt32 GetOrderSpec();
UInt64 GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory);
UInt64 GetMemoryUsage(UInt64 &decompressMemory);
void PrintMemUsage(UINT res, UInt64 value);
void SetMemoryUsage();

View File

@@ -104,6 +104,9 @@ int Main2()
eo.OverwriteMode = options.OverwriteMode;
eo.PathMode = options.Command.GetPathMode();
eo.TestMode = options.Command.IsTestMode();
#ifdef COMPRESS_MT
eo.Properties = options.ExtractProperties;
#endif
HRESULT result = ExtractGUI(
options.ArchivePathsSorted,

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 /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /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"
@@ -72,7 +72,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -99,7 +99,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /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"
@@ -127,7 +127,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -549,6 +549,10 @@ SOURCE=..\Common\OpenArchive.h
# End Source File
# Begin Source File
SOURCE=..\Common\Property.h
# End Source File
# Begin Source File
SOURCE=..\Common\PropIDUtils.cpp
# End Source File
# Begin Source File
@@ -557,6 +561,14 @@ SOURCE=..\Common\PropIDUtils.h
# End Source File
# Begin Source File
SOURCE=..\Common\SetProperties.cpp
# End Source File
# Begin Source File
SOURCE=..\Common\SetProperties.h
# End Source File
# Begin Source File
SOURCE=..\Common\SortUtils.cpp
# End Source File
# Begin Source File

View File

@@ -1,6 +1,6 @@
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
CFLAGS = $(CFLAGS) -I ../../../ -DLANG -DCOMPRESS_MT
GUI_OBJS = \
$O\CompressDialog.obj \
@@ -65,6 +65,7 @@ UI_COMMON_OBJS = \
$O\ExtractingFilePath.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SetProperties.obj \
$O\SortUtils.obj \
$O\TempFiles.obj \
$O\Update.obj \