Compare commits

...

2 Commits
9.14 ... 9.16

Author SHA1 Message Date
Igor Pavlov
044e4bb741 9.16 2016-05-28 00:16:03 +01:00
Igor Pavlov
e279500d76 9.15 2016-05-28 00:16:03 +01:00
44 changed files with 515 additions and 258 deletions

View File

@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 9
#define MY_VER_MINOR 14
#define MY_VER_MINOR 16
#define MY_VER_BUILD 0
#define MY_VERSION "9.14 beta"
#define MY_DATE "2010-06-04"
#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,9 +1,9 @@
/* Crypto/Sha256.c -- SHA-256 Hash function
2008-11-06 : Igor Pavlov : Public domain
/* Crypto/Sha256.c -- SHA-256 Hash
2010-06-11 : Igor Pavlov : Public domain
This code is based on public domain code from Wei Dai's Crypto++ library. */
#include "Sha256.h"
#include "RotateDefs.h"
#include "Sha256.h"
/* define it for speed optimization */
/* #define _SHA256_UNROLL */
@@ -71,7 +71,7 @@ void Sha256_Init(CSha256 *p)
#endif
const UInt32 K[64] = {
static const UInt32 K[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,

View File

@@ -1,14 +1,12 @@
/* Sha256.h -- SHA-256 Hash
2009-02-07 : Igor Pavlov : Public domain */
2010-06-11 : Igor Pavlov : Public domain */
#ifndef __CRYPTO_SHA256_H
#define __CRYPTO_SHA256_H
#include "Types.h"
#ifdef __cplusplus
extern "C" {
#endif
EXTERN_C_BEGIN
#define SHA256_DIGEST_SIZE 32
@@ -23,8 +21,6 @@ void Sha256_Init(CSha256 *p);
void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
void Sha256_Final(CSha256 *p, Byte *digest);
#ifdef __cplusplus
}
#endif
EXTERN_C_END
#endif

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

@@ -2,15 +2,14 @@
#include "StdAfx.h"
#include "7zHandler.h"
#include "7zFolderOutStream.h"
#include "../../../Common/ComTry.h"
#include "../../Common/ProgressUtils.h"
#include "7zDecode.h"
// #include "7z1Decode.h"
#include "../../../Common/ComTry.h"
#include "../../Common/StreamObjects.h"
#include "../../Common/ProgressUtils.h"
#include "../../Common/LimitedStreams.h"
#include "7zFolderOutStream.h"
#include "7zHandler.h"
namespace NArchive {
namespace N7z {
@@ -73,13 +72,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
*/
CObjectVector<CExtractFolderInfo> extractFolderInfoVector;
for(UInt32 ii = 0; ii < numItems; ii++)
for (UInt32 ii = 0; ii < numItems; ii++)
{
// UInt32 fileIndex = allFilesMode ? indexIndex : indices[indexIndex];
UInt32 ref2Index = allFilesMode ? ii : indices[ii];
// const CRef2 &ref2 = _refs[ref2Index];
// for(UInt32 ri = 0; ri < ref2.Refs.Size(); ri++)
// for (UInt32 ri = 0; ri < ref2.Refs.Size(); ri++)
{
#ifdef _7Z_VOL
// const CRef &ref = ref2.Refs[ri];
@@ -149,27 +148,26 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
);
// CDecoder1 decoder;
UInt64 currentTotalPacked = 0;
UInt64 currentTotalUnpacked = 0;
UInt64 totalFolderUnpacked;
UInt64 totalFolderPacked;
UInt64 totalPacked = 0;
UInt64 totalUnpacked = 0;
UInt64 curPacked, curUnpacked;
CLocalProgress *lps = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> progress = lps;
lps->Init(extractCallback, false);
for(int i = 0; i < extractFolderInfoVector.Size(); i++,
currentTotalUnpacked += totalFolderUnpacked,
currentTotalPacked += totalFolderPacked)
for (int i = 0;; i++, totalUnpacked += curUnpacked, totalPacked += curPacked)
{
lps->OutSize = currentTotalUnpacked;
lps->InSize = currentTotalPacked;
lps->OutSize = totalUnpacked;
lps->InSize = totalPacked;
RINOK(lps->SetCur());
const CExtractFolderInfo &efi = extractFolderInfoVector[i];
totalFolderUnpacked = efi.UnpackSize;
if (i >= extractFolderInfoVector.Size())
break;
totalFolderPacked = 0;
const CExtractFolderInfo &efi = extractFolderInfoVector[i];
curUnpacked = efi.UnpackSize;
curPacked = 0;
CFolderOutStream *folderOutStream = new CFolderOutStream;
CMyComPtr<ISequentialOutStream> outStream(folderOutStream);
@@ -187,7 +185,6 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
else
startIndex = db.FolderStartFileIndex[efi.FolderIndex];
HRESULT result = folderOutStream->Init(&db,
#ifdef _7Z_VOL
volume.StartRef2Index,
@@ -205,7 +202,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
CNum folderIndex = efi.FolderIndex;
const CFolder &folderInfo = db.Folders[folderIndex];
totalFolderPacked = _db.GetFolderFullPackSize(folderIndex);
curPacked = _db.GetFolderFullPackSize(folderIndex);
CNum packStreamIndex = db.FolderStartPackStreamIndex[folderIndex];
UInt64 folderStartPackPos = db.GetFolderStreamPos(folderIndex, 0);

View File

@@ -85,6 +85,7 @@ STDAPI CreateArchiver(const GUID *clsid, const GUID *iid, void **outObject)
STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
if (formatIndex >= g_NumArcs)
return E_INVALIDARG;
const CArcInfo &arc = *g_Arcs[formatIndex];
@@ -119,6 +120,7 @@ STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value
}
prop.Detach(value);
return S_OK;
COM_TRY_END
}
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)

View File

@@ -41,7 +41,7 @@ enum
};
#endif
STATPROPSTG kProps[] =
static STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
{ NULL, kpidSize, VT_UI8},
@@ -57,18 +57,18 @@ STATPROPSTG kProps[] =
#endif
};
static const wchar_t *kMethods[] =
static const char *kMethods[] =
{
L"None",
L"MSZip",
L"Quantum",
L"LZX"
"None",
"MSZip",
"Quantum",
"LZX"
};
static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
static const wchar_t *kUnknownMethod = L"Unknown";
static const char *kUnknownMethod = "Unknown";
STATPROPSTG kArcProps[] =
static STATPROPSTG kArcProps[] =
{
{ NULL, kpidMethod, VT_BSTR},
// { NULL, kpidSolid, VT_BOOL},
@@ -87,7 +87,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
case kpidMethod:
{
UString resString;
AString resString;
CRecordVector<Byte> ids;
int i;
for (int v = 0; v < m_Database.Volumes.Size(); v++)
@@ -99,9 +99,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
for (i = 0; i < ids.Size(); i++)
{
Byte id = ids[i];
UString method = (id < kNumMethods) ? kMethods[id] : kUnknownMethod;
AString method = (id < kNumMethods) ? kMethods[id] : kUnknownMethod;
if (!resString.IsEmpty())
resString += L' ';
resString += ' ';
resString += method;
}
prop = resString;
@@ -171,12 +171,12 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
UInt32 realFolderIndex = item.GetFolderIndex(db.Folders.Size());
const CFolder &folder = db.Folders[realFolderIndex];
int methodIndex = folder.GetCompressionMethod();
UString method = (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
AString method = (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
if (methodIndex == NHeader::NCompressionMethodMajor::kLZX ||
methodIndex == NHeader::NCompressionMethodMajor::kQuantum)
{
method += L":";
wchar_t temp[32];
method += ':';
char temp[32];
ConvertUInt64ToString(folder.CompressionTypeMinor, temp);
method += temp;
}

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);
@@ -578,8 +585,12 @@ HRESULT CDatabase::Open()
return S_FALSE;
UInt64 fileSize;
RINOK(InStream->Seek(0, STREAM_SEEK_END, &fileSize));
/* we comment that check to support truncated images */
/*
if (fileSize < Header.GetPhySize())
return S_FALSE;
*/
if (Header.IsFat32())
{

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

@@ -391,7 +391,6 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
{
COM_TRY_BEGIN
Close();
try
{
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
@@ -488,10 +487,6 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
_xmlInComments = (_xmls.Size() == 1 && !_db.ShowImageNumber);
}
catch(...)
{
return S_FALSE;
}
return S_OK;
COM_TRY_END
}

View File

@@ -258,7 +258,7 @@ static size_t WriteItem(const CUpdateItem &item, Byte *p, const Byte *hash)
return totalLen;
}
void WriteTree(const CDir &tree, CRecordVector<CSha1Hash> &digests,
static void WriteTree(const CDir &tree, CRecordVector<CSha1Hash> &digests,
CUpdateItem &defaultDirItem,
CObjectVector<CUpdateItem> &updateItems, Byte *dest, size_t &pos)
{
@@ -488,11 +488,15 @@ static HRESULT UpdateArchive(ISequentialOutStream *seqOutStream,
const UInt32 kSecuritySize = 8;
size_t pos = kSecuritySize;
WriteTree(rootFolder, hashes.Digests, ri, updateItems, NULL, pos);
CByteBuffer meta;
meta.SetCapacity(pos);
// memset(meta, 0, kSecuritySize);
Set32((Byte *)meta, 0); // only if there is no security data, we can use 0 here.
// we can write 0 here only if there is no security data, imageX does it,
// but some programs expect size = 8
Set32((Byte *)meta, 8); // size of security data
Set32((Byte *)meta + 4, 0); // num security entries
pos = kSecuritySize;
WriteTree(rootFolder, hashes.Digests, ri, updateItems, (Byte *)meta, pos);

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]";
@@ -384,7 +395,12 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent)
return S_FALSE;
UInt32 fileNameLen = Get16(p + 0x24);
if ((fileNameLen & 1) != 0 || ((0x26 + fileNameLen + 6) & ~7) != len)
if ((fileNameLen & 1) != 0)
return S_FALSE;
/* Probably different versions of ImageX can use different number of
additional ZEROs. So we don't use exact check. */
UInt32 fileNameLen2 = (fileNameLen == 0 ? fileNameLen : fileNameLen + 2);
if (((0x26 + fileNameLen2 + 6) & ~7) > len)
return S_FALSE;
UString name;
@@ -522,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())
@@ -532,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;
}
@@ -565,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);
}
@@ -584,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

@@ -1,3 +1,3 @@
#include "../../MyVersionInfo.rc"
MY_VERSION_INFO_APP("7-Zip Standalone Console", "7za")
MY_VERSION_INFO_APP("7-Zip Standalone Console", "7zr")

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 14
#define MY_VER_MINOR 16
#define MY_VER_BUILD 0
#define MY_VERSION "9.14 beta"
#define MY_7ZIP_VERSION "7-Zip 9.14 beta"
#define MY_DATE "2010-06-04"
#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

@@ -514,11 +514,9 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
if (archive->GetArchivePropertyInfo(j, &name, &propID, &vt) != S_OK)
continue;
RINOK(archive->GetArchivePropertyInfo(j, &name, &propID, &vt));
NCOM::CPropVariant prop;
if (archive->GetArchiveProperty(propID, &prop) != S_OK)
continue;
RINOK(archive->GetArchiveProperty(propID, &prop));
UString s = ConvertPropertyToString(prop, propID);
if (!s.IsEmpty())
PrintPropPair(GetPropName(propID, name), s);
@@ -536,11 +534,9 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
if (archive->GetPropertyInfo(j, &name, &propID, &vt) != S_OK)
continue;
RINOK(archive->GetPropertyInfo(j, &name, &propID, &vt));
NCOM::CPropVariant prop;
if (archive->GetProperty(mainIndex, propID, &prop) != S_OK)
continue;
RINOK(archive->GetProperty(mainIndex, propID, &prop));
UString s = ConvertPropertyToString(prop, propID);
if (!s.IsEmpty())
PrintPropPair(GetPropName(propID, name), s);

View File

@@ -21,6 +21,6 @@ CAPTION "About 7-Zip"
ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE
LTEXT MY_7ZIP_VERSION, -1, m, 54, xc, 8
LTEXT MY_COPYRIGHT, -1, m, 67, xc, 8
LTEXT "7-Zip is free software. However, you can support development of 7-Zip by registering.",
LTEXT "7-Zip is free software",
IDC_ABOUT_STATIC_REGISTER_INFO, m, y, xc, (by - y - 1)
}

View File

@@ -236,12 +236,12 @@ private:
void ChangeWindowSize(int xSize, int ySize);
void InitColumns();
HRESULT InitColumns();
// void InitColumns2(PROPID sortID);
void InsertColumn(int index);
void SetFocusedSelectedItem(int index, bool select);
void RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
HRESULT RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames);
void OnShiftSelectMessage();
@@ -335,8 +335,8 @@ public:
void GetSelectedNames(UStringVector &selectedNames);
void SaveSelectedState(CSelectedState &s);
void RefreshListCtrl(const CSelectedState &s);
void RefreshListCtrlSaveFocused();
HRESULT RefreshListCtrl(const CSelectedState &s);
HRESULT RefreshListCtrlSaveFocused();
UString GetItemName(int itemIndex) const;
UString GetItemPrefix(int itemIndex) const;
@@ -517,7 +517,7 @@ public:
// bool _passwordIsDefined;
// UString _password;
void RefreshListCtrl();
HRESULT RefreshListCtrl();
void MessageBoxInfo(LPCWSTR message, LPCWSTR caption);
void MessageBox(LPCWSTR message);

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

@@ -55,7 +55,7 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType)
}
}
void CPanel::InitColumns()
HRESULT CPanel::InitColumns()
{
if (_needSaveInfo)
SaveListViewInfo();
@@ -88,8 +88,7 @@ void CPanel::InitColumns()
PROPID propID;
VARTYPE varType;
if (_folder->GetPropertyInfo(i, &name, &propID, &varType) != S_OK)
throw 1;
RINOK(_folder->GetPropertyInfo(i, &name, &propID, &varType));
if (propID == kpidIsDir)
continue;
@@ -110,7 +109,7 @@ void CPanel::InitColumns()
break;
int order = 0;
for(i = 0; i < _listViewInfo.Columns.Size(); i++)
for (i = 0; i < _listViewInfo.Columns.Size(); i++)
{
const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
int index = _properties.FindItemWithID(columnInfo.PropID);
@@ -124,7 +123,7 @@ void CPanel::InitColumns()
continue;
}
}
for(i = 0; i < _properties.Size(); i++)
for (i = 0; i < _properties.Size(); i++)
{
CItemProperty &item = _properties[i];
if (item.Order < 0)
@@ -155,6 +154,7 @@ void CPanel::InitColumns()
{
InsertColumn(i);
}
return S_OK;
}
void CPanel::InsertColumn(int index)
@@ -170,9 +170,9 @@ void CPanel::InsertColumn(int index)
_listView.InsertColumn(index, &column);
}
void CPanel::RefreshListCtrl()
HRESULT CPanel::RefreshListCtrl()
{
RefreshListCtrl(UString(), -1, true, UStringVector());
return RefreshListCtrl(UString(), -1, true, UStringVector());
}
int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
@@ -239,19 +239,19 @@ void CPanel::SaveSelectedState(CSelectedState &s)
GetSelectedNames(s.SelectedNames);
}
void CPanel::RefreshListCtrl(const CSelectedState &s)
HRESULT CPanel::RefreshListCtrl(const CSelectedState &s)
{
bool selectFocused = s.SelectFocused;
if (_mySelectMode)
selectFocused = true;
RefreshListCtrl(s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
return RefreshListCtrl(s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
}
void CPanel::RefreshListCtrlSaveFocused()
HRESULT CPanel::RefreshListCtrlSaveFocused()
{
CSelectedState state;
SaveSelectedState(state);
RefreshListCtrl(state);
return RefreshListCtrl(state);
}
void CPanel::SetFocusedSelectedItem(int index, bool select)
@@ -268,7 +268,7 @@ void CPanel::SetFocusedSelectedItem(int index, bool select)
}
}
void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames)
{
_dontShowMode = false;
@@ -309,11 +309,8 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
if (folderSetFlatMode)
folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
if (_folder->LoadItems() != S_OK)
return;
InitColumns();
RINOK(_folder->LoadItems());
RINOK(InitColumns());
// OutputDebugString(TEXT("Start Dir\n"));
UInt32 numItems;
@@ -345,13 +342,13 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
item.iImage = _extToIconMap.GetIconIndex(attrib, itemName);
if (item.iImage < 0)
item.iImage = 0;
if(_listView.InsertItem(&item) == -1)
return;
if (_listView.InsertItem(&item) == -1)
return E_FAIL;
}
// OutputDebugStringA("S1\n");
for(UInt32 i = 0; i < numItems; i++)
for (UInt32 i = 0; i < numItems; i++)
{
UString itemName = GetItemName(i);
const UString relPath = GetItemRelPath(i);
@@ -400,7 +397,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
item.pszText = (wchar_t *)(const wchar_t *)itemName;
NCOM::CPropVariant prop;
_folder->GetProperty(i, kpidAttrib, &prop);
RINOK(_folder->GetProperty(i, kpidAttrib, &prop));
UInt32 attrib = 0;
if (prop.vt == VT_UI4)
attrib = prop.ulVal;
@@ -430,12 +427,12 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
if (item.iImage < 0)
item.iImage = 0;
if(_listView.InsertItem(&item) == -1)
return; // error
if (_listView.InsertItem(&item) == -1)
return E_FAIL; // error
}
// OutputDebugStringA("End2\n");
if(_listView.GetItemCount() > 0 && cursorIndex >= 0)
if (_listView.GetItemCount() > 0 && cursorIndex >= 0)
SetFocusedSelectedItem(cursorIndex, selectFocused);
_listView.SortItems(CompareItems, (LPARAM)this);
if (cursorIndex < 0 && _listView.GetItemCount() > 0)
@@ -452,6 +449,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
/*
_listView.UpdateWindow();
*/
return S_OK;
}
void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
@@ -482,7 +480,7 @@ void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
int focusedItem = _listView.GetFocusedItem();
if (focusedItem >= 0)
{
if(_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
if (_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
{
int realIndex = GetRealItemIndex(focusedItem);
if (realIndex != kParentIndex)
@@ -572,7 +570,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
}
bool dirIsStarted = false;
for(int i = 0; i < indices.Size(); i++)
for (int i = 0; i < indices.Size(); i++)
{
UInt32 index = indices[i];
// CFileInfo &aFile = m_Files[index];
@@ -666,7 +664,7 @@ void CPanel::ReadListViewInfo()
void CPanel::SaveListViewInfo()
{
int i;
for(i = 0; i < _visibleProperties.Size(); i++)
for (i = 0; i < _visibleProperties.Size(); i++)
{
CItemProperty &prop = _visibleProperties[i];
LVCOLUMN winColumnInfo;
@@ -683,7 +681,7 @@ void CPanel::SaveListViewInfo()
PROPID sortPropID = _sortID;
_visibleProperties.Sort();
for(i = 0; i < _visibleProperties.Size(); i++)
for (i = 0; i < _visibleProperties.Size(); i++)
{
const CItemProperty &prop = _visibleProperties[i];
CColumnInfo columnInfo;
@@ -692,7 +690,7 @@ void CPanel::SaveListViewInfo()
columnInfo.Width = prop.Width;
viewInfo.Columns.Add(columnInfo);
}
for(i = 0; i < _properties.Size(); i++)
for (i = 0; i < _properties.Size(); i++)
{
const CItemProperty &prop = _properties[i];
if (!prop.IsVisible)
@@ -719,7 +717,7 @@ void CPanel::SaveListViewInfo()
bool CPanel::OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActiveate, LRESULT &result)
{
if(itemActiveate->hdr.hwndFrom == HWND(_listView))
if (itemActiveate->hdr.hwndFrom == HWND(_listView))
return false;
POINT point;
::GetCursorPos(&point);
@@ -737,7 +735,7 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
menu.CreatePopup();
const int kCommandStart = 100;
for(int i = 0; i < _properties.Size(); i++)
for (int i = 0; i < _properties.Size(); i++)
{
const CItemProperty &prop = _properties[i];
UINT flags = MF_STRING;
@@ -785,7 +783,9 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
void CPanel::OnReload()
{
RefreshListCtrlSaveFocused();
HRESULT res = RefreshListCtrlSaveFocused();
if (res != S_OK)
MessageBoxError(res);
OnRefreshStatusBar();
}

View File

@@ -149,9 +149,10 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
if (needRead)
*/
if (_folder->GetProperty(realIndex, propID, &prop) != S_OK)
throw 2723407;
HRESULT res = _folder->GetProperty(realIndex, propID, &prop);
if (res != S_OK)
s = UString(L"Error: ") + HResultToMessage(res);
else
if ((prop.vt == VT_UI8 || prop.vt == VT_UI4) && (
propID == kpidSize ||
propID == kpidPackSize ||

View File

@@ -50,6 +50,8 @@ CPropVariant& CPropVariant::operator=(BSTR bstrSrc)
return *this;
}
static const char *kMemException = "out of memory";
CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc)
{
InternalClear();
@@ -58,8 +60,9 @@ CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc)
bstrVal = ::SysAllocString(lpszSrc);
if (bstrVal == NULL && lpszSrc != NULL)
{
vt = VT_ERROR;
scode = E_OUTOFMEMORY;
throw kMemException;
// vt = VT_ERROR;
// scode = E_OUTOFMEMORY;
}
return *this;
}
@@ -74,8 +77,9 @@ CPropVariant& CPropVariant::operator=(const char *s)
bstrVal = ::SysAllocStringByteLen(0, (UINT)len * sizeof(OLECHAR));
if (bstrVal == NULL)
{
vt = VT_ERROR;
scode = E_OUTOFMEMORY;
throw kMemException;
// vt = VT_ERROR;
// scode = E_OUTOFMEMORY;
}
else
{
@@ -204,6 +208,8 @@ void CPropVariant::InternalCopy(const PROPVARIANT *pSrc)
HRESULT hr = Copy(pSrc);
if (FAILED(hr))
{
if (hr == E_OUTOFMEMORY)
throw kMemException;
vt = VT_ERROR;
scode = hr;
}

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.14"
AppDate = "2010-06-04"
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 14
!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 = "14" ?>
<?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.14
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.13 Sources
7-Zip 9.16 Sources
------------------
7-Zip is a file archiver for Windows.