4.41 beta

This commit is contained in:
Igor Pavlov
2006-05-09 00:00:00 +00:00
committed by Kornel Lesiński
parent bd9a40b0ed
commit 631462beb2
19 changed files with 209 additions and 194 deletions

View File

@@ -167,17 +167,6 @@ private:
bool _compressHeadersFull;
bool _encryptHeaders;
bool _copyMode;
UInt32 _defaultDicSize;
UInt32 _defaultAlgorithm;
UInt32 _defaultFastBytes;
UInt32 _defaultPasses;
UString _defaultMatchFinder;
UInt32 _defaultPpmdMemSize;
UInt32 _defaultPpmdOrder;
bool _autoFilter;
UInt32 _level;
@@ -221,30 +210,6 @@ private:
_solidExtension = false;
_numSolidBytesDefined = false;
}
/*
void InitSolidPart()
{
if (_numSolidFiles <= 1)
InitSolidFiles();
}
*/
void SetSolidBytesLimit()
{
_numSolidBytes = ((UInt64)_defaultDicSize) << 7;
const UInt64 kMinSize = (1<<24);
if (_numSolidBytes < kMinSize)
_numSolidBytes = kMinSize;
}
void CheckAndSetSolidBytesLimit()
{
if (!_numSolidBytesDefined)
{
if (_copyMode)
_numSolidBytes = 0;
else
SetSolidBytesLimit();
}
}
void Init()
{
@@ -255,22 +220,11 @@ private:
#ifdef COMPRESS_MT
_numThreads = NWindows::NSystem::GetNumberOfProcessors();
#endif
_copyMode = false;
_defaultDicSize =
_defaultAlgorithm =
_defaultFastBytes =
_defaultPasses =
_defaultPpmdMemSize =
_defaultPpmdOrder = 0xFFFFFFFF;
_defaultMatchFinder.Empty();
_level = 5;
_autoFilter = true;
_volumeMode = false;
InitSolid();
SetSolidBytesLimit();
}
#endif
};

View File

@@ -117,6 +117,9 @@ static const UInt32 kDictionaryForHeaders = 1 << 20;
static const UInt32 kNumFastBytesForHeaders = 273;
static const UInt32 kAlgorithmForHeaders = kLzmaAlgorithmX5;
static bool IsCopyMethod(const UString &methodName)
{ return (methodName.CompareNoCase(kCopyMethod) == 0); }
static bool IsLZMAMethod(const UString &methodName)
{ return (methodName.CompareNoCase(kLZMAMethodName) == 0); }
static bool IsLZMethod(const UString &methodName)
@@ -304,47 +307,45 @@ HRESULT CHandler::SetCompressionMethod(
#endif
UInt32 level = _level;
if (methodsInfo.IsEmpty())
{
COneMethodInfo oneMethodInfo;
oneMethodInfo.MethodName = _copyMode ? kCopyMethod : kDefaultMethodName;
oneMethodInfo.MethodName = ((level == 0) ? kCopyMethod : kDefaultMethodName);
methodsInfo.Add(oneMethodInfo);
}
UInt32 level = _level;
bool needSolid = false;
for(int i = 0; i < methodsInfo.Size(); i++)
{
COneMethodInfo &oneMethodInfo = methodsInfo[i];
if (oneMethodInfo.MethodName.IsEmpty())
oneMethodInfo.MethodName = kDefaultMethodName;
if (!IsCopyMethod(oneMethodInfo.MethodName))
needSolid = true;
if (IsLZMAMethod(oneMethodInfo.MethodName))
{
UInt32 dicSize = _defaultDicSize;
if (dicSize == 0xFFFFFFFF)
dicSize = (level >= 9 ? kLzmaDicSizeX9 :
UInt32 dicSize =
(level >= 9 ? kLzmaDicSizeX9 :
(level >= 7 ? kLzmaDicSizeX7 :
(level >= 5 ? kLzmaDicSizeX5 :
(level >= 3 ? kLzmaDicSizeX3 :
kLzmaDicSizeX1))));
UInt32 algorithm = _defaultAlgorithm;
if (algorithm == 0xFFFFFFFF)
algorithm = (level >= 5 ? kLzmaAlgorithmX5 :
UInt32 algorithm =
(level >= 5 ? kLzmaAlgorithmX5 :
kLzmaAlgorithmX1);
UInt32 fastBytes = _defaultFastBytes;
if (fastBytes == 0xFFFFFFFF)
fastBytes = (level >= 7 ? kLzmaFastBytesX7 :
UInt32 fastBytes =
(level >= 7 ? kLzmaFastBytesX7 :
kLzmaFastBytesX1);
const wchar_t *matchFinder = 0;
if (_defaultMatchFinder.IsEmpty())
matchFinder = (level >= 5 ? kLzmaMatchFinderX5 :
const wchar_t *matchFinder =
(level >= 5 ? kLzmaMatchFinderX5 :
kLzmaMatchFinderX1);
else
matchFinder = (const wchar_t *)_defaultMatchFinder;
SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algorithm);
@@ -356,15 +357,13 @@ HRESULT CHandler::SetCompressionMethod(
}
else if (IsDeflateMethod(oneMethodInfo.MethodName))
{
UInt32 fastBytes = _defaultFastBytes;
if (fastBytes == 0xFFFFFFFF)
fastBytes = (level >= 9 ? kDeflateFastBytesX9 :
UInt32 fastBytes =
(level >= 9 ? kDeflateFastBytesX9 :
(level >= 7 ? kDeflateFastBytesX7 :
kDeflateFastBytesX1));
UInt32 numPasses = _defaultPasses;
if (numPasses == 0xFFFFFFFF)
numPasses = (level >= 9 ? kDeflatePassesX9 :
UInt32 numPasses =
(level >= 9 ? kDeflatePassesX9 :
(level >= 7 ? kDeflatePassesX7 :
kDeflatePassesX1));
@@ -373,15 +372,13 @@ HRESULT CHandler::SetCompressionMethod(
}
else if (IsBZip2Method(oneMethodInfo.MethodName))
{
UInt32 numPasses = _defaultPasses;
if (numPasses == 0xFFFFFFFF)
numPasses = (level >= 9 ? kBZip2NumPassesX9 :
UInt32 numPasses =
(level >= 9 ? kBZip2NumPassesX9 :
(level >= 7 ? kBZip2NumPassesX7 :
kBZip2NumPassesX1));
UInt32 dicSize = _defaultDicSize;
if (dicSize == 0xFFFFFFFF)
dicSize = (level >= 5 ? kBZip2DicSizeX5 :
UInt32 dicSize =
(level >= 5 ? kBZip2DicSizeX5 :
(level >= 3 ? kBZip2DicSizeX3 :
kBZip2DicSizeX1));
@@ -393,16 +390,14 @@ HRESULT CHandler::SetCompressionMethod(
}
else if (IsPpmdMethod(oneMethodInfo.MethodName))
{
UInt32 useMemSize = _defaultPpmdMemSize;
if (useMemSize == 0xFFFFFFFF)
useMemSize = (level >= 9 ? kPpmdMemSizeX9 :
UInt32 useMemSize =
(level >= 9 ? kPpmdMemSizeX9 :
(level >= 7 ? kPpmdMemSizeX7 :
(level >= 5 ? kPpmdMemSizeX5 :
kPpmdMemSizeX1)));
UInt32 order = _defaultPpmdOrder;
if (order == 0xFFFFFFFF)
order = (level >= 9 ? kPpmdOrderX9 :
UInt32 order =
(level >= 9 ? kPpmdOrderX9 :
(level >= 7 ? kPpmdOrderX7 :
(level >= 5 ? kPpmdOrderX5 :
kPpmdOrderX1)));
@@ -509,6 +504,30 @@ HRESULT CHandler::SetCompressionMethod(
return E_FAIL;
methodMode.Methods.Add(methodFull);
if (!_numSolidBytesDefined)
{
for (int j = 0; j < methodFull.CoderProperties.Size(); j++)
{
const CProperty &prop = methodFull.CoderProperties[j];
if ((prop.PropID == NCoderPropID::kDictionarySize ||
prop.PropID == NCoderPropID::kUsedMemorySize) && prop.Value.vt == VT_UI4)
{
_numSolidBytes = ((UInt64)prop.Value.ulVal) << 7;
const UInt64 kMinSize = (1 << 24);
if (_numSolidBytes < kMinSize)
_numSolidBytes = kMinSize;
_numSolidBytesDefined = true;
break;
}
}
}
}
if (!needSolid && !_numSolidBytesDefined)
{
_numSolidBytesDefined = true;
_numSolidBytes = 0;
}
return S_OK;
}
@@ -671,28 +690,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
if (updateItem.Size != 0 && updateItem.IsAnti)
return E_INVALIDARG;
}
/*
else
thereIsCopyData = true;
*/
updateItems.Add(updateItem);
}
/*
if (thereIsCopyData)
{
for(int i = 0; i < _database.NumUnPackStreamsVector.Size(); i++)
if (_database.NumUnPackStreamsVector[i] != 1)
return E_NOTIMPL;
if (!_solidIsSpecified)
_solid = false;
if (_solid)
return E_NOTIMPL;
}
*/
CCompressionMethodMode methodMode, headerMethod;
RINOK(SetCompressionMethod(methodMode, headerMethod));
#ifdef COMPRESS_MT
@@ -747,29 +747,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
COM_TRY_END
}
/*
static HRESULT SetComplexProperty(bool &boolStatus, UInt32 &number,
const PROPVARIANT &value)
{
switch(value.vt)
{
case VT_EMPTY:
case VT_BSTR:
{
RINOK(SetBoolProperty(boolStatus, value));
return S_OK;
}
case VT_UI4:
boolStatus = true;
number = (value.ulVal);
break;
default:
return E_INVALIDARG;
}
return S_OK;
}
*/
static HRESULT GetBindInfoPart(UString &srcString, UInt32 &coder, UInt32 &stream)
{
stream = 0;
@@ -988,6 +965,9 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
#endif
UInt32 mainDicSize = 0xFFFFFFFF;
UInt32 mainDicMethodIndex = 0xFFFFFFFF;
UInt32 minNumber = 0;
for (int i = 0; i < numProperties; i++)
@@ -1002,11 +982,8 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
if (name[0] == 'X')
{
name.Delete(0);
_level = 9;
RINOK(ParsePropValue(name, value, _level));
if (_level == 0)
_copyMode = true;
continue;
}
@@ -1109,6 +1086,8 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
property.PropID = NCoderPropID::kDictionarySize;
property.Value = dicSize;
oneMethodInfo.CoderProperties.Add(property);
if (number <= mainDicMethodIndex)
mainDicSize = dicSize;
}
else if (realName.Left(3).CompareNoCase(L"MEM") == 0)
{
@@ -1117,6 +1096,8 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
property.PropID = NCoderPropID::kUsedMemorySize;
property.Value = dicSize;
oneMethodInfo.CoderProperties.Add(property);
if (number <= mainDicMethodIndex)
mainDicSize = dicSize;
}
else
{
@@ -1134,7 +1115,6 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
}
}
}
CheckAndSetSolidBytesLimit();
return S_OK;
COM_TRY_END

View File

@@ -300,7 +300,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
outStreamSpec->InitCRC();
switch(m_Item.CompressionMethod)
switch(item.CompressionMethod)
{
case NFileHeader::NCompressionMethod::kDeflate:
{

View File

@@ -100,7 +100,11 @@ STDMETHODIMP CHandler::Close()
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
*numItems = _archive.Items.Size() + 1;
*numItems = _archive.Items.Size()
#ifdef NSIS_SCRIPT
+ 1
#endif
;
return S_OK;
}
@@ -179,6 +183,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant propVariant;
#ifdef NSIS_SCRIPT
if (index >= (UInt32)_archive.Items.Size())
{
switch(propID)
@@ -199,6 +204,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
}
}
else
#endif
{
const CItem &item = _archive.Items[index];
switch(propID)
@@ -277,9 +283,11 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
for(i = 0; i < numItems; i++)
{
UInt32 index = (allFilesMode ? i : indices[i]);
#ifdef NSIS_SCRIPT
if (index >= (UInt32)_archive.Items.Size())
totalSize += _archive.Script.Length();
else
#endif
{
UInt32 size;
if (_archive.IsSolid)
@@ -321,6 +329,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
#ifdef NSIS_SCRIPT
if (index >= (UInt32)_archive.Items.Size())
{
currentItemSize = _archive.Script.Length();
@@ -331,6 +340,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(realOutStream->Write((const char *)_archive.Script, (UInt32)_archive.Script.Length(), NULL));
}
else
#endif
{
const CItem &item = _archive.Items[index];

View File

@@ -559,14 +559,54 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
e.Which = ReadUInt32();
for (UInt32 j = 0; j < kNumEntryParams; j++)
e.Params[j] = ReadUInt32();
#ifdef NSIS_SCRIPT
if (e.Which != EW_PUSHPOP && e.Which < sizeof(kCommandPairs) / sizeof(kCommandPairs[0]))
{
const CCommandPair &pair = kCommandPairs[e.Which];
Script += pair.Name;
}
#endif
switch (e.Which)
{
case EW_CREATEDIR:
{
prefix.Empty();
prefix = ReadString2(e.Params[0]);
#ifdef NSIS_SCRIPT
Script += " ";
Script += prefix;
#endif
break;
}
case EW_EXTRACTFILE:
{
CItem item;
item.Prefix = prefix;
UInt32 overwriteFlag = e.Params[0];
item.Name = ReadString2(e.Params[1]);
item.Pos = e.Params[2];
item.DateTime.dwLowDateTime = e.Params[3];
item.DateTime.dwHighDateTime = e.Params[4];
UInt32 allowIgnore = e.Params[5];
if (Items.Size() > 0)
{
/*
if (item.Pos == Items.Back().Pos)
continue;
*/
}
Items.Add(item);
#ifdef NSIS_SCRIPT
Script += " ";
Script += item.Name;
#endif
break;
}
#ifdef NSIS_SCRIPT
case EW_UPDATETEXT:
{
Script += " ";
@@ -583,14 +623,6 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
Script += UIntToString(e.Params[1]);
break;
}
case EW_CREATEDIR:
{
prefix.Empty();
Script += " ";
prefix = ReadString2(e.Params[0]);
Script += prefix;
break;
}
case EW_IFFILEEXISTS:
{
Script += " ";
@@ -639,28 +671,6 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
break;
}
case EW_EXTRACTFILE:
{
CItem item;
item.Prefix = prefix;
UInt32 overwriteFlag = e.Params[0];
item.Name = ReadString2(e.Params[1]);
item.Pos = e.Params[2];
item.DateTime.dwLowDateTime = e.Params[3];
item.DateTime.dwHighDateTime = e.Params[4];
UInt32 allowIgnore = e.Params[5];
if (Items.Size() > 0)
{
/*
if (item.Pos == Items.Back().Pos)
continue;
*/
}
Items.Add(item);
Script += " ";
Script += item.Name;
break;
}
case EW_DELETEFILE:
{
UInt64 flag = e.Params[1];
@@ -871,8 +881,11 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
}
Script += e.GetParamsString(numParams);
}
#endif
}
#ifdef NSIS_SCRIPT
Script += kCrLf;
#endif
}
{
@@ -1138,7 +1151,9 @@ HRESULT CInArchive::Open(IInStream *inStream, const UInt64 *maxCheckStartPositio
void CInArchive::Clear()
{
#ifdef NSIS_SCRIPT
Script.Empty();
#endif
Items.Clear();
}

View File

@@ -11,6 +11,8 @@
#include "NsisDecode.h"
// #define NSIS_SCRIPT
namespace NArchive {
namespace NNsis {
@@ -128,7 +130,9 @@ public:
UInt32 DictionarySize;
bool FilterFlag;
#ifdef NSIS_SCRIPT
AString Script;
#endif
UInt32 GetOffset() const { return IsSolid ? 4 : 0; }
UInt64 GetDataPos(int index)
{