This commit is contained in:
Igor Pavlov
2010-09-08 00:00:00 +00:00
committed by Kornel Lesiński
parent e279500d76
commit 044e4bb741
30 changed files with 399 additions and 148 deletions

View File

@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 9
#define MY_VER_MINOR 15
#define MY_VER_MINOR 16
#define MY_VER_BUILD 0
#define MY_VERSION "9.15 beta"
#define MY_DATE "2010-06-20"
#define MY_VERSION "9.16 beta"
#define MY_DATE "2010-09-08"
#define MY_COPYRIGHT ": Igor Pavlov : Public domain"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE

View File

@@ -1,5 +1,5 @@
/* 7zMain.c - Test application for 7z Decoder
2010-03-12 : Igor Pavlov : Public domain */
2010-07-13 : Igor Pavlov : Public domain */
#include <stdio.h>
#include <string.h>
@@ -104,7 +104,7 @@ static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen)
}
#endif
static WRes Utf16_To_Char(CBuf *buf, const UInt16 *s, int fileMode)
static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s, int fileMode)
{
int len = 0;
for (len = 0; s[len] != '\0'; len++);
@@ -172,15 +172,16 @@ static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name)
#endif
}
static void PrintString(const UInt16 *s)
static SRes PrintString(const UInt16 *s)
{
CBuf buf;
SRes res;
Buf_Init(&buf);
if (Utf16_To_Char(&buf, s, 0) == 0)
{
res = Utf16_To_Char(&buf, s, 0);
if (res == SZ_OK)
printf("%s", buf.data);
Buf_Free(&buf, &g_Alloc);
}
return res;
}
static void UInt64ToStr(UInt64 value, char *s)
@@ -398,7 +399,9 @@ int MY_CDECL main(int numargs, char *args[])
}
printf("%s %s %10s ", t, attr, s);
PrintString(temp);
res = PrintString(temp);
if (res != SZ_OK)
break;
if (f->IsDir)
printf("/");
printf("\n");
@@ -407,7 +410,9 @@ int MY_CDECL main(int numargs, char *args[])
printf(testCommand ?
"Testing ":
"Extracting ");
PrintString(temp);
res = PrintString(temp);
if (res != SZ_OK)
break;
if (f->IsDir)
printf("/");
else

View File

@@ -526,7 +526,14 @@ HRESULT CDatabase::ReadDir(Int32 parent, UInt32 cluster, int level)
item.Attrib = attrib;
item.Flags = p[12];
item.Size = Get32(p + 28);
item.Cluster = Get16(p + 26) | ((UInt32)Get16(p + 20) << 16);
item.Cluster = Get16(p + 26);
if (Header.NumFatBits > 16)
item.Cluster |= ((UInt32)Get16(p + 20) << 16);
else
{
// OS/2 and WinNT probably can store EA (extended atributes) in that field.
}
item.CTime = Get32(p + 14);
item.CTime2 = p[13];
item.ADate = Get16(p + 18);

View File

@@ -7,15 +7,14 @@
#include "../../Common/StreamUtils.h"
#include "../../Common/MethodId.h"
#include "../../Common/CreateCoder.h"
#include "../../Compress/BZip2Decoder.h"
#include "../../Compress/DeflateDecoder.h"
#include "../../Compress/LzmaDecoder.h"
namespace NArchive {
namespace NNsis {
static const CMethodId k_Copy = 0x0;
static const CMethodId k_Deflate = 0x040901;
static const CMethodId k_BZip2 = 0x040902;
static const CMethodId k_LZMA = 0x030101;
static const CMethodId k_BCJ_X86 = 0x03030103;
HRESULT CDecoder::Init(
@@ -31,24 +30,14 @@ HRESULT CDecoder::Init(
_method = method;
if (!_codecInStream)
{
CMethodId methodID;
switch (method)
{
case NMethodType::kCopy: methodID = k_Copy; break;
case NMethodType::kDeflate: methodID = k_Deflate; break;
case NMethodType::kBZip2: methodID = k_BZip2; break;
case NMethodType::kLZMA: methodID = k_LZMA; break;
// case NMethodType::kCopy: return E_NOTIMPL;
case NMethodType::kDeflate: _codecInStream = new NCompress::NDeflate::NDecoder::CNsisCOMCoder(); break;
case NMethodType::kBZip2: _codecInStream = new NCompress::NBZip2::CNsisDecoder(); break;
case NMethodType::kLZMA: _codecInStream = new NCompress::NLzma::CDecoder(); break;
default: return E_NOTIMPL;
}
CMyComPtr<ICompressCoder> coder;
RINOK(CreateCoder(
EXTERNAL_CODECS_LOC_VARS
methodID, coder, false));
if (!coder)
return E_NOTIMPL;
coder.QueryInterface(IID_ISequentialInStream, &_codecInStream);
if (!_codecInStream)
return E_NOTIMPL;
}
if (thereIsFilterFlag)

View File

@@ -87,7 +87,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 * maxCheckStartPosit
COM_TRY_BEGIN
Close();
{
if(_archive.Open(
if (_archive.Open(
EXTERNAL_CODECS_VARS
stream, maxCheckStartPosition) != S_OK)
return S_FALSE;
@@ -264,12 +264,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
bool allFilesMode = (numItems == (UInt32)-1);
if (allFilesMode)
GetNumberOfItems(&numItems);
if(numItems == 0)
if (numItems == 0)
return S_OK;
UInt64 totalSize = 0;
UInt32 i;
for(i = 0; i < numItems; i++)
for (i = 0; i < numItems; i++)
{
UInt32 index = (allFilesMode ? i : indices[i]);
#ifdef NSIS_SCRIPT
@@ -313,6 +313,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
byteBuf.SetCapacity(kBufferLength);
Byte *buffer = byteBuf;
CByteBuffer tempBuf;
bool dataError = false;
for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
{
@@ -330,7 +332,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
if (index >= (UInt32)_archive.Items.Size())
{
currentItemSize = _archive.Script.Length();
if(!testMode && !realOutStream)
if (!testMode && !realOutStream)
continue;
RINOK(extractCallback->PrepareOperation(askMode));
if (!testMode)
@@ -346,7 +348,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
else
GetCompressedSize(index, currentItemSize);
if(!testMode && !realOutStream)
if (!testMode && !realOutStream)
continue;
RINOK(extractCallback->PrepareOperation(askMode));
@@ -357,10 +359,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
bool sizeIsKnown = false;
UInt32 fullSize = 0;
bool writeToTemp = false;
bool readFromTemp = false;
if (_archive.IsSolid)
{
UInt64 pos = _archive.GetPosOfSolidItem(index);
while(streamPos < pos)
while (streamPos < pos)
{
size_t processedSize = (UInt32)MyMin(pos - streamPos, (UInt64)kBufferLength);
HRESULT res = _archive.Decoder.Read(buffer, &processedSize);
@@ -389,8 +394,21 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
fullSize = Get32(buffer2);
sizeIsKnown = true;
needDecompress = true;
if (!testMode && i + 1 < numItems)
{
UInt64 nextPos = _archive.GetPosOfSolidItem(allFilesMode ? i : indices[i + 1]);
if (nextPos < streamPos + fullSize)
{
tempBuf.Free();
tempBuf.SetCapacity(fullSize);
writeToTemp = true;
}
}
}
else
readFromTemp = true;
}
else
{
RINOK(_inStream->Seek(_archive.GetPosOfNonSolidItem(index) + 4, STREAM_SEEK_SET, NULL));
@@ -413,7 +431,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
if (needDecompress)
{
UInt64 offset = 0;
while(!sizeIsKnown || fullSize > 0)
while (!sizeIsKnown || fullSize > 0)
{
UInt32 curSize = kBufferLength;
if (sizeIsKnown && curSize > fullSize)
@@ -434,6 +452,9 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
break;
}
if (writeToTemp)
memcpy((Byte *)tempBuf + (size_t)offset, buffer, processedSize);
fullSize -= (UInt32)processedSize;
streamPos += processedSize;
offset += processedSize;
@@ -450,7 +471,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
}
else
{
while(fullSize > 0)
if (readFromTemp)
{
if (!testMode)
RINOK(WriteStream(realOutStream, tempBuf, tempBuf.GetCapacity()));
}
else
while (fullSize > 0)
{
UInt32 curSize = MyMin(fullSize, kBufferLength);
UInt32 processedSize;

View File

@@ -1151,16 +1151,25 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
bool sameName = IsUnicode ?
(Items[i].NameU == Items[i + 1].NameU) :
(Items[i].NameA == Items[i + 1].NameA);
if (Items[i].Pos == Items[i + 1].Pos && (IsSolid || sameName))
if (Items[i].Pos == Items[i + 1].Pos && sameName)
Items.Delete(i + 1);
else
i++;
}
for (i = 0; i + 1 < Items.Size(); i++)
for (i = 0; i < Items.Size(); i++)
{
CItem &item = Items[i];
UInt32 curPos = item.Pos + 4;
for (int nextIndex = i + 1; nextIndex < Items.Size(); nextIndex++)
{
UInt32 nextPos = Items[nextIndex].Pos;
if (curPos <= nextPos)
{
item.EstimatedSizeIsDefined = true;
item.EstimatedSize = Items[i + 1].Pos - item.Pos - 4;
item.EstimatedSize = nextPos - curPos;
break;
}
}
}
if (!IsSolid)
{
@@ -1275,6 +1284,11 @@ static bool IsLZMA(const Byte *p, UInt32 &dictionary, bool &thereIsFlag)
return false;
}
static bool IsBZip2(const Byte *p)
{
return (p[0] == 0x31 && p[1] < 14);
}
HRESULT CInArchive::Open2(
DECL_EXTERNAL_CODECS_LOC_VARS2
)
@@ -1312,8 +1326,15 @@ HRESULT CInArchive::Open2(
else if (sig[3] == 0x80)
{
IsSolid = false;
if (IsBZip2(sig + 4))
Method = NMethodType::kBZip2;
else
Method = NMethodType::kDeflate;
}
else if (IsBZip2(sig))
{
Method = NMethodType::kBZip2;
}
else
{
Method = NMethodType::kDeflate;

View File

@@ -107,8 +107,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
if (prop.vt != VT_UI8)
return E_INVALIDARG;
ui.Size = prop.uhVal.QuadPart;
/*
// now we support GNU extension for big files
if (ui.Size >= ((UInt64)1 << 33))
return E_INVALIDARG;
*/
}
updateItems.Add(ui);
}

View File

@@ -2,6 +2,8 @@
#include "StdAfx.h"
#include "../../../../C/CpuArch.h"
#include "Common/StringToInt.h"
#include "../../Common/StreamUtils.h"
@@ -92,7 +94,16 @@ static HRESULT GetNextItemReal(ISequentialInStream *stream, bool &filled, CItemE
if (!OctalToNumber32(p, 8, item.UID)) item.UID = 0; p += 8;
if (!OctalToNumber32(p, 8, item.GID)) item.GID = 0; p += 8;
RIF(OctalToNumber(p, 12, item.Size)); p += 12;
if (GetBe32(p) == (UInt32)1 << 31)
{
// GNU extension
item.Size = GetBe64(p + 4);
}
else
{
RIF(OctalToNumber(p, 12, item.Size));
}
p += 12;
RIF(OctalToNumber32(p, 12, item.MTime)); p += 12;
UInt32 checkSum;

View File

@@ -53,17 +53,23 @@ static bool MakeOctalString8(char *s, UInt32 value)
return true;
}
static bool MakeOctalString12(char *s, UInt64 value)
static void MakeOctalString12(char *s, UInt64 value)
{
AString tempString = MakeOctalString(value);
const int kMaxSize = 12;
if (tempString.Length() > kMaxSize)
return false;
{
// GNU extension;
s[0] = (char)(Byte)0x80;
s[1] = s[2] = s[3] = 0;
for (int i = 0; i < 8; i++, value <<= 8)
s[4 + i] = (char)(value >> 56);
return;
}
int numSpaces = kMaxSize - tempString.Length();
for(int i = 0; i < numSpaces; i++)
s[i] = ' ';
memmove(s + numSpaces, (const char *)tempString, tempString.Length());
return true;
}
static bool CopyString(char *dest, const AString &src, int maxSize)
@@ -90,17 +96,12 @@ HRESULT COutArchive::WriteHeaderReal(const CItem &item)
MyStrNCpy(cur, item.Name, NFileHeader::kNameSize);
cur += NFileHeader::kNameSize;
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.Mode));
cur += 8;
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.UID));
cur += 8;
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.GID));
cur += 8;
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.Mode)); cur += 8;
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.UID)); cur += 8;
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.GID)); cur += 8;
RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.Size));
cur += 12;
RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.MTime));
cur += 12;
MakeOctalString12(cur, item.Size); cur += 12;
MakeOctalString12(cur, item.MTime); cur += 12;
memmove(cur, NFileHeader::kCheckSumBlanks, 8);
cur += 8;

View File

@@ -258,12 +258,23 @@ void CResource::Parse(const Byte *p)
#define GetResource(p, res) res.Parse(p)
static void GetStream(const Byte *p, CStreamInfo &s)
static void GetStream(bool oldVersion, const Byte *p, CStreamInfo &s)
{
s.Resource.Parse(p);
if (oldVersion)
{
s.PartNumber = 1;
s.RefCount = 1;
// UInt32 id = Get32(p + 24);
// UInt32 unknown = Get32(p + 28);
memcpy(s.Hash, p + 32, kHashSize);
}
else
{
s.PartNumber = Get16(p + 24);
s.RefCount = Get32(p + 26);
memcpy(s.Hash, p + 30, kHashSize);
}
}
static const wchar_t *kLongPath = L"[LongPath]";
@@ -527,9 +538,7 @@ HRESULT CDatabase::ParseImageDirs(const CByteBuffer &buf, int parent)
HRESULT CHeader::Parse(const Byte *p)
{
UInt32 haderSize = Get32(p + 8);
if (haderSize < 0x74)
return S_FALSE;
UInt32 headerSize = Get32(p + 8);
Version = Get32(p + 0x0C);
Flags = Get32(p + 0x10);
if (!IsSupported())
@@ -537,25 +546,42 @@ HRESULT CHeader::Parse(const Byte *p)
ChunkSize = Get32(p + 0x14);
if (ChunkSize != kChunkSize && ChunkSize != 0)
return S_FALSE;
int offset;
if (IsOldVersion())
{
if (headerSize != 0x60)
return S_FALSE;
memset(Guid, 0, 16);
offset = 0x18;
PartNumber = 1;
NumParts = 1;
}
else
{
if (headerSize < 0x74)
return S_FALSE;
memcpy(Guid, p + 0x18, 16);
PartNumber = Get16(p + 0x28);
NumParts = Get16(p + 0x2A);
int offset = 0x2C;
offset = 0x2C;
if (IsNewVersion())
{
NumImages = Get32(p + offset);
offset += 4;
}
}
GetResource(p + offset, OffsetResource);
GetResource(p + offset + 0x18, XmlResource);
GetResource(p + offset + 0x30, MetadataResource);
if (IsNewVersion())
{
if (haderSize < 0xD0)
if (headerSize < 0xD0)
return S_FALSE;
BootIndex = Get32(p + 0x48);
IntegrityResource.Parse(p + offset + 0x4C);
}
if (IsOldVersion())
return S_FALSE;
return S_OK;
}
@@ -570,15 +596,16 @@ HRESULT ReadHeader(IInStream *inStream, CHeader &h)
return h.Parse(p);
}
static HRESULT ReadStreams(IInStream *inStream, const CHeader &h, CDatabase &db)
static HRESULT ReadStreams(bool oldVersion, IInStream *inStream, const CHeader &h, CDatabase &db)
{
CByteBuffer offsetBuf;
RINOK(UnpackData(inStream, h.OffsetResource, h.IsLzxMode(), offsetBuf, NULL));
size_t i;
for (i = 0; offsetBuf.GetCapacity() - i >= kStreamInfoSize; i += kStreamInfoSize)
size_t streamInfoSize = oldVersion ? kStreamInfoSize + 2 : kStreamInfoSize;
for (i = 0; offsetBuf.GetCapacity() - i >= streamInfoSize; i += streamInfoSize)
{
CStreamInfo s;
GetStream((const Byte *)offsetBuf + i, s);
GetStream(oldVersion, (const Byte *)offsetBuf + i, s);
if (s.PartNumber == h.PartNumber)
db.Streams.Add(s);
}
@@ -589,7 +616,7 @@ HRESULT CDatabase::Open(IInStream *inStream, const CHeader &h, CByteBuffer &xml,
{
OpenCallback = openCallback;
RINOK(UnpackData(inStream, h.XmlResource, h.IsLzxMode(), xml, NULL));
RINOK(ReadStreams(inStream, h, *this));
RINOK(ReadStreams(h.IsOldVersion(), inStream, h, *this));
bool needBootMetadata = !h.MetadataResource.IsEmpty();
Order = 0;
if (h.PartNumber == 1)

View File

@@ -155,6 +155,7 @@ struct CHeader
bool IsSupported() const { return (!IsCompressed() || (Flags & NHeaderFlags::kLZX) != 0 || (Flags & NHeaderFlags::kXPRESS) != 0 ) ; }
bool IsLzxMode() const { return (Flags & NHeaderFlags::kLZX) != 0; }
bool IsSpanned() const { return (!IsCompressed() || (Flags & NHeaderFlags::kSpanned) != 0); }
bool IsOldVersion() const { return (Version == 0x010A00); }
bool IsNewVersion()const { return (Version > 0x010C00); }
bool AreFromOnArchive(const CHeader &h)

View File

@@ -78,7 +78,7 @@ namespace NFileHeader
kWzAES = 0x63
};
const int kNumCompressionMethods = 11;
const Byte kMadeByProgramVersion = 20;
const Byte kMadeByProgramVersion = 63;
const Byte kExtractVersion_Default = 10;
const Byte kExtractVersion_Dir = 20;

View File

@@ -358,7 +358,6 @@ COMPRESS_OBJS = \
$O\Deflate64Register.obj \
$O\DeflateDecoder.obj \
$O\DeflateEncoder.obj \
$O\DeflateNsisRegister.obj \
$O\DeflateRegister.obj \
$O\DeltaFilter.obj \
$O\ImplodeDecoder.obj \

View File

@@ -539,10 +539,6 @@ SOURCE=..\..\Compress\DeflateEncoder.h
# End Source File
# Begin Source File
SOURCE=..\..\Compress\DeflateNsisRegister.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Compress\DeflateRegister.cpp
# End Source File
# Begin Source File

View File

@@ -210,7 +210,6 @@ COMPRESS_OBJS = \
$O\Deflate64Register.obj \
$O\DeflateDecoder.obj \
$O\DeflateEncoder.obj \
$O\DeflateNsisRegister.obj \
$O\DeflateRegister.obj \
$O\DeltaFilter.obj \
$O\ImplodeDecoder.obj \

View File

@@ -32,5 +32,5 @@ MY_VERSION_INFO_DLL("7z Standalone Plugin", "7za")
STRINGTABLE
BEGIN
100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 001:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16 dmg:17 hfs:18 xar:19 vhd:20 fat:21 ntfs:22 xz:23"
100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 001:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16 dmg:17 hfs:18 xar:19 vhd:20 fat:21 ntfs:22 xz:23 txz:23"
END

View File

@@ -164,7 +164,7 @@ Byte CByteInBufWrap::ReadByteFromNewBlock()
return 0;
}
extern "C" static Byte Wrap_ReadByte(void *pp)
static Byte Wrap_ReadByte(void *pp)
{
CByteInBufWrap *p = (CByteInBufWrap *)pp;
if (p->Cur != p->Lim)
@@ -210,7 +210,7 @@ HRESULT CByteOutBufWrap::Flush()
return Res;
}
extern "C" static void Wrap_WriteByte(void *pp, Byte b)
static void Wrap_WriteByte(void *pp, Byte b)
{
CByteOutBufWrap *p = (CByteOutBufWrap *)pp;
Byte *dest = p->Cur;

View File

@@ -4,9 +4,6 @@
#include "../../../C/Alloc.h"
#include "../../Common/Defs.h"
#include "BZip2Crc.h"
#include "BZip2Decoder.h"
#include "Mtf8.h"
@@ -15,11 +12,11 @@ namespace NBZip2 {
#define NO_INLINE MY_FAST_CALL
const UInt32 kNumThreadsMax = 4;
static const UInt32 kNumThreadsMax = 4;
static const UInt32 kBufferSize = (1 << 17);
static Int16 kRandNums[512] = {
static const UInt16 kRandNums[512] = {
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
@@ -76,8 +73,8 @@ static Int16 kRandNums[512] = {
bool CState::Alloc()
{
if (Counters == 0)
Counters = (UInt32 *)BigAlloc((256 + kBlockSizeMax) * sizeof(UInt32));
if (!Counters)
Counters = (UInt32 *)::BigAlloc((256 + kBlockSizeMax) * sizeof(UInt32));
return (Counters != 0);
}
@@ -87,7 +84,7 @@ void CState::Free()
Counters = 0;
}
UInt32 CDecoder::ReadBits(int numBits) { return m_InStream.ReadBits(numBits); }
UInt32 CDecoder::ReadBits(unsigned numBits) { return m_InStream.ReadBits(numBits); }
Byte CDecoder::ReadByte() {return (Byte)ReadBits(8); }
bool CDecoder::ReadBit() { return ReadBits(1) != 0; }
@@ -102,12 +99,12 @@ UInt32 CDecoder::ReadCrc()
return crc;
}
UInt32 NO_INLINE ReadBits(NBitm::CDecoder<CInBuffer> *m_InStream, int num)
static UInt32 NO_INLINE ReadBits(NBitm::CDecoder<CInBuffer> *m_InStream, unsigned num)
{
return m_InStream->ReadBits(num);
}
UInt32 NO_INLINE ReadBit(NBitm::CDecoder<CInBuffer> *m_InStream)
static UInt32 NO_INLINE ReadBit(NBitm::CDecoder<CInBuffer> *m_InStream)
{
return m_InStream->ReadBits(1);
}
@@ -116,6 +113,7 @@ static HRESULT NO_INLINE ReadBlock(NBitm::CDecoder<CInBuffer> *m_InStream,
UInt32 *CharCounters, UInt32 blockSizeMax, Byte *m_Selectors, CHuffmanDecoder *m_HuffmanDecoders,
UInt32 *blockSizeRes, UInt32 *origPtrRes, bool *randRes)
{
if (randRes)
*randRes = ReadBit(m_InStream) ? true : false;
*origPtrRes = ReadBits(m_InStream, kNumOrigBits);
@@ -258,7 +256,7 @@ static HRESULT NO_INLINE ReadBlock(NBitm::CDecoder<CInBuffer> *m_InStream,
return (*origPtrRes < blockSize) ? S_OK : S_FALSE;
}
void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize)
static void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize)
{
{
UInt32 sum = 0;
@@ -283,13 +281,13 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
// it's for speed optimization: prefetch & prevByte_init;
UInt32 tPos = tt[tt[OrigPtr] >> 8];
unsigned int prevByte = (unsigned int)(tPos & 0xFF);
unsigned prevByte = (unsigned)(tPos & 0xFF);
int numReps = 0;
unsigned numReps = 0;
do
{
unsigned int b = (unsigned int)(tPos & 0xFF);
unsigned b = (unsigned)(tPos & 0xFF);
tPos = tt[tPos >> 8];
if (numReps == kRleModeRepSize)
@@ -315,7 +313,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
m_OutStream.WriteByte((Byte)b);
for (; --blockSize != 0;)
{
b = (unsigned int)(tPos & 0xFF);
b = (unsigned)(tPos & 0xFF);
tPos = tt[tPos >> 8];
crc.UpdateByte(b);
m_OutStream.WriteByte((Byte)b);
@@ -327,7 +325,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
if (--blockSize == 0)
break;
b = (unsigned int)(tPos & 0xFF);
b = (unsigned)(tPos & 0xFF);
tPos = tt[tPos >> 8];
crc.UpdateByte(b);
m_OutStream.WriteByte((Byte)b);
@@ -339,7 +337,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
if (--blockSize == 0)
break;
b = (unsigned int)(tPos & 0xFF);
b = (unsigned)(tPos & 0xFF);
tPos = tt[tPos >> 8];
crc.UpdateByte(b);
m_OutStream.WriteByte((Byte)b);
@@ -354,7 +352,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
if (blockSize == 0)
break;
b = (unsigned int)(tPos & 0xFF);
b = (unsigned)(tPos & 0xFF);
tPos = tt[tPos >> 8];
for (; b > 0; b--)
@@ -375,15 +373,15 @@ static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UIn
UInt32 randIndex = 1;
UInt32 randToGo = kRandNums[0] - 2;
int numReps = 0;
unsigned numReps = 0;
// it's for speed optimization: prefetch & prevByte_init;
UInt32 tPos = tt[tt[OrigPtr] >> 8];
unsigned int prevByte = (unsigned int)(tPos & 0xFF);
unsigned prevByte = (unsigned)(tPos & 0xFF);
do
{
unsigned int b = (unsigned int)(tPos & 0xFF);
unsigned b = (unsigned)(tPos & 0xFF);
tPos = tt[tPos >> 8];
{
@@ -449,7 +447,7 @@ HRESULT CDecoder::Create()
try
{
m_States = new CState[NumThreads];
if (m_States == 0)
if (!m_States)
return E_OUTOFMEMORY;
}
catch(...) { return E_OUTOFMEMORY; }
@@ -487,6 +485,7 @@ void CDecoder::Free()
delete []m_States;
m_States = 0;
}
#endif
HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
@@ -794,6 +793,7 @@ STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
NumThreads = kNumThreadsMax;
return S_OK;
}
#endif
HRESULT CDecoder::SetRatioProgress(UInt64 packSize)
@@ -805,4 +805,138 @@ HRESULT CDecoder::SetRatioProgress(UInt64 packSize)
return Progress->SetRatioInfo(&packSize, &unpackSize);
}
// ---------- NSIS ----------
enum
{
NSIS_STATE_INIT,
NSIS_STATE_NEW_BLOCK,
NSIS_STATE_DATA,
NSIS_STATE_FINISHED,
NSIS_STATE_ERROR
};
STDMETHODIMP CNsisDecoder::SetInStream(ISequentialInStream *inStream) { m_InStream.SetStream(inStream); return S_OK; }
STDMETHODIMP CNsisDecoder::ReleaseInStream() { m_InStream.ReleaseStream(); return S_OK; }
STDMETHODIMP CNsisDecoder::SetOutStreamSize(const UInt64 * /* outSize */)
{
_nsisState = NSIS_STATE_INIT;
return S_OK;
}
STDMETHODIMP CNsisDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
{
try {
*processedSize = 0;
if (_nsisState == NSIS_STATE_FINISHED)
return S_OK;
if (_nsisState == NSIS_STATE_ERROR)
return S_FALSE;
if (size == 0)
return S_OK;
CState &state = m_State;
if (_nsisState == NSIS_STATE_INIT)
{
if (!m_InStream.Create(kBufferSize))
return E_OUTOFMEMORY;
if (!state.Alloc())
return E_OUTOFMEMORY;
m_InStream.Init();
_nsisState = NSIS_STATE_NEW_BLOCK;
}
if (_nsisState == NSIS_STATE_NEW_BLOCK)
{
Byte b = (Byte)m_InStream.ReadBits(8);
if (b == kFinSig0)
{
_nsisState = NSIS_STATE_FINISHED;
return S_OK;
}
if (b != kBlockSig0)
{
_nsisState = NSIS_STATE_ERROR;
return S_FALSE;
}
UInt32 origPtr;
RINOK(ReadBlock(&m_InStream, state.Counters, 9 * kBlockSizeStep,
m_Selectors, m_HuffmanDecoders, &_blockSize, &origPtr, NULL));
DecodeBlock1(state.Counters, _blockSize);
const UInt32 *tt = state.Counters + 256;
_tPos = tt[tt[origPtr] >> 8];
_prevByte = (unsigned)(_tPos & 0xFF);
_numReps = 0;
_repRem = 0;
_nsisState = NSIS_STATE_DATA;
}
UInt32 tPos = _tPos;
unsigned prevByte = _prevByte;
unsigned numReps = _numReps;
UInt32 blockSize = _blockSize;
const UInt32 *tt = state.Counters + 256;
while (_repRem)
{
_repRem--;
*(Byte *)data = (Byte)prevByte;
data = (Byte *)data + 1;
(*processedSize)++;
if (--size == 0)
return S_OK;
}
if (blockSize == 0)
{
_nsisState = NSIS_STATE_NEW_BLOCK;
return S_OK;
}
do
{
unsigned b = (unsigned)(tPos & 0xFF);
tPos = tt[tPos >> 8];
blockSize--;
if (numReps == kRleModeRepSize)
{
numReps = 0;
while (b)
{
b--;
*(Byte *)data = (Byte)prevByte;
data = (Byte *)data + 1;
(*processedSize)++;
if (--size == 0)
break;
}
_repRem = b;
continue;
}
if (b != prevByte)
numReps = 0;
numReps++;
prevByte = b;
*(Byte *)data = (Byte)b;
data = (Byte *)data + 1;
(*processedSize)++;
size--;
}
while (size && blockSize);
_tPos = tPos;
_prevByte = prevByte;
_numReps = numReps;
_blockSize = blockSize;
return S_OK;
}
catch(const CInBufferException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
}
}}

View File

@@ -76,11 +76,10 @@ private:
bool _needInStreamInit;
UInt32 ReadBits(int numBits);
UInt32 ReadBits(unsigned numBits);
Byte ReadByte();
bool ReadBit();
UInt32 ReadCrc();
HRESULT PrepareBlock(CState &state);
HRESULT DecodeFile(bool &isBZ, ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
bool &isBZ, ICompressProgressInfo *progress);
@@ -168,6 +167,39 @@ public:
#endif
};
class CNsisDecoder :
public ISequentialInStream,
public ICompressSetInStream,
public ICompressSetOutStreamSize,
public CMyUnknownImp
{
NBitm::CDecoder<CInBuffer> m_InStream;
Byte m_Selectors[kNumSelectorsMax];
CHuffmanDecoder m_HuffmanDecoders[kNumTablesMax];
CState m_State;
int _nsisState;
UInt32 _tPos;
unsigned _prevByte;
unsigned _repRem;
unsigned _numReps;
UInt32 _blockSize;
public:
MY_QUERYINTERFACE_BEGIN2(ISequentialInStream)
MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize)
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
STDMETHOD(ReleaseInStream)();
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
};
}}
#endif

View File

@@ -1,14 +0,0 @@
// DeflateNsisRegister.cpp
#include "StdAfx.h"
#include "../Common/RegisterCodec.h"
#include "DeflateDecoder.h"
static void *CreateCodecDeflateNsis() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CNsisCOMCoder); }
static CCodecInfo g_CodecInfo =
{ CreateCodecDeflateNsis, 0, 0x040901, L"DeflateNSIS", 1, false };
REGISTER_CODEC(DeflateNsis)

View File

@@ -627,7 +627,6 @@ public:
CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
~CCoderReleaser()
{
// m_Coder->m_OutWindowStream.Flush();
m_Coder->ReleaseStreams();
}
};
@@ -821,7 +820,7 @@ HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress)
return S_OK;
}
for(;;)
for (;;)
{
bool keepDecompressing;
if (_lzMode)
@@ -838,9 +837,10 @@ HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress)
break;
}
RINOK(WriteBuf());
UInt64 packSize = m_InBitStream.bitDecoder.GetProcessedSize();
RINOK(progress->SetRatioInfo(&packSize, &_writtenFileSize));
if (_writtenFileSize < _unpackSize)
return S_FALSE;
// return m_OutWindowStream.Flush();
return S_OK;
}

View File

@@ -114,6 +114,12 @@ HRESULT CDecoder::CheckPassword(bool &passwOK)
_key.KeySize = 16 + algId * 8;
if ((flags & 1) == 0)
return E_NOTIMPL;
if ((flags & 0x4000) != 0)
{
// Use 3DES
return E_NOTIMPL;
}
UInt32 rdSize = GetUi16(p + 8);
if ((rdSize & 0xF) != 0 || rdSize + 16 > _remSize)
return E_NOTIMPL;

View File

@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 9
#define MY_VER_MINOR 15
#define MY_VER_MINOR 16
#define MY_VER_BUILD 0
#define MY_VERSION "9.15 beta"
#define MY_7ZIP_VERSION "7-Zip 9.15 beta"
#define MY_DATE "2010-06-20"
#define MY_VERSION "9.16"
#define MY_7ZIP_VERSION "7-Zip 9.16 beta"
#define MY_DATE "2010-09-08"
#define MY_COPYRIGHT "Copyright (c) 1999-2010 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE

View File

@@ -169,7 +169,7 @@ static const char *kStartExtensions =
#endif
" exe bat com"
" chm"
" msi doc xls ppt pps wps wpt wks xlr wdb"
" msi doc xls ppt pps wps wpt wks xlr wdb vsd"
" docx docm dotx dotm xlsx xlsm xltx xltm xlsb"
" xlam pptx pptm potx potm ppam ppsx ppsm xsn"

View File

@@ -62,7 +62,6 @@ fm\index.htm
fm\menu.htm
fm\about.htm
fm\plugins\index.htm
fm\plugins\7-zip\options.htm
fm\plugins\7-zip\extract.htm
fm\plugins\7-zip\index.htm
fm\plugins\7-zip\add.htm

View File

@@ -10,8 +10,8 @@ AppName = "7-Zip"
InstallDir = %CE1%\%AppName%
[Strings]
AppVer = "9.15"
AppDate = "2010-06-20"
AppVer = "9.16"
AppDate = "2010-09-07"
[CEDevice]
; ProcessorType = 2577 ; ARM

View File

@@ -2,7 +2,7 @@
;Defines
!define VERSION_MAJOR 9
!define VERSION_MINOR 15
!define VERSION_MINOR 16
!define VERSION_POSTFIX_FULL " beta"
!ifdef WIN64
!ifdef IA64
@@ -206,7 +206,9 @@ Section
File fur.txt
File fy.txt
File gl.txt
File gu.txt
File he.txt
File hi.txt
File hr.txt
File hu.txt
File hy.txt
@@ -237,6 +239,7 @@ Section
File pt-br.txt
File ro.txt
File ru.txt
File sa.txt
File si.txt
File sk.txt
File sl.txt
@@ -397,7 +400,9 @@ Section "Uninstall"
Delete $INSTDIR\Lang\fur.txt
Delete $INSTDIR\Lang\fy.txt
Delete $INSTDIR\Lang\gl.txt
Delete $INSTDIR\Lang\gu.txt
Delete $INSTDIR\Lang\he.txt
Delete $INSTDIR\Lang\hi.txt
Delete $INSTDIR\Lang\hr.txt
Delete $INSTDIR\Lang\hu.txt
Delete $INSTDIR\Lang\hy.txt
@@ -428,6 +433,7 @@ Section "Uninstall"
Delete $INSTDIR\Lang\pt-br.txt
Delete $INSTDIR\Lang\ro.txt
Delete $INSTDIR\Lang\ru.txt
Delete $INSTDIR\Lang\sa.txt
Delete $INSTDIR\Lang\si.txt
Delete $INSTDIR\Lang\sk.txt
Delete $INSTDIR\Lang\sl.txt

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?define VerMajor = "9" ?>
<?define VerMinor = "15" ?>
<?define VerMinor = "16" ?>
<?define VerBuild = "00" ?>
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
<?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?>
@@ -248,7 +248,9 @@
<File Id="fur.txt" Name="fur.txt" />
<File Id="fy.txt" Name="fy.txt" />
<File Id="gl.txt" Name="gl.txt" />
<File Id="gu.txt" Name="gu.txt" />
<File Id="he.txt" Name="he.txt" />
<File Id="hi.txt" Name="hi.txt" />
<File Id="hr.txt" Name="hr.txt" />
<File Id="hu.txt" Name="hu.txt" />
<File Id="hy.txt" Name="hy.txt" />
@@ -279,6 +281,7 @@
<File Id="pt_br.txt" Name="pt-br.txt" />
<File Id="ro.txt" Name="ro.txt" />
<File Id="ru.txt" Name="ru.txt" />
<File Id="sa.txt" Name="sa.txt" />
<File Id="si.txt" Name="si.txt" />
<File Id="sk.txt" Name="sk.txt" />
<File Id="sl.txt" Name="sl.txt" />

View File

@@ -1,4 +1,4 @@
LZMA SDK 9.15
LZMA SDK 9.16
-------------
LZMA SDK provides the documentation, samples, header files, libraries,
@@ -37,7 +37,7 @@ LZMA SDK includes:
UNIX/Linux version
------------------
To compile C++ version of file->file LZMA encoding, go to directory
C++/7zip/Compress/LZMA_Alone
CPP/7zip/Bundles/LzmaCon
and call make to recompile it:
make -f makefile.gcc clean all
@@ -91,8 +91,6 @@ CPP/ -- CPP files
Compress - files related to compression/decompression
LZMA_Alone - file->file LZMA compression/decompression
Archive - files related to archiving
Common - common files for archive handling
@@ -101,6 +99,7 @@ CPP/ -- CPP files
Bundles - Modules that are bundles of other modules
Alone7z - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2
LzmaCon - lzma.exe: LZMA compression/decompression
Format7zR - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2
Format7zExtractR - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2.

View File

@@ -1,4 +1,4 @@
7-Zip 9.15 Sources
7-Zip 9.16 Sources
------------------
7-Zip is a file archiver for Windows.