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 _compressHeadersFull;
bool _encryptHeaders; bool _encryptHeaders;
bool _copyMode;
UInt32 _defaultDicSize;
UInt32 _defaultAlgorithm;
UInt32 _defaultFastBytes;
UInt32 _defaultPasses;
UString _defaultMatchFinder;
UInt32 _defaultPpmdMemSize;
UInt32 _defaultPpmdOrder;
bool _autoFilter; bool _autoFilter;
UInt32 _level; UInt32 _level;
@@ -221,30 +210,6 @@ private:
_solidExtension = false; _solidExtension = false;
_numSolidBytesDefined = 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() void Init()
{ {
@@ -255,22 +220,11 @@ private:
#ifdef COMPRESS_MT #ifdef COMPRESS_MT
_numThreads = NWindows::NSystem::GetNumberOfProcessors(); _numThreads = NWindows::NSystem::GetNumberOfProcessors();
#endif #endif
_copyMode = false;
_defaultDicSize =
_defaultAlgorithm =
_defaultFastBytes =
_defaultPasses =
_defaultPpmdMemSize =
_defaultPpmdOrder = 0xFFFFFFFF;
_defaultMatchFinder.Empty();
_level = 5; _level = 5;
_autoFilter = true; _autoFilter = true;
_volumeMode = false; _volumeMode = false;
InitSolid(); InitSolid();
SetSolidBytesLimit();
} }
#endif #endif
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -85,11 +85,12 @@ void CState::Free()
} }
#ifdef COMPRESS_BZIP2_MT #ifdef COMPRESS_BZIP2_MT
void CState::FinishStream() void CState::FinishStream(bool needLeave)
{ {
Decoder->StreamWasFinished = true; Decoder->StreamWasFinished = true;
StreamWasFinishedEvent.Set(); StreamWasFinishedEvent.Set();
Decoder->CS.Leave(); if (needLeave)
Decoder->CS.Leave();
Decoder->CanStartWaitingEvent.Lock(); Decoder->CanStartWaitingEvent.Lock();
WaitingWasStartedEvent.Set(); WaitingWasStartedEvent.Set();
} }
@@ -106,10 +107,11 @@ DWORD CState::ThreadFunc()
} }
if (Decoder->StreamWasFinished) if (Decoder->StreamWasFinished)
{ {
FinishStream(); FinishStream(true);
continue; continue;
} }
HRESULT res = S_OK; HRESULT res = S_OK;
bool neadLeave = true;
try try
{ {
UInt32 blockIndex = Decoder->NextBlockIndex; UInt32 blockIndex = Decoder->NextBlockIndex;
@@ -124,13 +126,13 @@ DWORD CState::ThreadFunc()
if (res != S_OK) if (res != S_OK)
{ {
Decoder->Result = res; Decoder->Result = res;
FinishStream(); FinishStream(true);
continue; continue;
} }
if (wasFinished) if (wasFinished)
{ {
Decoder->Result = res; Decoder->Result = res;
FinishStream(); FinishStream(true);
continue; continue;
} }
@@ -139,9 +141,10 @@ DWORD CState::ThreadFunc()
if (res != S_OK) if (res != S_OK)
{ {
Decoder->Result = res; Decoder->Result = res;
FinishStream(); FinishStream(true);
continue; continue;
} }
neadLeave = false;
Decoder->CS.Leave(); Decoder->CS.Leave();
DecodeBlock1(); DecodeBlock1();
@@ -151,7 +154,7 @@ DWORD CState::ThreadFunc()
if (DecodeBlock2(Decoder->m_OutStream) != crc) if (DecodeBlock2(Decoder->m_OutStream) != crc)
{ {
Decoder->Result = S_FALSE; Decoder->Result = S_FALSE;
FinishStream(); FinishStream(neadLeave);
continue; continue;
} }
@@ -169,7 +172,7 @@ DWORD CState::ThreadFunc()
if (res != S_OK) if (res != S_OK)
{ {
Decoder->Result = res; Decoder->Result = res;
FinishStream(); FinishStream(neadLeave);
continue; continue;
} }
} }

View File

@@ -47,7 +47,7 @@ struct CState
Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size. Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
void FinishStream(); void FinishStream(bool needLeave);
DWORD ThreadFunc(); DWORD ThreadFunc();
#endif #endif

View File

@@ -46,11 +46,12 @@ void CThreadInfo::Free()
} }
#ifdef COMPRESS_BZIP2_MT #ifdef COMPRESS_BZIP2_MT
void CThreadInfo::FinishStream() void CThreadInfo::FinishStream(bool needLeave)
{ {
Encoder->StreamWasFinished = true; Encoder->StreamWasFinished = true;
StreamWasFinishedEvent.Set(); StreamWasFinishedEvent.Set();
Encoder->CS.Leave(); if (needLeave)
Encoder->CS.Leave();
Encoder->CanStartWaitingEvent.Lock(); Encoder->CanStartWaitingEvent.Lock();
WaitingWasStartedEvent.Set(); WaitingWasStartedEvent.Set();
} }
@@ -67,10 +68,11 @@ DWORD CThreadInfo::ThreadFunc()
} }
if (Encoder->StreamWasFinished) if (Encoder->StreamWasFinished)
{ {
FinishStream(); FinishStream(true);
continue; continue;
} }
HRESULT res = S_OK; HRESULT res = S_OK;
bool needLeave = true;
try try
{ {
UInt32 blockSize = Encoder->ReadRleBlock(m_Block); UInt32 blockSize = Encoder->ReadRleBlock(m_Block);
@@ -80,10 +82,11 @@ DWORD CThreadInfo::ThreadFunc()
Encoder->NextBlockIndex = 0; Encoder->NextBlockIndex = 0;
if (blockSize == 0) if (blockSize == 0)
{ {
FinishStream(); FinishStream(true);
continue; continue;
} }
Encoder->CS.Leave(); Encoder->CS.Leave();
needLeave = false;
res = EncodeBlock3(blockSize); res = EncodeBlock3(blockSize);
} }
catch(const CInBufferException &e) { res = e.ErrorCode; } catch(const CInBufferException &e) { res = e.ErrorCode; }
@@ -92,7 +95,7 @@ DWORD CThreadInfo::ThreadFunc()
if (res != S_OK) if (res != S_OK)
{ {
Encoder->Result = res; Encoder->Result = res;
FinishStream(); FinishStream(needLeave);
continue; continue;
} }
} }

View File

@@ -106,7 +106,7 @@ private:
int m_BlockIndex; int m_BlockIndex;
void FinishStream(); void FinishStream(bool needLeave);
void WriteBits2(UInt32 value, UInt32 numBits); void WriteBits2(UInt32 value, UInt32 numBits);
void WriteByte2(Byte b); void WriteByte2(Byte b);

View File

@@ -145,6 +145,7 @@ public:
class CDecoder: class CDecoder:
public ICompressCoder, public ICompressCoder,
public ICompressSetDecoderProperties2, public ICompressSetDecoderProperties2,
public ICompressGetInStreamProcessedSize,
#ifdef _ST_MODE #ifdef _ST_MODE
public ICompressSetInStream, public ICompressSetInStream,
public ICompressSetOutStreamSize, public ICompressSetOutStreamSize,
@@ -187,14 +188,16 @@ class CDecoder:
public: public:
#ifdef _ST_MODE #ifdef _ST_MODE
MY_UNKNOWN_IMP4( MY_UNKNOWN_IMP5(
ICompressSetDecoderProperties2, ICompressSetDecoderProperties2,
ICompressGetInStreamProcessedSize,
ICompressSetInStream, ICompressSetInStream,
ICompressSetOutStreamSize, ICompressSetOutStreamSize,
ISequentialInStream) ISequentialInStream)
#else #else
MY_UNKNOWN_IMP1( MY_UNKNOWN_IMP2(
ICompressSetDecoderProperties2) ICompressSetDecoderProperties2,
ICompressGetInStreamProcessedSize)
#endif #endif
void ReleaseStreams() void ReleaseStreams()

View File

@@ -775,6 +775,17 @@ void CPanel::AddToArchive()
// KillSelection(); // KillSelection();
} }
static UString GetSubFolderNameForExtract(const UString &archiveName)
{
int slashPos = archiveName.ReverseFind(L'\\');
int dotPos = archiveName.ReverseFind(L'.');
if (dotPos < 0 || slashPos > dotPos)
return archiveName + UString(L"~");
UString res = archiveName.Left(dotPos);
res.TrimRight();
return res;
}
void CPanel::ExtractArchives() void CPanel::ExtractArchives()
{ {
if (_parentFolders.Size() > 0) if (_parentFolders.Size() > 0)
@@ -800,7 +811,12 @@ void CPanel::ExtractArchives()
} }
paths.Add(_currentFolderPrefix + GetItemRelPath(index)); paths.Add(_currentFolderPrefix + GetItemRelPath(index));
} }
::ExtractArchives(paths, _currentFolderPrefix, true); UString folderName;
if (indices.Size() == 1)
folderName = GetSubFolderNameForExtract(GetItemRelPath(indices[0]));
else
folderName = L"*";
::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(L"\\"), true);
} }
void CPanel::TestArchives() void CPanel::TestArchives()

View File

@@ -115,6 +115,7 @@ Handler GUIDs:
07 7z 07 7z
08 Cab 08 Cab
09 Nsis 09 Nsis
0A Lzma
E7 Iso E7 Iso
E8 Bkf E8 Bkf

View File

@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 4 #define MY_VER_MAJOR 4
#define MY_VER_MINOR 40 #define MY_VER_MINOR 41
#define MY_VER_BUILD 0 #define MY_VER_BUILD 0
#define MY_VERSION "4.40 beta" #define MY_VERSION "4.41 beta"
#define MY_7ZIP_VERSION "7-Zip 4.40 beta" #define MY_7ZIP_VERSION "7-Zip 4.41 beta"
#define MY_DATE "2006-05-01" #define MY_DATE "2006-05-09"
#define MY_COPYRIGHT "Copyright (c) 1999-2006 Igor Pavlov" #define MY_COPYRIGHT "Copyright (c) 1999-2006 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE

View File

@@ -246,14 +246,12 @@ static bool MyInsertMenu(CMenu &menu, int pos, UINT id, const UString &s)
static UString GetSubFolderNameForExtract(const UString &archiveName) static UString GetSubFolderNameForExtract(const UString &archiveName)
{ {
int dotPos = archiveName.ReverseFind('.'); int dotPos = archiveName.ReverseFind(L'.');
if (dotPos >= 0) if (dotPos < 0)
{ return archiveName + UString(L"~");
UString res = archiveName.Left(dotPos); UString res = archiveName.Left(dotPos);
res.TrimRight(); res.TrimRight();
return res; return res;
}
return archiveName + UString(L"~");
} }
static UString GetReducedString(const UString &s) static UString GetReducedString(const UString &s)

View File

@@ -2,7 +2,7 @@
;Defines ;Defines
!define VERSION_MAJOR 4 !define VERSION_MAJOR 4
!define VERSION_MINOR 40 !define VERSION_MINOR 41
!define VERSION_POSTFIX_FULL " beta" !define VERSION_POSTFIX_FULL " beta"
!ifdef WIN64 !ifdef WIN64
!ifdef IA64 !ifdef IA64

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<?define VerMajor = "4" ?> <?define VerMajor = "4" ?>
<?define VerMinor = "40" ?> <?define VerMinor = "41" ?>
<?define VerBuild = "00" ?> <?define VerBuild = "00" ?>
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?> <?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
<?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?> <?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?>
@@ -370,7 +370,7 @@
<ComponentRef Id="InstallRegAppPath" /> <ComponentRef Id="InstallRegAppPath" />
</Feature> </Feature>
<Feature Id="LanguageFiles" Title="Localization files" Description="Localization files for 62 languages." <Feature Id="LanguageFiles" Title="Localization files" Description="Localization files for 63 languages."
Level="1" AllowAdvertise="no"> Level="1" AllowAdvertise="no">
<ComponentRef Id="Lang" /> <ComponentRef Id="Lang" />
</Feature> </Feature>

28
DOC/lzma_format.txt Executable file
View File

@@ -0,0 +1,28 @@
6 Signature 0xFF 'L' 'Z' 'M' 'A' 0x00
1 Flags
0 Has CRC16 of the header
1 Has CRC32 of the data
2 Has filter
3 Need initial dictionary
4-7 Reserved, *must* be zero for now.
1 CompressionMethod
0 No compression
1 Lzma
1 Filter ID
0 none
1 BCJ
2 LZMA properties
1 (uint8_t)((pb * 5 + lp) * 9 + lc) (like in LZMA_Alone)
1 Dictionary size.
eppnnnnn
e: 1 - there is end marker
Dictionary size = (1 << nnnnn) + (pp) << (nnnnn - 2);
2 CRC16 of the header
Compressed data
... ...
(-16) 4 CRC32 of the uncompressed data as big endian uint32_t
-12 8 Uncompressed size as big endian uint64_t
-4 4 Footer magic bytes: 0x0A 'I' 'P' 0x0A
0 (End of file; the last byte of the file is at offset -1.)

View File

@@ -1,4 +1,4 @@
7-Zip 4.40 Sources 7-Zip 4.41 Sources
------------------ ------------------
7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP. 7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP.