Compare commits

...

2 Commits
15.10 ... 15.12

Author SHA1 Message Date
Igor Pavlov
5de23c1deb 15.12 2016-05-28 00:16:58 +01:00
Igor Pavlov
e24f7fba53 15.11 2016-05-28 00:16:57 +01:00
80 changed files with 1053 additions and 715 deletions

82
C/7z.h
View File

@@ -1,5 +1,5 @@
/* 7z.h -- 7z interface /* 7z.h -- 7z interface
2014-02-08 : Igor Pavlov : Public domain */ 2015-11-18 : Igor Pavlov : Public domain */
#ifndef __7Z_H #ifndef __7Z_H
#define __7Z_H #define __7Z_H
@@ -48,21 +48,10 @@ typedef struct
UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX]; UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX];
CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX]; CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX];
CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX]; CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX];
UInt64 CodersUnpackSizes[SZ_NUM_CODERS_IN_FOLDER_MAX];
} CSzFolder; } CSzFolder;
/*
typedef struct
{
size_t CodersDataOffset;
size_t UnpackSizeDataOffset;
// UInt32 StartCoderUnpackSizesIndex;
UInt32 StartPackStreamIndex;
// UInt32 IndexOfMainOutStream;
} CSzFolder2;
*/
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd, CSzData *sdSizes); SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd);
typedef struct typedef struct
{ {
@@ -92,47 +81,25 @@ typedef struct
UInt32 NumPackStreams; UInt32 NumPackStreams;
UInt32 NumFolders; UInt32 NumFolders;
UInt64 *PackPositions; // NumPackStreams + 1 UInt64 *PackPositions; // NumPackStreams + 1
CSzBitUi32s FolderCRCs; CSzBitUi32s FolderCRCs; // NumFolders
size_t *FoCodersOffsets; size_t *FoCodersOffsets; // NumFolders + 1
size_t *FoSizesOffsets; UInt32 *FoStartPackStreamIndex; // NumFolders + 1
// UInt32 StartCoderUnpackSizesIndex; UInt32 *FoToCoderUnpackSizes; // NumFolders + 1
UInt32 *FoStartPackStreamIndex; Byte *FoToMainUnpackSizeIndex; // NumFolders
UInt64 *CoderUnpackSizes; // for all coders in all folders
// CSzFolder2 *Folders; // +1 item for sum values
Byte *CodersData; Byte *CodersData;
Byte *UnpackSizesData;
size_t UnpackSizesDataSize;
// UInt64 *CoderUnpackSizes;
} CSzAr; } CSzAr;
UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex);
SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
ILookInStream *stream, UInt64 startPos, ILookInStream *stream, UInt64 startPos,
Byte *outBuffer, size_t outSize, Byte *outBuffer, size_t outSize,
ISzAlloc *allocMain); ISzAlloc *allocMain);
/*
SzExtract extracts file from archive
*outBuffer must be 0 before first call for each new archive.
Extracting cache:
If you need to decompress more than one file, you can send
these values from previous call:
*blockIndex,
*outBuffer,
*outBufferSize
You can consider "*outBuffer" as cache of solid block. If your archive is solid,
it will increase decompression speed.
If you use external function, you can declare these 3 cache variables
(blockIndex, outBuffer, outBufferSize) as static in that external function.
Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
*/
typedef struct typedef struct
{ {
CSzAr db; CSzAr db;
@@ -142,7 +109,7 @@ typedef struct
UInt32 NumFiles; UInt32 NumFiles;
UInt64 *UnpackPositions; UInt64 *UnpackPositions; // NumFiles + 1
// Byte *IsEmptyFiles; // Byte *IsEmptyFiles;
Byte *IsDirs; Byte *IsDirs;
CSzBitUi32s CRCs; CSzBitUi32s CRCs;
@@ -152,9 +119,8 @@ typedef struct
CSzBitUi64s MTime; CSzBitUi64s MTime;
CSzBitUi64s CTime; CSzBitUi64s CTime;
// UInt32 *FolderStartPackStreamIndex; UInt32 *FolderToFile; // NumFolders + 1
UInt32 *FolderStartFileIndex; // + 1 UInt32 *FileToFolder; // NumFiles
UInt32 *FileIndexToFolderIndexMap;
size_t *FileNameOffsets; /* in 2-byte steps */ size_t *FileNameOffsets; /* in 2-byte steps */
Byte *FileNames; /* UTF-16-LE */ Byte *FileNames; /* UTF-16-LE */
@@ -182,6 +148,28 @@ size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex);
UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest); UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
*/ */
/*
SzArEx_Extract extracts file from archive
*outBuffer must be 0 before first call for each new archive.
Extracting cache:
If you need to decompress more than one file, you can send
these values from previous call:
*blockIndex,
*outBuffer,
*outBufferSize
You can consider "*outBuffer" as cache of solid block. If your archive is solid,
it will increase decompression speed.
If you use external function, you can declare these 3 cache variables
(blockIndex, outBuffer, outBufferSize) as static in that external function.
Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
*/
SRes SzArEx_Extract( SRes SzArEx_Extract(
const CSzArEx *db, const CSzArEx *db,
ILookInStream *inStream, ILookInStream *inStream,

View File

@@ -1,5 +1,5 @@
/* 7zAlloc.c -- Allocation functions /* 7zAlloc.c -- Allocation functions
2015-02-21 : Igor Pavlov : Public domain */ 2015-11-09 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@@ -26,7 +26,7 @@ void *SzAlloc(void *p, size_t size)
if (size == 0) if (size == 0)
return 0; return 0;
#ifdef _SZ_ALLOC_DEBUG #ifdef _SZ_ALLOC_DEBUG
fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount); fprintf(stderr, "\nAlloc %10u bytes; count = %10d", (unsigned)size, g_allocCount);
g_allocCount++; g_allocCount++;
#endif #endif
return malloc(size); return malloc(size);
@@ -51,7 +51,7 @@ void *SzAllocTemp(void *p, size_t size)
if (size == 0) if (size == 0)
return 0; return 0;
#ifdef _SZ_ALLOC_DEBUG #ifdef _SZ_ALLOC_DEBUG
fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp); fprintf(stderr, "\nAlloc_temp %10u bytes; count = %10d", (unsigned)size, g_allocCountTemp);
g_allocCountTemp++; g_allocCountTemp++;
#ifdef _WIN32 #ifdef _WIN32
return HeapAlloc(GetProcessHeap(), 0, size); return HeapAlloc(GetProcessHeap(), 0, size);

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/* 7zDec.c -- Decoding from 7z folder /* 7zDec.c -- Decoding from 7z folder
2015-08-01 : Igor Pavlov : Public domain */ 2015-11-18 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@@ -8,6 +8,7 @@
/* #define _7ZIP_PPMD_SUPPPORT */ /* #define _7ZIP_PPMD_SUPPPORT */
#include "7z.h" #include "7z.h"
#include "7zCrc.h"
#include "Bcj2.h" #include "Bcj2.h"
#include "Bra.h" #include "Bra.h"
@@ -160,14 +161,23 @@ static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, I
inSize -= inProcessed; inSize -= inProcessed;
if (res != SZ_OK) if (res != SZ_OK)
break; break;
if (state.dicPos == state.dicBufSize || (inProcessed == 0 && dicPos == state.dicPos))
if (status == LZMA_STATUS_FINISHED_WITH_MARK)
{ {
if (state.dicBufSize != outSize || lookahead != 0 || if (outSize != state.dicPos || inSize != 0)
(status != LZMA_STATUS_FINISHED_WITH_MARK &&
status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK))
res = SZ_ERROR_DATA; res = SZ_ERROR_DATA;
break; break;
} }
if (outSize == state.dicPos && inSize == 0 && status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)
break;
if (inProcessed == 0 && dicPos == state.dicPos)
{
res = SZ_ERROR_DATA;
break;
}
res = inStream->Skip((void *)inStream, inProcessed); res = inStream->Skip((void *)inStream, inProcessed);
if (res != SZ_OK) if (res != SZ_OK)
break; break;
@@ -213,13 +223,20 @@ static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize,
inSize -= inProcessed; inSize -= inProcessed;
if (res != SZ_OK) if (res != SZ_OK)
break; break;
if (state.decoder.dicPos == state.decoder.dicBufSize || (inProcessed == 0 && dicPos == state.decoder.dicPos))
if (status == LZMA_STATUS_FINISHED_WITH_MARK)
{ {
if (state.decoder.dicBufSize != outSize || lookahead != 0 || if (outSize != state.decoder.dicPos || inSize != 0)
(status != LZMA_STATUS_FINISHED_WITH_MARK))
res = SZ_ERROR_DATA; res = SZ_ERROR_DATA;
break; break;
} }
if (inProcessed == 0 && dicPos == state.decoder.dicPos)
{
res = SZ_ERROR_DATA;
break;
}
res = inStream->Skip((void *)inStream, inProcessed); res = inStream->Skip((void *)inStream, inProcessed);
if (res != SZ_OK) if (res != SZ_OK)
break; break;
@@ -537,33 +554,38 @@ SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
SRes res; SRes res;
CSzFolder folder; CSzFolder folder;
CSzData sd; CSzData sd;
CSzData sdSizes;
const Byte *data = p->CodersData + p->FoCodersOffsets[folderIndex]; const Byte *data = p->CodersData + p->FoCodersOffsets[folderIndex];
sd.Data = data; sd.Data = data;
sd.Size = p->FoCodersOffsets[folderIndex + 1] - p->FoCodersOffsets[folderIndex]; sd.Size = p->FoCodersOffsets[folderIndex + 1] - p->FoCodersOffsets[folderIndex];
sdSizes.Data = p->UnpackSizesData + p->FoSizesOffsets[folderIndex]; res = SzGetNextFolderItem(&folder, &sd);
sdSizes.Size =
p->FoSizesOffsets[folderIndex + 1] -
p->FoSizesOffsets[folderIndex];
res = SzGetNextFolderItem(&folder, &sd, &sdSizes);
if (res != SZ_OK) if (res != SZ_OK)
return res; return res;
if (sd.Size != 0 || outSize != folder.CodersUnpackSizes[folder.UnpackStream]) if (sd.Size != 0
|| folder.UnpackStream != p->FoToMainUnpackSizeIndex[folderIndex]
|| outSize != SzAr_GetFolderUnpackSize(p, folderIndex))
return SZ_ERROR_FAIL; return SZ_ERROR_FAIL;
{ {
unsigned i; unsigned i;
Byte *tempBuf[3] = { 0, 0, 0}; Byte *tempBuf[3] = { 0, 0, 0};
res = SzFolder_Decode2(&folder, data, folder.CodersUnpackSizes,
res = SzFolder_Decode2(&folder, data,
&p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex]],
p->PackPositions + p->FoStartPackStreamIndex[folderIndex], p->PackPositions + p->FoStartPackStreamIndex[folderIndex],
inStream, startPos, inStream, startPos,
outBuffer, (SizeT)outSize, allocMain, tempBuf); outBuffer, (SizeT)outSize, allocMain, tempBuf);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
IAlloc_Free(allocMain, tempBuf[i]); IAlloc_Free(allocMain, tempBuf[i]);
if (res == SZ_OK)
if (SzBitWithVals_Check(&p->FolderCRCs, folderIndex))
if (CrcCalc(outBuffer, outSize) != p->FolderCRCs.Vals[folderIndex])
res = SZ_ERROR_CRC;
return res; return res;
} }
} }

View File

@@ -1,9 +1,9 @@
#define MY_VER_MAJOR 15 #define MY_VER_MAJOR 15
#define MY_VER_MINOR 10 #define MY_VER_MINOR 12
#define MY_VER_BUILD 0 #define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "15.10" #define MY_VERSION_NUMBERS "15.12"
#define MY_VERSION "15.10 beta" #define MY_VERSION "15.12"
#define MY_DATE "2015-11-01" #define MY_DATE "2015-11-19"
#undef MY_COPYRIGHT #undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE #undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov" #define MY_AUTHOR_NAME "Igor Pavlov"

View File

@@ -513,4 +513,3 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
#endif #endif
return Groups[0]; return Groups[0];
} }

View File

@@ -1,5 +1,5 @@
/* Lzma2Dec.c -- LZMA2 Decoder /* Lzma2Dec.c -- LZMA2 Decoder
2014-10-29 : Igor Pavlov : Public domain */ 2015-11-09 : Igor Pavlov : Public domain */
/* #define SHOW_DEBUG_INFO */ /* #define SHOW_DEBUG_INFO */
@@ -103,8 +103,8 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
{ {
case LZMA2_STATE_CONTROL: case LZMA2_STATE_CONTROL:
p->control = b; p->control = b;
PRF(printf("\n %4X ", p->decoder.dicPos)); PRF(printf("\n %4X ", (unsigned)p->decoder.dicPos));
PRF(printf(" %2X", b)); PRF(printf(" %2X", (unsigned)b));
if (p->control == 0) if (p->control == 0)
return LZMA2_STATE_FINISHED; return LZMA2_STATE_FINISHED;
if (LZMA2_IS_UNCOMPRESSED_STATE(p)) if (LZMA2_IS_UNCOMPRESSED_STATE(p))
@@ -124,7 +124,7 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
case LZMA2_STATE_UNPACK1: case LZMA2_STATE_UNPACK1:
p->unpackSize |= (UInt32)b; p->unpackSize |= (UInt32)b;
p->unpackSize++; p->unpackSize++;
PRF(printf(" %8d", p->unpackSize)); PRF(printf(" %8u", (unsigned)p->unpackSize));
return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
case LZMA2_STATE_PACK0: case LZMA2_STATE_PACK0:
@@ -134,7 +134,7 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
case LZMA2_STATE_PACK1: case LZMA2_STATE_PACK1:
p->packSize |= (UInt32)b; p->packSize |= (UInt32)b;
p->packSize++; p->packSize++;
PRF(printf(" %8d", p->packSize)); PRF(printf(" %8u", (unsigned)p->packSize));
return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP: return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP:
(p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA); (p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA);

View File

@@ -1,5 +1,7 @@
/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder /* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
2009-08-14 : Igor Pavlov : Public domain */ 2015-11-08 : Igor Pavlov : Public domain */
#include "Precomp.h"
#include "Lzma86.h" #include "Lzma86.h"
@@ -7,8 +9,8 @@
#include "Bra.h" #include "Bra.h"
#include "LzmaDec.h" #include "LzmaDec.h"
static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
static void SzFree(void *p, void *address) { p = p; MyFree(address); } static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize) SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
{ {

View File

@@ -1,5 +1,7 @@
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder /* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
2009-08-14 : Igor Pavlov : Public domain */ 2015-11-08 : Igor Pavlov : Public domain */
#include "Precomp.h"
#include <string.h> #include <string.h>
@@ -11,8 +13,8 @@
#define SZE_OUT_OVERFLOW SZE_DATA_ERROR #define SZE_OUT_OVERFLOW SZE_DATA_ERROR
static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
static void SzFree(void *p, void *address) { p = p; MyFree(address); } static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
int level, UInt32 dictSize, int filterMode) int level, UInt32 dictSize, int filterMode)

View File

@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder /* LzmaEnc.c -- LZMA Encoder
2015-10-15 Igor Pavlov : Public domain */ 2015-11-08 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@@ -854,7 +854,7 @@ static void MovePos(CLzmaEnc *p, UInt32 num)
{ {
#ifdef SHOW_STAT #ifdef SHOW_STAT
g_STAT_OFFSET += num; g_STAT_OFFSET += num;
printf("\n MovePos %d", num); printf("\n MovePos %u", num);
#endif #endif
if (num != 0) if (num != 0)
@@ -871,12 +871,12 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);
#ifdef SHOW_STAT #ifdef SHOW_STAT
printf("\n i = %d numPairs = %d ", g_STAT_OFFSET, numPairs / 2); printf("\n i = %u numPairs = %u ", g_STAT_OFFSET, numPairs / 2);
g_STAT_OFFSET++; g_STAT_OFFSET++;
{ {
UInt32 i; UInt32 i;
for (i = 0; i < numPairs; i += 2) for (i = 0; i < numPairs; i += 2)
printf("%2d %6d | ", p->matches[i], p->matches[i + 1]); printf("%2u %6u | ", p->matches[i], p->matches[i + 1]);
} }
#endif #endif
@@ -1167,12 +1167,12 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
cur = 0; cur = 0;
#ifdef SHOW_STAT2 #ifdef SHOW_STAT2
if (position >= 0) /* if (position >= 0) */
{ {
unsigned i; unsigned i;
printf("\n pos = %4X", position); printf("\n pos = %4X", position);
for (i = cur; i <= lenEnd; i++) for (i = cur; i <= lenEnd; i++)
printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price); printf("\nprice[%4X] = %u", position - cur + i, p->opt[i].price);
} }
#endif #endif
@@ -1397,13 +1397,13 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
{ {
UInt32 lenTest2 = lenTest + 1; UInt32 lenTest2 = lenTest + 1;
UInt32 limit = lenTest2 + p->numFastBytes; UInt32 limit = lenTest2 + p->numFastBytes;
UInt32 nextRepMatchPrice;
if (limit > numAvailFull) if (limit > numAvailFull)
limit = numAvailFull; limit = numAvailFull;
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1; lenTest2 -= lenTest + 1;
if (lenTest2 >= 2) if (lenTest2 >= 2)
{ {
UInt32 nextRepMatchPrice;
UInt32 state2 = kRepNextStates[state]; UInt32 state2 = kRepNextStates[state];
UInt32 posStateNext = (position + lenTest) & p->pbMask; UInt32 posStateNext = (position + lenTest) & p->pbMask;
UInt32 curAndLenCharPrice = UInt32 curAndLenCharPrice =
@@ -1487,13 +1487,13 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
const Byte *data2 = data - curBack - 1; const Byte *data2 = data - curBack - 1;
UInt32 lenTest2 = lenTest + 1; UInt32 lenTest2 = lenTest + 1;
UInt32 limit = lenTest2 + p->numFastBytes; UInt32 limit = lenTest2 + p->numFastBytes;
UInt32 nextRepMatchPrice;
if (limit > numAvailFull) if (limit > numAvailFull)
limit = numAvailFull; limit = numAvailFull;
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1; lenTest2 -= lenTest + 1;
if (lenTest2 >= 2) if (lenTest2 >= 2)
{ {
UInt32 nextRepMatchPrice;
UInt32 state2 = kMatchNextStates[state]; UInt32 state2 = kMatchNextStates[state];
UInt32 posStateNext = (position + lenTest) & p->pbMask; UInt32 posStateNext = (position + lenTest) & p->pbMask;
UInt32 curAndLenCharPrice = curAndLenPrice + UInt32 curAndLenCharPrice = curAndLenPrice +
@@ -1829,7 +1829,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
len = GetOptimum(p, nowPos32, &pos); len = GetOptimum(p, nowPos32, &pos);
#ifdef SHOW_STAT2 #ifdef SHOW_STAT2
printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos); printf("\n pos = %4X, len = %u pos = %u", nowPos32, len, pos);
#endif #endif
posState = nowPos32 & p->pbMask; posState = nowPos32 & p->pbMask;

View File

@@ -1,5 +1,5 @@
/* Crypto/Sha256.c -- SHA-256 Hash /* Crypto/Sha256.c -- SHA-256 Hash
2015-03-02 : Igor Pavlov : Public domain 2015-11-14 : Igor Pavlov : Public domain
This code is based on public domain code from Wei Dai's Crypto++ library. */ This code is based on public domain code from Wei Dai's Crypto++ library. */
#include "Precomp.h" #include "Precomp.h"
@@ -113,10 +113,26 @@ static void Sha256_WriteByteBlock(CSha256 *p)
{ {
UInt32 W[16]; UInt32 W[16];
unsigned j; unsigned j;
UInt32 *state = p->state; UInt32 *state;
#ifdef _SHA256_UNROLL2 #ifdef _SHA256_UNROLL2
UInt32 a,b,c,d,e,f,g,h; UInt32 a,b,c,d,e,f,g,h;
#else
UInt32 T[8];
#endif
for (j = 0; j < 16; j += 4)
{
const Byte *ccc = p->buffer + j * 4;
W[j ] = GetBe32(ccc);
W[j + 1] = GetBe32(ccc + 4);
W[j + 2] = GetBe32(ccc + 8);
W[j + 3] = GetBe32(ccc + 12);
}
state = p->state;
#ifdef _SHA256_UNROLL2
a = state[0]; a = state[0];
b = state[1]; b = state[1];
c = state[2]; c = state[2];
@@ -126,17 +142,10 @@ static void Sha256_WriteByteBlock(CSha256 *p)
g = state[6]; g = state[6];
h = state[7]; h = state[7];
#else #else
UInt32 T[8];
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
T[j] = state[j]; T[j] = state[j];
#endif #endif
for (j = 0; j < 16; j += 2)
{
W[j ] = GetBe32(p->buffer + j * 4);
W[j + 1] = GetBe32(p->buffer + j * 4 + 4);
}
for (j = 0; j < 64; j += 16) for (j = 0; j < 64; j += 16)
{ {
RX_16 RX_16
@@ -226,11 +235,13 @@ void Sha256_Final(CSha256 *p, Byte *digest)
Sha256_WriteByteBlock(p); Sha256_WriteByteBlock(p);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i += 2)
{ {
UInt32 v = p->state[i]; UInt32 v0 = p->state[i];
SetBe32(digest, v); UInt32 v1 = p->state[i + 1];
digest += 4; SetBe32(digest , v0);
SetBe32(digest + 4, v1);
digest += 8;
} }
Sha256_Init(p); Sha256_Init(p);

View File

@@ -73,4 +73,3 @@ Ppmd7Dec.o: ../../Ppmd7Dec.c
clean: clean:
-$(RM) $(PROG) $(OBJS) -$(RM) $(PROG) $(OBJS)

View File

@@ -1,5 +1,5 @@
/* 7zipInstall.c - 7-Zip Installer /* 7zipInstall.c - 7-Zip Installer
2015-09-28 : Igor Pavlov : Public domain */ 2015-11-08 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@@ -261,7 +261,7 @@ static LONG MyRegistry_CreateKeyAndVal(HKEY parentKey, LPCWSTR keyName, LPCWSTR
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
{ {
res = MyRegistry_SetString(destKey, valName, val); res = MyRegistry_SetString(destKey, valName, val);
res = RegCloseKey(destKey); /* res = */ RegCloseKey(destKey);
} }
return res; return res;
} }
@@ -284,7 +284,7 @@ static LONG MyRegistry_CreateKeyAndVal_32(HKEY parentKey, LPCWSTR keyName, LPCWS
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
{ {
res = MyRegistry_SetString(destKey, valName, val); res = MyRegistry_SetString(destKey, valName, val);
res = RegCloseKey(destKey); /* res = */ RegCloseKey(destKey);
} }
return res; return res;
} }
@@ -322,7 +322,7 @@ static Bool FindSignature(CSzFile *stream, UInt64 *resPos)
processed -= k7zStartHeaderSize; processed -= k7zStartHeaderSize;
for (pos = 0; pos <= processed; pos++) for (pos = 0; pos <= processed; pos++)
{ {
for (; buf[pos] != '7' && pos <= processed; pos++); for (; pos <= processed && buf[pos] != '7'; pos++);
if (pos > processed) if (pos > processed)
break; break;
if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0) if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0)
@@ -598,8 +598,8 @@ static LONG SetRegKey_Path2(HKEY parentKey)
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
{ {
res = MyRegistry_SetString(destKey, k_Reg_Path32, path); res = MyRegistry_SetString(destKey, k_Reg_Path32, path);
res = MyRegistry_SetString(destKey, k_Reg_Path, path); /* res = */ MyRegistry_SetString(destKey, k_Reg_Path, path);
res = RegCloseKey(destKey); /* res = */ RegCloseKey(destKey);
} }
return res; return res;
} }
@@ -718,10 +718,10 @@ static void WriteCLSID()
WCHAR destPath[MAX_PATH + 10]; WCHAR destPath[MAX_PATH + 10];
wcscpy(destPath, path); wcscpy(destPath, path);
wcscat(destPath, L"7-zip32.dll"); wcscat(destPath, L"7-zip32.dll");
res = MyRegistry_SetString(destKey, NULL, destPath); /* res = */ MyRegistry_SetString(destKey, NULL, destPath);
res = MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment"); /* res = */ MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
// DeleteRegValue(destKey, L"InprocServer32"); // DeleteRegValue(destKey, L"InprocServer32");
res = RegCloseKey(destKey); /* res = */ RegCloseKey(destKey);
} }
#endif #endif
@@ -737,10 +737,10 @@ static void WriteCLSID()
WCHAR destPath[MAX_PATH + 10]; WCHAR destPath[MAX_PATH + 10];
wcscpy(destPath, path); wcscpy(destPath, path);
wcscat(destPath, L"7-zip.dll"); wcscat(destPath, L"7-zip.dll");
res = MyRegistry_SetString(destKey, NULL, destPath); /* res = */ MyRegistry_SetString(destKey, NULL, destPath);
res = MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment"); /* res = */ MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
// DeleteRegValue(destKey, L"InprocServer32"); // DeleteRegValue(destKey, L"InprocServer32");
res = RegCloseKey(destKey); /* res = */ RegCloseKey(destKey);
} }
} }
@@ -1083,7 +1083,6 @@ static int Install()
WCHAR sfxPath[MAX_PATH + 2]; WCHAR sfxPath[MAX_PATH + 2];
Bool needReboot = False; Bool needReboot = False;
size_t pathLen;
allocImp.Alloc = SzAlloc; allocImp.Alloc = SzAlloc;
allocImp.Free = SzFree; allocImp.Free = SzFree;
@@ -1116,6 +1115,7 @@ static int Install()
if (res == SZ_OK) if (res == SZ_OK)
{ {
size_t pathLen;
if (!g_SilentMode) if (!g_SilentMode)
{ {
GetDlgItemTextW(g_HWND, IDE_EXTRACT_PATH, path, MAX_PATH); GetDlgItemTextW(g_HWND, IDE_EXTRACT_PATH, path, MAX_PATH);

View File

@@ -1,5 +1,5 @@
/* 7zipUninstall.c - 7-Zip Uninstaller /* 7zipUninstall.c - 7-Zip Uninstaller
2015-08-09 : Igor Pavlov : Public domain */ 2015-11-08 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@@ -384,7 +384,7 @@ static void WriteCLSID()
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
{ {
RegDeleteValueW(destKey, k_7zip_CLSID); RegDeleteValueW(destKey, k_7zip_CLSID);
res = RegCloseKey(destKey); /* res = */ RegCloseKey(destKey);
} }
} }
} }
@@ -419,7 +419,7 @@ static void WriteCLSID()
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
{ {
RegDeleteValueW(destKey, k_7zip_CLSID); RegDeleteValueW(destKey, k_7zip_CLSID);
res = RegCloseKey(destKey); /* res = */ RegCloseKey(destKey);
} }
} }
} }

View File

@@ -1,5 +1,5 @@
/* LzmaUtil.c -- Test application for LZMA compression /* LzmaUtil.c -- Test application for LZMA compression
2015-06-13 : Igor Pavlov : Public domain */ 2015-11-08 : Igor Pavlov : Public domain */
#include "../../Precomp.h" #include "../../Precomp.h"
@@ -133,7 +133,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
SRes res; SRes res;
CLzmaEncProps props; CLzmaEncProps props;
rs = rs; UNUSED_VAR(rs);
enc = LzmaEnc_Create(&g_Alloc); enc = LzmaEnc_Create(&g_Alloc);
if (enc == 0) if (enc == 0)

View File

@@ -1,12 +1,14 @@
/* LzmaLibExports.c -- LZMA library DLL Entry point /* LzmaLibExports.c -- LZMA library DLL Entry point
2008-10-04 : Igor Pavlov : Public domain */ 2015-11-08 : Igor Pavlov : Public domain */
#include "../../Precomp.h"
#include <windows.h> #include <windows.h>
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{ {
hInstance = hInstance; UNUSED_VAR(hInstance);
dwReason = dwReason; UNUSED_VAR(dwReason);
lpReserved = lpReserved; UNUSED_VAR(lpReserved);
return TRUE; return TRUE;
} }

View File

@@ -1,5 +1,5 @@
/* SfxSetup.c - 7z SFX Setup /* SfxSetup.c - 7z SFX Setup
2015-03-25 : Igor Pavlov : Public domain */ 2015-11-08 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@@ -88,7 +88,7 @@ static unsigned FindItem(const char * const *items, unsigned num, const wchar_t
#ifdef _CONSOLE #ifdef _CONSOLE
static BOOL WINAPI HandlerRoutine(DWORD ctrlType) static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
{ {
ctrlType = ctrlType; UNUSED_VAR(ctrlType);
return TRUE; return TRUE;
} }
#endif #endif
@@ -144,7 +144,7 @@ static Bool FindSignature(CSzFile *stream, UInt64 *resPos)
processed -= k7zStartHeaderSize; processed -= k7zStartHeaderSize;
for (pos = 0; pos <= processed; pos++) for (pos = 0; pos <= processed; pos++)
{ {
for (; buf[pos] != '7' && pos <= processed; pos++); for (; pos <= processed && buf[pos] != '7'; pos++);
if (pos > processed) if (pos > processed)
break; break;
if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0) if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0)
@@ -257,10 +257,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef _CONSOLE #ifdef _CONSOLE
SetConsoleCtrlHandler(HandlerRoutine, TRUE); SetConsoleCtrlHandler(HandlerRoutine, TRUE);
#else #else
hInstance = hInstance; UNUSED_VAR(hInstance);
hPrevInstance = hPrevInstance; UNUSED_VAR(hPrevInstance);
lpCmdLine = lpCmdLine; UNUSED_VAR(lpCmdLine);
nCmdShow = nCmdShow; UNUSED_VAR(nCmdShow);
#endif #endif
CrcGenerateTable(); CrcGenerateTable();

View File

@@ -1,5 +1,5 @@
/* XzDec.c -- Xz Decode /* XzDec.c -- Xz Decode
2015-05-01 : Igor Pavlov : Public domain */ 2015-11-09 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@@ -74,7 +74,7 @@ static void BraState_Free(void *pp, ISzAlloc *alloc)
static SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc) static SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
{ {
CBraState *p = ((CBraState *)pp); CBraState *p = ((CBraState *)pp);
alloc = alloc; UNUSED_VAR(alloc);
p->ip = 0; p->ip = 0;
if (p->methodId == XZ_ID_Delta) if (p->methodId == XZ_ID_Delta)
{ {
@@ -129,9 +129,9 @@ static SRes BraState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src,
CBraState *p = ((CBraState *)pp); CBraState *p = ((CBraState *)pp);
SizeT destLenOrig = *destLen; SizeT destLenOrig = *destLen;
SizeT srcLenOrig = *srcLen; SizeT srcLenOrig = *srcLen;
UNUSED_VAR(finishMode);
*destLen = 0; *destLen = 0;
*srcLen = 0; *srcLen = 0;
finishMode = finishMode;
*wasFinished = 0; *wasFinished = 0;
while (destLenOrig > 0) while (destLenOrig > 0)
{ {
@@ -236,8 +236,8 @@ static void SbState_Free(void *pp, ISzAlloc *alloc)
static SRes SbState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc) static SRes SbState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
{ {
UNUSED_VAR(pp); UNUSED_VAR(pp);
props = props; UNUSED_VAR(props);
alloc = alloc; UNUSED_VAR(alloc);
return (propSize == 0) ? SZ_OK : SZ_ERROR_UNSUPPORTED; return (propSize == 0) ? SZ_OK : SZ_ERROR_UNSUPPORTED;
} }
@@ -251,7 +251,7 @@ static SRes SbState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src,
{ {
CSbDec *p = (CSbDec *)pp; CSbDec *p = (CSbDec *)pp;
SRes res; SRes res;
srcWasFinished = srcWasFinished; UNUSED_VAR(srcWasFinished);
p->dest = dest; p->dest = dest;
p->destLen = *destLen; p->destLen = *destLen;
p->src = src; p->src = src;
@@ -308,7 +308,7 @@ static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *sr
ELzmaStatus status; ELzmaStatus status;
/* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */ /* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */
SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, (ELzmaFinishMode)finishMode, &status); SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, (ELzmaFinishMode)finishMode, &status);
srcWasFinished = srcWasFinished; UNUSED_VAR(srcWasFinished);
*wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK); *wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
return res; return res;
} }
@@ -555,7 +555,7 @@ SRes XzBlock_Parse(CXzBlock *p, const Byte *header)
pos += (unsigned)size; pos += (unsigned)size;
#ifdef XZ_DUMP #ifdef XZ_DUMP
printf("\nf[%d] = %2X: ", i, filter->id); printf("\nf[%u] = %2X: ", i, (unsigned)filter->id);
{ {
unsigned i; unsigned i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)

View File

@@ -1,5 +1,5 @@
/* XzIn.c - Xz input /* XzIn.c - Xz input
2015-04-21 : Igor Pavlov : Public domain */ 2015-11-08 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@@ -72,7 +72,7 @@ SRes XzBlock_ReadFooter(CXzBlock *p, CXzStreamFlags f, ISeqInStream *inStream)
static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *alloc) static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *alloc)
{ {
size_t i, numBlocks, pos = 1; size_t numBlocks, pos = 1;
UInt32 crc; UInt32 crc;
if (size < 5 || buf[0] != 0) if (size < 5 || buf[0] != 0)
@@ -94,6 +94,7 @@ static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *
Xz_Free(p, alloc); Xz_Free(p, alloc);
if (numBlocks != 0) if (numBlocks != 0)
{ {
size_t i;
p->numBlocks = numBlocks; p->numBlocks = numBlocks;
p->numBlocksAllocated = numBlocks; p->numBlocksAllocated = numBlocks;
p->blocks = alloc->Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks); p->blocks = alloc->Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks);

View File

@@ -87,6 +87,8 @@ struct CFolders
return PackPositions[index + 1] - PackPositions[index]; return PackPositions[index + 1] - PackPositions[index];
} }
CFolders(): NumPackStreams(0), NumFolders(0) {}
void Clear() void Clear()
{ {
NumPackStreams = 0; NumPackStreams = 0;

View File

@@ -26,6 +26,7 @@ HINSTANCE g_hInstance;
#define NT_CHECK_FAIL_ACTION return FALSE; #define NT_CHECK_FAIL_ACTION return FALSE;
#ifdef _WIN32
extern "C" extern "C"
BOOL WINAPI DllMain( BOOL WINAPI DllMain(
#ifdef UNDER_CE #ifdef UNDER_CE
@@ -49,6 +50,7 @@ BOOL WINAPI DllMain(
*/ */
return TRUE; return TRUE;
} }
#endif
DEFINE_GUID(CLSID_CArchiveHandler, DEFINE_GUID(CLSID_CArchiveHandler,
k_7zip_GUID_Data1, k_7zip_GUID_Data1,

View File

@@ -1825,6 +1825,8 @@ HRESULT CHandler::Open2(IInStream *stream,
int prevSplitFile = -1; int prevSplitFile = -1;
int prevMainFile = -1; int prevMainFile = -1;
bool nextVol_is_Required = false;
CInArchive arch; CInArchive arch;
for (;;) for (;;)
@@ -1861,7 +1863,8 @@ HRESULT CHandler::Open2(IInStream *stream,
if (!inStream || result != S_OK) if (!inStream || result != S_OK)
{ {
_missingVolName = volName; if (nextVol_is_Required)
_missingVolName = volName;
break; break;
} }
} }
@@ -2111,11 +2114,18 @@ HRESULT CHandler::Open2(IInStream *stream,
} }
curBytes += endPos; curBytes += endPos;
nextVol_is_Required = false;
if (!arcInfo.IsVolume()) if (!arcInfo.IsVolume())
break; break;
if (arcInfo.EndOfArchive_was_Read
&& !arcInfo.AreMoreVolumes()) if (arcInfo.EndOfArchive_was_Read)
break; {
if (!arcInfo.AreMoreVolumes())
break;
nextVol_is_Required = true;
}
} }
FillLinks(); FillLinks();

View File

@@ -640,6 +640,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
{ {
ArcInfo.EndFlags = m_BlockHeader.Flags; ArcInfo.EndFlags = m_BlockHeader.Flags;
UInt32 offset = 7; UInt32 offset = 7;
if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_DataCRC) if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_DataCRC)
{ {
if (processed < offset + 4) if (processed < offset + 4)
@@ -648,6 +649,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
ArcInfo.DataCRC = Get32(m_FileHeaderData + offset); ArcInfo.DataCRC = Get32(m_FileHeaderData + offset);
offset += 4; offset += 4;
} }
if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_VolNumber) if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_VolNumber)
{ {
if (processed < offset + 2) if (processed < offset + 2)
@@ -657,6 +659,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
ArcInfo.EndOfArchive_was_Read = true; ArcInfo.EndOfArchive_was_Read = true;
} }
m_Position += processed; m_Position += processed;
FinishCryptoBlock(); FinishCryptoBlock();
ArcInfo.EndPos = m_Position; ArcInfo.EndPos = m_Position;
@@ -699,11 +702,13 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
continue; continue;
*/ */
} }
if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 10)) if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 10))
{ {
error = k_ErrorType_DecryptionError; error = k_ErrorType_DecryptionError;
return S_OK; return S_OK;
} }
if ((m_BlockHeader.Flags & NHeader::NBlock::kLongBlock) != 0) if ((m_BlockHeader.Flags & NHeader::NBlock::kLongBlock) != 0)
{ {
if (m_FileHeaderData.Size() < 7 + 4) if (m_FileHeaderData.Size() < 7 + 4)
@@ -1032,7 +1037,10 @@ HRESULT CHandler::Open2(IInStream *stream,
openCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getTextPassword); openCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getTextPassword);
} }
bool nextVol_is_Required = false;
CInArchive archive; CInArchive archive;
for (;;) for (;;)
{ {
CMyComPtr<IInStream> inStream; CMyComPtr<IInStream> inStream;
@@ -1072,7 +1080,8 @@ HRESULT CHandler::Open2(IInStream *stream,
if (!inStream || result != S_OK) if (!inStream || result != S_OK)
{ {
_missingVolName = volName; if (nextVol_is_Required)
_missingVolName = volName;
break; break;
} }
} }
@@ -1191,6 +1200,18 @@ HRESULT CHandler::Open2(IInStream *stream,
arc.PhySize = archive.ArcInfo.GetPhySize(); arc.PhySize = archive.ArcInfo.GetPhySize();
arc.Stream = inStream; arc.Stream = inStream;
} }
nextVol_is_Required = false;
if (!archive.ArcInfo.IsVolume())
break;
if (archive.ArcInfo.EndOfArchive_was_Read)
{
if (!archive.ArcInfo.AreMoreVolumes())
break;
nextVol_is_Required = true;
}
} }
} }

View File

@@ -45,6 +45,7 @@ struct CInArcInfo
bool IsEncryptOld() const { return (!IsThereEncryptVer() || EncryptVersion < 36); } bool IsEncryptOld() const { return (!IsThereEncryptVer() || EncryptVersion < 36); }
bool AreMoreVolumes() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_NextVol) != 0; }
bool Is_VolNumber_Defined() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_VolNumber) != 0; } bool Is_VolNumber_Defined() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_VolNumber) != 0; }
bool Is_DataCRC_Defined() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_DataCRC) != 0; } bool Is_DataCRC_Defined() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_DataCRC) != 0; }
}; };

View File

@@ -98,6 +98,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
if (!_archive.IsArc) v |= kpv_ErrorFlags_IsNotArc; if (!_archive.IsArc) v |= kpv_ErrorFlags_IsNotArc;
if (_archive.Unsupported) v |= kpv_ErrorFlags_UnsupportedFeature; if (_archive.Unsupported) v |= kpv_ErrorFlags_UnsupportedFeature;
if (_archive.UnexpectedEnd) v |= kpv_ErrorFlags_UnexpectedEnd; if (_archive.UnexpectedEnd) v |= kpv_ErrorFlags_UnexpectedEnd;
if (_archive.NoEndAnchor) v |= kpv_ErrorFlags_HeadersError;
prop = v; prop = v;
break; break;
} }

View File

@@ -610,6 +610,7 @@ API_FUNC_IsArc IsArc_Udf(const Byte *p, size_t size)
} }
} }
HRESULT CInArchive::Open2() HRESULT CInArchive::Open2()
{ {
Clear(); Clear();
@@ -644,8 +645,10 @@ HRESULT CInArchive::Open2()
CExtent extentVDS; CExtent extentVDS;
extentVDS.Parse(buf + i + 16); extentVDS.Parse(buf + i + 16);
*/ */
const size_t kBufSize = 1 << 11; const size_t kBufSize = 1 << 11;
Byte buf[kBufSize]; Byte buf[kBufSize];
for (SecLogSize = 11;; SecLogSize -= 3) for (SecLogSize = 11;; SecLogSize -= 3)
{ {
if (SecLogSize < 8) if (SecLogSize < 8)
@@ -665,6 +668,7 @@ HRESULT CInArchive::Open2()
break; break;
} }
} }
PhySize = (UInt32)(256 + 1) << SecLogSize; PhySize = (UInt32)(256 + 1) << SecLogSize;
IsArc = true; IsArc = true;
@@ -946,28 +950,63 @@ HRESULT CInArchive::Open2()
} }
{ {
UInt32 secMask = ((UInt32)1 << SecLogSize) - 1; const UInt32 secMask = ((UInt32)1 << SecLogSize) - 1;
PhySize = (PhySize + secMask) & ~(UInt64)secMask; PhySize = (PhySize + secMask) & ~(UInt64)secMask;
} }
NoEndAnchor = true;
if (PhySize < fileSize) if (PhySize < fileSize)
{ {
UInt64 rem = fileSize - PhySize;
const size_t secSize = (size_t)1 << SecLogSize;
RINOK(_stream->Seek(PhySize, STREAM_SEEK_SET, NULL)); RINOK(_stream->Seek(PhySize, STREAM_SEEK_SET, NULL));
size_t bufSize = (UInt32)1 << SecLogSize;
size_t readSize = bufSize; // some UDF images contain ZEROs before "Anchor Volume Descriptor Pointer" at the end
RINOK(ReadStream(_stream, buf, &readSize));
if (readSize == bufSize) for (unsigned sec = 0; sec < 1024; sec++)
{ {
CTag tag; if (rem == 0)
if (tag.Parse(buf, readSize) == S_OK) break;
if (tag.Id == DESC_TYPE_AnchorVolPtr)
size_t readSize = secSize;
if (readSize > rem)
readSize = (size_t)rem;
RINOK(ReadStream(_stream, buf, &readSize));
if (readSize == 0)
break;
if (readSize == secSize && NoEndAnchor)
{
CTag tag;
if (tag.Parse(buf, readSize) == S_OK &&
tag.Id == DESC_TYPE_AnchorVolPtr)
{ {
PhySize += bufSize; NoEndAnchor = false;
rem -= readSize;
PhySize = fileSize - rem;
continue;
} }
}
size_t i;
for (i = 0; i < readSize && buf[i] == 0; i++);
if (i != readSize)
break;
rem -= readSize;
} }
if (rem == 0)
PhySize = fileSize;
} }
return S_OK; return S_OK;
} }
HRESULT CInArchive::Open(IInStream *inStream, CProgressVirt *progress) HRESULT CInArchive::Open(IInStream *inStream, CProgressVirt *progress)
{ {
_progress = progress; _progress = progress;
@@ -1000,6 +1039,7 @@ void CInArchive::Clear()
IsArc = false; IsArc = false;
Unsupported = false; Unsupported = false;
UnexpectedEnd = false; UnexpectedEnd = false;
NoEndAnchor = false;
PhySize = 0; PhySize = 0;
FileSize = 0; FileSize = 0;

View File

@@ -370,6 +370,7 @@ public:
bool IsArc; bool IsArc;
bool Unsupported; bool Unsupported;
bool UnexpectedEnd; bool UnexpectedEnd;
bool NoEndAnchor;
void UpdatePhySize(UInt64 val) void UpdatePhySize(UInt64 val)
{ {

View File

@@ -373,6 +373,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
ConvertUInt32ToString(f.AlgId, temp + 1); ConvertUInt32ToString(f.AlgId, temp + 1);
m += temp; m += temp;
} }
if (f.CertificateIsUsed())
m += "-Cert";
} }
else else
m += kMethod_StrongCrypto; m += kMethod_StrongCrypto;

View File

@@ -188,9 +188,9 @@ API_FUNC_IsArc IsArc_Zip(const Byte *p, size_t size)
// Crc = Get32(p + 10); // Crc = Get32(p + 10);
// PackSize = Get32(p + 14); // PackSize = Get32(p + 14);
// Size = Get32(p + 18); // Size = Get32(p + 18);
unsigned nameSize = Get16(p + 22); const unsigned nameSize = Get16(p + 22);
unsigned extraSize = Get16(p + 24); unsigned extraSize = Get16(p + 24);
UInt32 extraOffset = kLocalHeaderSize + (UInt32)nameSize; const UInt32 extraOffset = kLocalHeaderSize + (UInt32)nameSize;
if (extraOffset + extraSize > (1 << 16)) if (extraOffset + extraSize > (1 << 16))
return k_IsArc_Res_NO; return k_IsArc_Res_NO;
@@ -562,13 +562,21 @@ bool CInArchive::ReadLocalItem(CItemEx &item)
// return false; // return false;
} }
} }
if (!CheckDosTime(item.Time)) if (!CheckDosTime(item.Time))
{ {
HeadersWarning = true; HeadersWarning = true;
// return false; // return false;
} }
if (item.Name.Len() != nameSize) if (item.Name.Len() != nameSize)
return false; {
// we support "bad" archives with null-terminated name.
if (item.Name.Len() + 1 != nameSize)
return false;
HeadersWarning = true;
}
return item.LocalFullHeaderSize <= ((UInt32)1 << 16); return item.LocalFullHeaderSize <= ((UInt32)1 << 16);
} }
@@ -782,9 +790,9 @@ HRESULT CInArchive::ReadCdItem(CItemEx &item)
item.Crc = Get32(p + 12); item.Crc = Get32(p + 12);
item.PackSize = Get32(p + 16); item.PackSize = Get32(p + 16);
item.Size = Get32(p + 20); item.Size = Get32(p + 20);
unsigned nameSize = Get16(p + 24); const unsigned nameSize = Get16(p + 24);
UInt16 extraSize = Get16(p + 26); const unsigned extraSize = Get16(p + 26);
UInt16 commentSize = Get16(p + 28); const unsigned commentSize = Get16(p + 28);
UInt32 diskNumberStart = Get16(p + 30); UInt32 diskNumberStart = Get16(p + 30);
item.InternalAttrib = Get16(p + 32); item.InternalAttrib = Get16(p + 32);
item.ExternalAttrib = Get32(p + 34); item.ExternalAttrib = Get32(p + 34);
@@ -961,7 +969,7 @@ HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UI
CItemEx cdItem; CItemEx cdItem;
RINOK(ReadCdItem(cdItem)); RINOK(ReadCdItem(cdItem));
items.Add(cdItem); items.Add(cdItem);
if (progress && items.Size() % 1 == 0) if (progress && (items.Size() & 0xFFF) == 0)
RINOK(progress->SetCompletedCD(items.Size())); RINOK(progress->SetCompletedCD(items.Size()));
} }
return (m_Position - cdOffset == cdSize) ? S_OK : S_FALSE; return (m_Position - cdOffset == cdSize) ? S_OK : S_FALSE;
@@ -1009,6 +1017,7 @@ bool IsStrangeItem(const CItem &item)
return item.Name.Len() > (1 << 14) || item.Method > (1 << 8); return item.Name.Len() > (1 << 14) || item.Method > (1 << 8);
} }
HRESULT CInArchive::ReadLocals( HRESULT CInArchive::ReadLocals(
CObjectVector<CItemEx> &items, CProgressVirt *progress) CObjectVector<CItemEx> &items, CProgressVirt *progress)
{ {
@@ -1037,7 +1046,8 @@ HRESULT CInArchive::ReadLocals(
return S_FALSE; return S_FALSE;
throw; throw;
} }
if (progress && items.Size() % 1 == 0)
if (progress && (items.Size() & 0xFF) == 0)
RINOK(progress->SetCompletedLocal(items.Size(), item.LocalHeaderPos)); RINOK(progress->SetCompletedLocal(items.Size(), item.LocalHeaderPos));
} }
@@ -1154,15 +1164,17 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
HeadersError = true; HeadersError = true;
return S_OK; return S_OK;
} }
_inBufMode = true; _inBufMode = true;
_inBuffer.Init(); _inBuffer.Init();
cdAbsOffset = m_Position - 4; cdAbsOffset = m_Position - 4;
for (;;) for (;;)
{ {
CItemEx cdItem; CItemEx cdItem;
RINOK(ReadCdItem(cdItem)); RINOK(ReadCdItem(cdItem));
cdItems.Add(cdItem); cdItems.Add(cdItem);
if (progress && cdItems.Size() % 1 == 0) if (progress && (cdItems.Size() & 0xFFF) == 0)
RINOK(progress->SetCompletedCD(items.Size())); RINOK(progress->SetCompletedCD(items.Size()));
m_Signature = ReadUInt32(); m_Signature = ReadUInt32();
if (m_Signature != NSignature::kCentralFileHeader) if (m_Signature != NSignature::kCentralFileHeader)
@@ -1183,6 +1195,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
CEcd64 ecd64; CEcd64 ecd64;
bool isZip64 = false; bool isZip64 = false;
UInt64 ecd64AbsOffset = m_Position - 4; UInt64 ecd64AbsOffset = m_Position - 4;
if (m_Signature == NSignature::kEcd64) if (m_Signature == NSignature::kEcd64)
{ {
IsZip64 = isZip64 = true; IsZip64 = isZip64 = true;
@@ -1213,6 +1226,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
(!items.IsEmpty()))) (!items.IsEmpty())))
return S_FALSE; return S_FALSE;
} }
if (m_Signature == NSignature::kEcd64Locator) if (m_Signature == NSignature::kEcd64Locator)
{ {
if (!isZip64) if (!isZip64)
@@ -1224,6 +1238,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
return S_FALSE; return S_FALSE;
m_Signature = ReadUInt32(); m_Signature = ReadUInt32();
} }
if (m_Signature != NSignature::kEcd) if (m_Signature != NSignature::kEcd)
return S_FALSE; return S_FALSE;
@@ -1323,6 +1338,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
return S_OK; return S_OK;
} }
HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress) HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress)
{ {
HRESULT res; HRESULT res;

View File

@@ -109,6 +109,8 @@ struct CStrongCryptoExtra
Flags = GetUi16(p + 6); Flags = GetUi16(p + 6);
return (Format == 2); return (Format == 2);
} }
bool CertificateIsUsed() const { return (Flags > 0x0001); }
}; };
struct CExtraBlock struct CExtraBlock

View File

@@ -107,4 +107,4 @@ C_OBJS = \
!include "../../Aes.mak" !include "../../Aes.mak"
!include "../../Crc.mak" !include "../../Crc.mak"
!include "../../7zip.mak" !include "../../7zip.mak"

View File

@@ -18,7 +18,6 @@ FILE_IO =FileIO
FILE_IO_2 =Windows/$(FILE_IO) FILE_IO_2 =Windows/$(FILE_IO)
MT_FILES = \ MT_FILES = \
System.o \
LzFindMt.o \ LzFindMt.o \
Threads.o \ Threads.o \
@@ -60,6 +59,7 @@ OBJS = \
StringConvert.o \ StringConvert.o \
StringToInt.o \ StringToInt.o \
PropVariant.o \ PropVariant.o \
System.o \
7zCrc.o \ 7zCrc.o \
7zCrcOpt.o \ 7zCrcOpt.o \
Alloc.o \ Alloc.o \
@@ -150,10 +150,8 @@ StringToInt.o: ../../../Common/StringToInt.cpp
PropVariant.o: ../../../Windows/PropVariant.cpp PropVariant.o: ../../../Windows/PropVariant.cpp
$(CXX) $(CFLAGS) ../../../Windows/PropVariant.cpp $(CXX) $(CFLAGS) ../../../Windows/PropVariant.cpp
ifdef MT_FILES
System.o: ../../../Windows/System.cpp System.o: ../../../Windows/System.cpp
$(CXX) $(CFLAGS) ../../../Windows/System.cpp $(CXX) $(CFLAGS) ../../../Windows/System.cpp
endif
7zCrc.o: ../../../../C/7zCrc.c 7zCrc.o: ../../../../C/7zCrc.c
$(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c $(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
@@ -195,4 +193,3 @@ Lzma86Enc.o: ../../../../C/Lzma86Enc.c
clean: clean:
-$(RM) $(PROG) $(OBJS) -$(RM) $(PROG) $(OBJS)

View File

@@ -9,4 +9,4 @@
REGISTER_FILTER_E(7zAES, REGISTER_FILTER_E(7zAES,
NCrypto::N7z::CDecoder(), NCrypto::N7z::CDecoder(),
NCrypto::N7z::CEncoder(), NCrypto::N7z::CEncoder(),
0x6F10701, "7zAES") 0x6F10701, "7zAES")

View File

@@ -9,4 +9,4 @@
REGISTER_FILTER_E(AES256CBC, REGISTER_FILTER_E(AES256CBC,
NCrypto::CAesCbcDecoder(32), NCrypto::CAesCbcDecoder(32),
NCrypto::CAesCbcEncoder(32), NCrypto::CAesCbcEncoder(32),
0x6F00181, "AES256CBC") 0x6F00181, "AES256CBC")

View File

@@ -73,8 +73,10 @@ void CRandomGenerator::Init()
HASH_UPD(v2); HASH_UPD(v2);
#endif #endif
#ifdef _WIN32
DWORD tickCount = ::GetTickCount(); DWORD tickCount = ::GetTickCount();
HASH_UPD(tickCount); HASH_UPD(tickCount);
#endif
for (unsigned j = 0; j < 100; j++) for (unsigned j = 0; j < 100; j++)
{ {

View File

@@ -112,25 +112,87 @@ HRESULT CDecoder::Init_and_CheckPassword(bool &passwOK)
if (algId * 64 + 128 != bitLen) if (algId * 64 + 128 != bitLen)
return E_NOTIMPL; return E_NOTIMPL;
_key.KeySize = 16 + algId * 8; _key.KeySize = 16 + algId * 8;
if ((flags & 1) == 0) bool cert = ((flags & 2) != 0);
return E_NOTIMPL;
if ((flags & 0x4000) != 0) if ((flags & 0x4000) != 0)
{ {
// Use 3DES // Use 3DES
return E_NOTIMPL; return E_NOTIMPL;
} }
if (cert)
{
return E_NOTIMPL;
}
else
{
if ((flags & 1) == 0)
return E_NOTIMPL;
}
UInt32 rdSize = GetUi16(p + 8); UInt32 rdSize = GetUi16(p + 8);
if ((rdSize & 0xF) != 0 || rdSize + 16 > _remSize)
return E_NOTIMPL; if (rdSize + 16 > _remSize)
memmove(p, p + 10, rdSize);
Byte *validData = p + rdSize + 16;
if (GetUi32(validData - 6) != 0) // reserved
return E_NOTIMPL;
UInt32 validSize = GetUi16(validData - 2);
if ((validSize & 0xF) != 0 || 16 + rdSize + validSize != _remSize)
return E_NOTIMPL; return E_NOTIMPL;
/*
if (cert)
{
// how to filter rd, if ((rdSize & 0xF) != 0) ?
/*
if ((rdSize & 0x7) != 0)
return E_NOTIMPL;
}
else
*/
{
if ((rdSize & 0xF) != 0)
return E_NOTIMPL;
}
memmove(p, p + 10, rdSize);
const Byte *p2 = p + rdSize + 10;
UInt32 reserved = GetUi32(p2);
p2 += 4;
/*
if (cert)
{
UInt32 numRecipients = reserved;
if (numRecipients == 0)
return E_NOTIMPL;
{
UInt32 hashAlg = GetUi16(p2);
hashAlg = hashAlg;
UInt32 hashSize = GetUi16(p2 + 2);
hashSize = hashSize;
p2 += 4;
reserved = reserved;
// return E_NOTIMPL;
for (unsigned r = 0; r < numRecipients; r++)
{
UInt32 specSize = GetUi16(p2);
p2 += 2;
p2 += specSize;
}
}
}
else
*/
{
if (reserved != 0)
return E_NOTIMPL;
}
UInt32 validSize = GetUi16(p2);
p2 += 2;
const size_t validOffset = p2 - p;
if ((validSize & 0xF) != 0 || validOffset + validSize != _remSize)
return E_NOTIMPL;
{ {
RINOK(SetKey(_key.MasterKey, _key.KeySize)); RINOK(SetKey(_key.MasterKey, _key.KeySize));
@@ -149,12 +211,14 @@ HRESULT CDecoder::Init_and_CheckPassword(bool &passwOK)
RINOK(SetKey(fileKey, _key.KeySize)); RINOK(SetKey(fileKey, _key.KeySize));
RINOK(SetInitVector(_iv, 16)); RINOK(SetInitVector(_iv, 16));
Init(); Init();
Filter(validData, validSize);
memmove(p, p + validOffset, validSize);
Filter(p, validSize);
if (validSize < 4) if (validSize < 4)
return E_NOTIMPL; return E_NOTIMPL;
validSize -= 4; validSize -= 4;
if (GetUi32(validData + validSize) != CrcCalc(validData, validSize)) if (GetUi32(p + validSize) != CrcCalc(p, validSize))
return S_OK; return S_OK;
passwOK = true; passwOK = true;
return S_OK; return S_OK;

View File

@@ -248,7 +248,8 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
unsigned len = 0; unsigned len = 0;
bool isPtrName = false; bool isPtrName = false;
#ifdef MY_CPU_LE #if defined(MY_CPU_LE) && defined(_WIN32)
// it works only if (sizeof(wchar_t) == 2)
if (arc.GetRawProps) if (arc.GetRawProps)
{ {
const void *p; const void *p;

View File

@@ -271,7 +271,7 @@ static const unsigned kCommandIndex = 0;
static const char *kCannotFindListFile = "Cannot find listfile"; static const char *kCannotFindListFile = "Cannot find listfile";
static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch."; static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
static const char *kTerminalOutError = "I won't write compressed data to a terminal"; static const char *kTerminalOutError = "I won't write compressed data to a terminal";
static const char *kSameTerminalError = "I won't write data and program's messages to same terminal"; static const char *kSameTerminalError = "I won't write data and program's messages to same stream";
static const char *kEmptyFilePath = "Empty file path"; static const char *kEmptyFilePath = "Empty file path";
static const char *kCannotFindArchive = "Cannot find archive"; static const char *kCannotFindArchive = "Cannot find archive";
@@ -1219,8 +1219,26 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
if (isExtractGroupCommand) if (isExtractGroupCommand)
{ {
if (options.StdOutMode && options.IsStdOutTerminal && options.IsStdErrTerminal) if (options.StdOutMode)
throw CArcCmdLineException(kSameTerminalError); {
if (
options.Number_for_Percents == k_OutStream_stdout
// || options.Number_for_Out == k_OutStream_stdout
// || options.Number_for_Errors == k_OutStream_stdout
||
(
(options.IsStdOutTerminal && options.IsStdErrTerminal)
&&
(
options.Number_for_Percents != k_OutStream_disabled
// || options.Number_for_Out != k_OutStream_disabled
// || options.Number_for_Errors != k_OutStream_disabled
)
)
)
throw CArcCmdLineException(kSameTerminalError);
}
if (parser[NKey::kOutputDir].ThereIs) if (parser[NKey::kOutputDir].ThereIs)
{ {
eo.OutputDir = us2fs(parser[NKey::kOutputDir].PostStrings[0]); eo.OutputDir = us2fs(parser[NKey::kOutputDir].PostStrings[0]);
@@ -1293,8 +1311,18 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
if (updateOptions.StdOutMode && updateOptions.EMailMode) if (updateOptions.StdOutMode && updateOptions.EMailMode)
throw CArcCmdLineException("stdout mode and email mode cannot be combined"); throw CArcCmdLineException("stdout mode and email mode cannot be combined");
if (updateOptions.StdOutMode && options.IsStdOutTerminal)
throw CArcCmdLineException(kTerminalOutError); if (updateOptions.StdOutMode)
{
if (options.IsStdOutTerminal)
throw CArcCmdLineException(kTerminalOutError);
if (options.Number_for_Percents == k_OutStream_stdout
|| options.Number_for_Out == k_OutStream_stdout
|| options.Number_for_Errors == k_OutStream_stdout)
throw CArcCmdLineException(kSameTerminalError);
}
if (updateOptions.StdInMode) if (updateOptions.StdInMode)
updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front(); updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();

View File

@@ -451,32 +451,42 @@ static UString GetDirPrefixOf(const UString &src)
return s; return s;
} }
static bool IsSafePath(const UString &path) #endif
bool IsSafePath(const UString &path)
{ {
if (NName::IsAbsolutePath(path))
return false;
UStringVector parts; UStringVector parts;
SplitPathToParts(path, parts); SplitPathToParts(path, parts);
int level = 0; unsigned level = 0;
FOR_VECTOR(i, parts)
FOR_VECTOR (i, parts)
{ {
const UString &s = parts[i]; const UString &s = parts[i];
if (s.IsEmpty()) if (s.IsEmpty())
{
if (i == 0)
return false;
continue; continue;
}
if (s == L".") if (s == L".")
continue; continue;
if (s == L"..") if (s == L"..")
{ {
if (level <= 0) if (level == 0)
return false; return false;
level--; level--;
} }
else else
level++; level++;
} }
return level > 0; return level > 0;
} }
#endif
bool CensorNode_CheckPath2(const NWildcard::CCensorNode &node, const CReadArcItem &item, bool &include) bool CensorNode_CheckPath2(const NWildcard::CCensorNode &node, const CReadArcItem &item, bool &include)
{ {

View File

@@ -73,18 +73,40 @@ struct CInFileStreamVol: public CInFileStream
} }
}; };
// from ArchiveExtractCallback.cpp
bool IsSafePath(const UString &path);
STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStream) STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStream)
{ {
COM_TRY_BEGIN COM_TRY_BEGIN
*inStream = NULL; *inStream = NULL;
if (_subArchiveMode) if (_subArchiveMode)
return S_FALSE; return S_FALSE;
if (Callback) if (Callback)
{ {
RINOK(Callback->Open_CheckBreak()); RINOK(Callback->Open_CheckBreak());
} }
UString name2 = name;
#ifndef _SFX
#ifdef _WIN32
name2.Replace(L'/', WCHAR_PATH_SEPARATOR);
#endif
// if (!allowAbsVolPaths)
if (!IsSafePath(name2))
return S_FALSE;
#endif
FString fullPath; FString fullPath;
if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name), fullPath)) if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name2), fullPath))
return S_FALSE; return S_FALSE;
if (!_fileInfo.Find(fullPath)) if (!_fileInfo.Find(fullPath))
return S_FALSE; return S_FALSE;
@@ -93,10 +115,15 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre
CInFileStreamVol *inFile = new CInFileStreamVol; CInFileStreamVol *inFile = new CInFileStreamVol;
CMyComPtr<IInStream> inStreamTemp = inFile; CMyComPtr<IInStream> inStreamTemp = inFile;
if (!inFile->Open(fullPath)) if (!inFile->Open(fullPath))
return ::GetLastError(); {
DWORD lastError = ::GetLastError();
if (lastError == 0)
return E_FAIL;
return HRESULT_FROM_WIN32(lastError);
}
FileSizes.Add(_fileInfo.Size); FileSizes.Add(_fileInfo.Size);
FileNames.Add(name); FileNames.Add(name2);
inFile->FileNameIndex = FileNames_WasUsed.Add(true); inFile->FileNameIndex = FileNames_WasUsed.Add(true);
inFile->OpenCallbackImp = this; inFile->OpenCallbackImp = this;
inFile->OpenCallbackRef = this; inFile->OpenCallbackRef = this;

View File

@@ -32,9 +32,7 @@
#include "../../../../C/Alloc.h" #include "../../../../C/Alloc.h"
#include "../../../../C/CpuArch.h" #include "../../../../C/CpuArch.h"
#if defined(_WIN32)
#include "../../../Windows/System.h" #include "../../../Windows/System.h"
#endif
#ifndef _7ZIP_ST #ifndef _7ZIP_ST
#include "../../../Windows/Synchronization.h" #include "../../../Windows/Synchronization.h"
@@ -1860,11 +1858,15 @@ static void PrintTotals(IBenchPrintCallback &f, bool showFreq, UInt64 cpuFreq, c
PrintResults(f, res.Usage / numIterations2, res.RPU / numIterations2, res.Rating / numIterations2, showFreq, cpuFreq); PrintResults(f, res.Usage / numIterations2, res.RPU / numIterations2, res.Rating / numIterations2, showFreq, cpuFreq);
} }
static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads) static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString,
bool size_Defined, UInt64 size, const char *threadsString, UInt32 numThreads)
{ {
f.Print("RAM "); f.Print("RAM ");
f.Print(sizeString); f.Print(sizeString);
PrintNumber(f, (size >> 20), 6); if (size_Defined)
PrintNumber(f, (size >> 20), 6);
else
f.Print(" ?");
f.Print(" MB, # "); f.Print(" MB, # ");
f.Print(threadsString); f.Print(threadsString);
PrintNumber(f, numThreads, 3); PrintNumber(f, numThreads, 3);
@@ -2450,15 +2452,13 @@ HRESULT Bench(
return S_FALSE; return S_FALSE;
UInt32 numCPUs = 1; UInt32 numCPUs = 1;
UInt64 ramSize = (UInt64)512 << 20; UInt64 ramSize = (UInt64)(sizeof(size_t)) << 29;
#ifndef _7ZIP_ST #ifndef _7ZIP_ST
numCPUs = NSystem::GetNumberOfProcessors(); numCPUs = NSystem::GetNumberOfProcessors();
#endif #endif
#if defined(_WIN32) bool ramSize_Defined = NSystem::GetRamSize(ramSize);
ramSize = NSystem::GetRamSize();
#endif
UInt32 numThreadsSpecified = numCPUs; UInt32 numThreadsSpecified = numCPUs;
@@ -2640,7 +2640,7 @@ HRESULT Bench(
{ {
printCallback->NewLine(); printCallback->NewLine();
printCallback->NewLine(); printCallback->NewLine();
PrintRequirements(*printCallback, "size: ", ramSize, "CPU hardware threads:", numCPUs); PrintRequirements(*printCallback, "size: ", ramSize_Defined, ramSize, "CPU hardware threads:", numCPUs);
} }
if (numThreadsSpecified < 1 || numThreadsSpecified > kNumThreadsMax) if (numThreadsSpecified < 1 || numThreadsSpecified > kNumThreadsMax)
@@ -2834,6 +2834,7 @@ HRESULT Bench(
dicSizeLog = (UInt64)1 << 20; dicSizeLog = (UInt64)1 << 20;
#endif #endif
if (ramSize_Defined)
for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--) for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog), totalBenchMode) + (8 << 20) <= ramSize) if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog), totalBenchMode) + (8 << 20) <= ramSize)
break; break;
@@ -2848,7 +2849,7 @@ HRESULT Bench(
} }
} }
PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dict, totalBenchMode), "Benchmark threads: ", numThreads); PrintRequirements(f, "usage:", true, GetBenchMemoryUsage(numThreads, dict, totalBenchMode), "Benchmark threads: ", numThreads);
f.NewLine(); f.NewLine();

View File

@@ -142,14 +142,16 @@ void ConvertPropertyToShortString(char *dest, const PROPVARIANT &prop, PROPID pr
case kpidVa: case kpidVa:
{ {
UInt64 v = 0; UInt64 v = 0;
if (ConvertPropVariantToUInt64(prop, v)) if (prop.vt == VT_UI4)
{ v = prop.ulVal;
dest[0] = '0'; else if (prop.vt == VT_UI8)
dest[1] = 'x'; v = (UInt64)prop.uhVal.QuadPart;
ConvertUInt64ToHex(prop.ulVal, dest + 2); else
return; break;
} dest[0] = '0';
break; dest[1] = 'x';
ConvertUInt64ToHex(v, dest + 2);
return;
} }
} }

View File

@@ -14,8 +14,10 @@ static int CompareStrings(const unsigned *p1, const unsigned *p2, void *param)
void SortFileNames(const UStringVector &strings, CUIntVector &indices) void SortFileNames(const UStringVector &strings, CUIntVector &indices)
{ {
unsigned numItems = strings.Size(); const unsigned numItems = strings.Size();
indices.ClearAndSetSize(numItems); indices.ClearAndSetSize(numItems);
if (numItems == 0)
return;
unsigned *vals = &indices[0]; unsigned *vals = &indices[0];
for (unsigned i = 0; i < numItems; i++) for (unsigned i = 0; i < numItems; i++)
vals[i] = i; vals[i] = i;

View File

@@ -17,5 +17,3 @@ void CTempFiles::Clear()
Paths.DeleteBack(); Paths.DeleteBack();
} }
} }

View File

@@ -757,4 +757,3 @@ void CArchiveUpdateCallback::InFileStream_On_Destroy(UINT_PTR val)
} }
throw 20141125; throw 20141125;
} }

View File

@@ -92,6 +92,7 @@ void GetUpdatePairInfoList(
{ {
arcIndices.ClearAndSetSize(numArcItems); arcIndices.ClearAndSetSize(numArcItems);
if (numArcItems != 0)
{ {
unsigned *vals = &arcIndices[0]; unsigned *vals = &arcIndices[0];
for (unsigned i = 0; i < numArcItems; i++) for (unsigned i = 0; i < numArcItems; i++)

View File

@@ -17,7 +17,7 @@ FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FStr
{ {
NWorkDir::NMode::EEnum mode = workDirInfo.Mode; NWorkDir::NMode::EEnum mode = workDirInfo.Mode;
#ifndef UNDER_CE #if defined(_WIN32) && !defined(UNDER_CE)
if (workDirInfo.ForRemovableOnly) if (workDirInfo.ForRemovableOnly)
{ {
mode = NWorkDir::NMode::kCurrent; mode = NWorkDir::NMode::kCurrent;

View File

@@ -33,3 +33,4 @@ UI_COMMON_OBJS = \
$O\UpdatePair.obj \ $O\UpdatePair.obj \
$O\UpdateProduce.obj \ $O\UpdateProduce.obj \
#

View File

@@ -4,11 +4,13 @@
#include "../../../Common/MyWindows.h" #include "../../../Common/MyWindows.h"
#ifdef _WIN32
#include <Psapi.h> #include <Psapi.h>
#endif
#include "../../../../C/CpuArch.h" #include "../../../../C/CpuArch.h"
#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES) #if defined( _7ZIP_LARGE_PAGES)
#include "../../../../C/Alloc.h" #include "../../../../C/Alloc.h"
#endif #endif
@@ -470,7 +472,7 @@ static void PrintHexId(CStdOutStream &so, UInt64 id)
int Main2( int Main2(
#ifndef _WIN32 #ifndef _WIN32
int numArgs, const char *args[] int numArgs, char *args[]
#endif #endif
) )
{ {

View File

@@ -20,7 +20,7 @@ CStdOutStream *g_ErrStream = NULL;
extern int Main2( extern int Main2(
#ifndef _WIN32 #ifndef _WIN32
int numArgs, const char *args[] int numArgs, char *args[]
#endif #endif
); );
@@ -49,7 +49,7 @@ static void PrintError(const char *message)
int MY_CDECL main int MY_CDECL main
( (
#ifndef _WIN32 #ifndef _WIN32
int numArgs, const char *args[] int numArgs, char *args[]
#endif #endif
) )
{ {

View File

@@ -3,11 +3,6 @@
#ifndef __STDAFX_H #ifndef __STDAFX_H
#define __STDAFX_H #define __STDAFX_H
// #define _CRT_SECURE_NO_DEPRECATE
// #include <windows.h>
// #include <stdio.h>
#include "../../../Common/Common.h" #include "../../../Common/Common.h"
#endif #endif

View File

@@ -42,6 +42,7 @@ using namespace NFind;
#define MENU_HEIGHT 26 #define MENU_HEIGHT 26
bool g_RAM_Size_Defined;
UInt64 g_RAM_Size; UInt64 g_RAM_Size;
#ifdef _WIN32 #ifdef _WIN32
@@ -425,7 +426,7 @@ static void ErrorMessage(const wchar_t *s)
static int WINAPI WinMain2(int nCmdShow) static int WINAPI WinMain2(int nCmdShow)
{ {
g_RAM_Size = NSystem::GetRamSize(); g_RAM_Size_Defined = NSystem::GetRamSize(g_RAM_Size);
#ifdef _WIN32 #ifdef _WIN32

View File

@@ -69,31 +69,67 @@ struct CPanelCallback
void PanelCopyItems(); void PanelCopyItems();
struct CItemProperty
struct CPropColumn
{ {
UString Name; int Order;
PROPID ID; PROPID ID;
VARTYPE Type; VARTYPE Type;
int Order;
bool IsVisible; bool IsVisible;
bool IsRawProp; bool IsRawProp;
UInt32 Width; UInt32 Width;
UString Name;
int Compare(const CItemProperty &a) const { return MyCompare(Order, a.Order); } bool IsEqualTo(const CPropColumn &a) const
{
return Order == a.Order
&& ID == a.ID
&& Type == a.Type
&& IsVisible == a.IsVisible
&& IsRawProp == a.IsRawProp
&& Width == a.Width
&& Name == a.Name;
}
int Compare(const CPropColumn &a) const { return MyCompare(Order, a.Order); }
int Compare_NameFirst(const CPropColumn &a) const
{
if (ID == kpidName)
{
if (a.ID != kpidName)
return -1;
}
else if (a.ID == kpidName)
return 1;
return MyCompare(Order, a.Order);
}
}; };
class CItemProperties: public CObjectVector<CItemProperty>
class CPropColumns: public CObjectVector<CPropColumn>
{ {
public: public:
int FindItemWithID(PROPID id) int FindItem_for_PropID(PROPID id) const
{ {
FOR_VECTOR (i, (*this)) FOR_VECTOR (i, (*this))
if ((*this)[i].ID == id) if ((*this)[i].ID == id)
return i; return i;
return -1; return -1;
} }
bool IsEqualTo(const CPropColumns &props) const
{
if (Size() != props.Size())
return false;
FOR_VECTOR (i, (*this))
if (!(*this)[i].IsEqualTo(props[i]))
return false;
return true;
}
}; };
struct CTempFileInfo struct CTempFileInfo
{ {
UInt32 FileIndex; // index of file in folder UInt32 FileIndex; // index of file in folder
@@ -284,8 +320,8 @@ private:
void ChangeWindowSize(int xSize, int ySize); void ChangeWindowSize(int xSize, int ySize);
HRESULT InitColumns(); HRESULT InitColumns();
// void InitColumns2(PROPID sortID); void DeleteColumn(unsigned index);
void InsertColumn(unsigned index); void AddColumn(const CPropColumn &prop);
void SetFocusedSelectedItem(int index, bool select); void SetFocusedSelectedItem(int index, bool select);
HRESULT RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused, HRESULT RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
@@ -446,7 +482,6 @@ public:
void SetFocusToLastRememberedItem(); void SetFocusToLastRememberedItem();
void ReadListViewInfo();
void SaveListViewInfo(); void SaveListViewInfo();
CPanel() : CPanel() :
@@ -484,8 +519,9 @@ public:
bool _needSaveInfo; bool _needSaveInfo;
UString _typeIDString; UString _typeIDString;
CListViewInfo _listViewInfo; CListViewInfo _listViewInfo;
CItemProperties _properties;
CItemProperties _visibleProperties; CPropColumns _columns;
CPropColumns _visibleColumns;
PROPID _sortID; PROPID _sortID;
// int _sortIndex; // int _sortIndex;

View File

@@ -36,6 +36,7 @@ using namespace NSynchronization;
using namespace NFile; using namespace NFile;
using namespace NDir; using namespace NDir;
extern bool g_RAM_Size_Defined;
extern UInt64 g_RAM_Size; extern UInt64 g_RAM_Size;
#ifndef _UNICODE #ifndef _UNICODE
@@ -1173,7 +1174,10 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
{ {
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
_folder->GetProperty(index, kpidSize, &prop); _folder->GetProperty(index, kpidSize, &prop);
UInt64 fileLimit = g_RAM_Size / 4; UInt64 fileLimit = 1 << 22;
if (g_RAM_Size_Defined)
fileLimit = g_RAM_Size / 4;
UInt64 fileSize = 0; UInt64 fileSize = 0;
if (!ConvertPropVariantToUInt64(prop, fileSize)) if (!ConvertPropVariantToUInt64(prop, fileSize))
fileSize = fileLimit; fileSize = fileLimit;

View File

@@ -82,15 +82,33 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType)
} }
} }
static int ItemProperty_Compare_NameFirst(void *const *a1, void *const *a2, void * /* param */)
{
return (*(*((const CPropColumn **)a1))).Compare_NameFirst(*(*((const CPropColumn **)a2)));
}
HRESULT CPanel::InitColumns() HRESULT CPanel::InitColumns()
{ {
if (_needSaveInfo) SaveListViewInfo();
SaveListViewInfo();
_listView.DeleteAllItems(); _listView.DeleteAllItems();
_selectedStatusVector.Clear(); _selectedStatusVector.Clear();
ReadListViewInfo(); {
// ReadListViewInfo();
const UString oldType = _typeIDString;
_typeIDString = GetFolderTypeID();
// an empty _typeIDString is allowed.
// we read registry only for new FolderTypeID
if (!_needSaveInfo || _typeIDString != oldType)
_listViewInfo.Read(_typeIDString);
// folders with same FolderTypeID can have different columns
// so we still read columns for that case.
// if (_needSaveInfo && _typeIDString == oldType) return S_OK;
}
// PROPID sortID; // PROPID sortID;
/* /*
@@ -101,9 +119,8 @@ HRESULT CPanel::InitColumns()
_ascending = _listViewInfo.Ascending; _ascending = _listViewInfo.Ascending;
_properties.Clear(); _columns.Clear();
_needSaveInfo = true;
bool isFsFolder = IsFSFolder() || IsAltStreamsFolder(); bool isFsFolder = IsFSFolder() || IsAltStreamsFolder();
{ {
@@ -125,7 +142,7 @@ HRESULT CPanel::InitColumns()
} }
if (propID == kpidIsDir) if (propID == kpidIsDir)
continue; continue;
CItemProperty prop; CPropColumn prop;
prop.Type = varType; prop.Type = varType;
prop.ID = propID; prop.ID = propID;
prop.Name = GetNameOfProperty(propID, name); prop.Name = GetNameOfProperty(propID, name);
@@ -133,7 +150,7 @@ HRESULT CPanel::InitColumns()
prop.IsVisible = GetColumnVisible(propID, isFsFolder); prop.IsVisible = GetColumnVisible(propID, isFsFolder);
prop.Width = GetColumnWidth(propID, varType); prop.Width = GetColumnWidth(propID, varType);
prop.IsRawProp = false; prop.IsRawProp = false;
_properties.Add(prop); _columns.Add(prop);
} }
} }
@@ -141,13 +158,15 @@ HRESULT CPanel::InitColumns()
{ {
UInt32 numProps; UInt32 numProps;
_folderRawProps->GetNumRawProps(&numProps); _folderRawProps->GetNumRawProps(&numProps);
for (UInt32 i = 0; i < numProps; i++) for (UInt32 i = 0; i < numProps; i++)
{ {
CMyComBSTR name; CMyComBSTR name;
PROPID propID; PROPID propID;
RINOK(_folderRawProps->GetRawPropInfo(i, &name, &propID)); HRESULT res = _folderRawProps->GetRawPropInfo(i, &name, &propID);
if (res != S_OK)
CItemProperty prop; continue;
CPropColumn prop;
prop.Type = VT_EMPTY; prop.Type = VT_EMPTY;
prop.ID = propID; prop.ID = propID;
prop.Name = GetNameOfProperty(propID, name); prop.Name = GetNameOfProperty(propID, name);
@@ -155,83 +174,147 @@ HRESULT CPanel::InitColumns()
prop.IsVisible = GetColumnVisible(propID, isFsFolder); prop.IsVisible = GetColumnVisible(propID, isFsFolder);
prop.Width = GetColumnWidth(propID, VT_BSTR);; prop.Width = GetColumnWidth(propID, VT_BSTR);;
prop.IsRawProp = true; prop.IsRawProp = true;
_properties.Add(prop); _columns.Add(prop);
} }
} }
// InitColumns2(sortID);
for (;;)
if (!_listView.DeleteColumn(0))
break;
unsigned order = 0; unsigned order = 0;
unsigned i; unsigned i;
for (i = 0; i < _listViewInfo.Columns.Size(); i++) for (i = 0; i < _listViewInfo.Columns.Size(); i++)
{ {
const CColumnInfo &columnInfo = _listViewInfo.Columns[i]; const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
int index = _properties.FindItemWithID(columnInfo.PropID); int index = _columns.FindItem_for_PropID(columnInfo.PropID);
if (index >= 0) if (index >= 0)
{ {
CItemProperty &item = _properties[index]; CPropColumn &item = _columns[index];
item.IsVisible = columnInfo.IsVisible; if (item.Order >= 0)
continue; // we ignore duplicated items
bool isVisible = columnInfo.IsVisible;
// we enable kpidName, if it was disabled by some incorrect code
if (columnInfo.PropID == kpidName)
isVisible = true;
item.IsVisible = isVisible;
item.Width = columnInfo.Width; item.Width = columnInfo.Width;
if (columnInfo.IsVisible) if (isVisible)
item.Order = order++; item.Order = order++;
continue; continue;
} }
} }
for (i = 0; i < _properties.Size(); i++) for (i = 0; i < _columns.Size(); i++)
{ {
CItemProperty &item = _properties[i]; CPropColumn &item = _columns[i];
if (item.IsVisible && item.Order < 0)
item.Order = order++;
}
for (i = 0; i < _columns.Size(); i++)
{
CPropColumn &item = _columns[i];
if (item.Order < 0) if (item.Order < 0)
item.Order = order++; item.Order = order++;
} }
_visibleProperties.Clear(); CPropColumns newColumns;
for (i = 0; i < _properties.Size(); i++)
for (i = 0; i < _columns.Size(); i++)
{ {
const CItemProperty &prop = _properties[i]; const CPropColumn &prop = _columns[i];
if (prop.IsVisible) if (prop.IsVisible)
_visibleProperties.Add(prop); newColumns.Add(prop);
} }
// _sortIndex = 0;
_sortID = kpidName;
/* /*
_sortIndex = 0;
if (_listViewInfo.SortIndex >= 0) if (_listViewInfo.SortIndex >= 0)
{ {
int sortIndex = _properties.FindItemWithID(sortID); int sortIndex = _columns.FindItem_for_PropID(sortID);
if (sortIndex >= 0) if (sortIndex >= 0)
_sortIndex = sortIndex; _sortIndex = sortIndex;
} }
*/ */
_sortID = _listViewInfo.SortID;
_visibleProperties.Sort(); if (_listViewInfo.IsLoaded)
_sortID = _listViewInfo.SortID;
else
{
_sortID = 0;
if (IsFSFolder() || IsAltStreamsFolder() || IsArcFolder())
_sortID = kpidName;
}
for (i = 0; i < _visibleProperties.Size(); i++) /* There are restrictions in ListView control:
InsertColumn(i); 1) main column (kpidName) must have (LV_COLUMNW::iSubItem = 0)
So we need special sorting for columns.
2) when we add new column, LV_COLUMNW::iOrder can not be larger than already inserted columns)
So we set column order after all columns are added.
*/
newColumns.Sort(ItemProperty_Compare_NameFirst, NULL);
if (newColumns.IsEqualTo(_visibleColumns))
return S_OK;
CIntArr columns(newColumns.Size());
for (i = 0; i < newColumns.Size(); i++)
columns[i] = -1;
bool orderError = false;
for (i = 0; i < newColumns.Size(); i++)
{
const CPropColumn &prop = newColumns[i];
if (prop.Order < (int)newColumns.Size() && columns[prop.Order] == -1)
columns[prop.Order] = i;
else
orderError = true;
}
for (;;)
{
unsigned numColumns = _visibleColumns.Size();
if (numColumns == 0)
break;
DeleteColumn(numColumns - 1);
}
for (i = 0; i < newColumns.Size(); i++)
AddColumn(newColumns[i]);
// columns[0], columns[1], .... should be displayed from left to right:
if (!orderError)
_listView.SetColumnOrderArray(_visibleColumns.Size(), columns);
_needSaveInfo = true;
return S_OK; return S_OK;
} }
void CPanel::InsertColumn(unsigned index)
void CPanel::DeleteColumn(unsigned index)
{ {
const CItemProperty &prop = _visibleProperties[index]; _visibleColumns.Delete(index);
_listView.DeleteColumn(index);
}
void CPanel::AddColumn(const CPropColumn &prop)
{
const int index = _visibleColumns.Size();
LV_COLUMNW column; LV_COLUMNW column;
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER; column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
column.cx = prop.Width; column.cx = prop.Width;
column.fmt = GetColumnAlign(prop.ID, prop.Type); column.fmt = GetColumnAlign(prop.ID, prop.Type);
column.iOrder = prop.Order; column.iOrder = index; // must be <= _listView.ItemCount
// iOrder must be <= _listView.ItemCount column.iSubItem = index; // must be <= _listView.ItemCount
column.iSubItem = index;
column.pszText = const_cast<wchar_t *>((const wchar_t *)prop.Name); column.pszText = const_cast<wchar_t *>((const wchar_t *)prop.Name);
_visibleColumns.Add(prop);
_listView.InsertColumn(index, &column); _listView.InsertColumn(index, &column);
} }
HRESULT CPanel::RefreshListCtrl() HRESULT CPanel::RefreshListCtrl()
{ {
return RefreshListCtrl(UString(), -1, true, UStringVector()); return RefreshListCtrl(UString(), -1, true, UStringVector());
@@ -959,20 +1042,17 @@ UInt64 CPanel::GetItemSize(int itemIndex) const
return 0; return 0;
} }
void CPanel::ReadListViewInfo()
{
_typeIDString = GetFolderTypeID();
if (!_typeIDString.IsEmpty())
_listViewInfo.Read(_typeIDString);
}
void CPanel::SaveListViewInfo() void CPanel::SaveListViewInfo()
{ {
if (!_needSaveInfo)
return;
unsigned i; unsigned i;
for (i = 0; i < _visibleProperties.Size(); i++) for (i = 0; i < _visibleColumns.Size(); i++)
{ {
CItemProperty &prop = _visibleProperties[i]; CPropColumn &prop = _visibleColumns[i];
LVCOLUMN winColumnInfo; LVCOLUMN winColumnInfo;
winColumnInfo.mask = LVCF_ORDER | LVCF_WIDTH; winColumnInfo.mask = LVCF_ORDER | LVCF_WIDTH;
if (!_listView.GetColumn(i, &winColumnInfo)) if (!_listView.GetColumn(i, &winColumnInfo))
@@ -983,14 +1063,18 @@ void CPanel::SaveListViewInfo()
CListViewInfo viewInfo; CListViewInfo viewInfo;
// PROPID sortPropID = _properties[_sortIndex].ID; // PROPID sortPropID = _columns[_sortIndex].ID;
PROPID sortPropID = _sortID; PROPID sortPropID = _sortID;
_visibleProperties.Sort(); // we save columns as "sorted by order" to registry
CPropColumns sortedProperties = _visibleColumns;
sortedProperties.Sort();
for (i = 0; i < _visibleProperties.Size(); i++) for (i = 0; i < sortedProperties.Size(); i++)
{ {
const CItemProperty &prop = _visibleProperties[i]; const CPropColumn &prop = sortedProperties[i];
CColumnInfo columnInfo; CColumnInfo columnInfo;
columnInfo.IsVisible = prop.IsVisible; columnInfo.IsVisible = prop.IsVisible;
columnInfo.PropID = prop.ID; columnInfo.PropID = prop.ID;
@@ -998,13 +1082,13 @@ void CPanel::SaveListViewInfo()
viewInfo.Columns.Add(columnInfo); viewInfo.Columns.Add(columnInfo);
} }
for (i = 0; i < _properties.Size(); i++) for (i = 0; i < _columns.Size(); i++)
{ {
const CItemProperty &prop = _properties[i]; const CPropColumn &prop = _columns[i];
if (!prop.IsVisible) if (sortedProperties.FindItem_for_PropID(prop.ID) < 0)
{ {
CColumnInfo columnInfo; CColumnInfo columnInfo;
columnInfo.IsVisible = prop.IsVisible; columnInfo.IsVisible = false;
columnInfo.PropID = prop.ID; columnInfo.PropID = prop.ID;
columnInfo.Width = prop.Width; columnInfo.Width = prop.Width;
viewInfo.Columns.Add(columnInfo); viewInfo.Columns.Add(columnInfo);
@@ -1013,6 +1097,7 @@ void CPanel::SaveListViewInfo()
viewInfo.SortID = sortPropID; viewInfo.SortID = sortPropID;
viewInfo.Ascending = _ascending; viewInfo.Ascending = _ascending;
viewInfo.IsLoaded = true;
if (!_listViewInfo.IsEqual(viewInfo)) if (!_listViewInfo.IsEqual(viewInfo))
{ {
viewInfo.Save(_typeIDString); viewInfo.Save(_typeIDString);
@@ -1040,9 +1125,9 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
menu.CreatePopup(); menu.CreatePopup();
const int kCommandStart = 100; const int kCommandStart = 100;
FOR_VECTOR (i, _properties) FOR_VECTOR (i, _columns)
{ {
const CItemProperty &prop = _properties[i]; const CPropColumn &prop = _columns[i];
UINT flags = MF_STRING; UINT flags = MF_STRING;
if (prop.IsVisible) if (prop.IsVisible)
flags |= MF_CHECKED; flags |= MF_CHECKED;
@@ -1053,25 +1138,22 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView); int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView);
if (menuResult >= kCommandStart && menuResult <= kCommandStart + (int)_properties.Size()) if (menuResult >= kCommandStart && menuResult <= kCommandStart + (int)_columns.Size())
{ {
int index = menuResult - kCommandStart; int index = menuResult - kCommandStart;
CItemProperty &prop = _properties[index]; CPropColumn &prop = _columns[index];
prop.IsVisible = !prop.IsVisible; prop.IsVisible = !prop.IsVisible;
if (prop.IsVisible) if (prop.IsVisible)
{ {
unsigned num = _visibleProperties.Size(); prop.Order = _visibleColumns.Size();
prop.Order = num; AddColumn(prop);
_visibleProperties.Add(prop);
InsertColumn(num);
} }
else else
{ {
int visibleIndex = _visibleProperties.FindItemWithID(prop.ID); int visibleIndex = _visibleColumns.FindItem_for_PropID(prop.ID);
if (visibleIndex >= 0) if (visibleIndex >= 0)
{ {
_visibleProperties.Delete(visibleIndex);
/* /*
if (_sortIndex == index) if (_sortIndex == index)
{ {
@@ -1084,8 +1166,7 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
_sortID = kpidName; _sortID = kpidName;
_ascending = true; _ascending = true;
} }
DeleteColumn(visibleIndex);
_listView.DeleteColumn(visibleIndex);
} }
} }
} }

View File

@@ -175,7 +175,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
if (item.cchTextMax <= 1) if (item.cchTextMax <= 1)
return 0; return 0;
const CItemProperty &property = _visibleProperties[item.iSubItem]; const CPropColumn &property = _visibleColumns[item.iSubItem];
PROPID propID = property.ID; PROPID propID = property.ID;
if (realIndex == kParentIndex) if (realIndex == kParentIndex)

View File

@@ -83,9 +83,9 @@ static inline const wchar_t *GetExtensionPtr(const UString &name)
void CPanel::SetSortRawStatus() void CPanel::SetSortRawStatus()
{ {
_isRawSortProp = false; _isRawSortProp = false;
FOR_VECTOR (i, _properties) FOR_VECTOR (i, _columns)
{ {
const CItemProperty &prop = _properties[i]; const CPropColumn &prop = _columns[i];
if (prop.ID == _sortID) if (prop.ID == _sortID)
{ {
_isRawSortProp = prop.IsRawProp ? 1 : 0; _isRawSortProp = prop.IsRawProp ? 1 : 0;
@@ -169,7 +169,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
return ::CompareFileTime(&file1.MTime, &file2.MTime); return ::CompareFileTime(&file1.MTime, &file2.MTime);
*/ */
// PROPID propID = panel->_properties[panel->_sortIndex].ID; // PROPID propID = panel->_columns[panel->_sortIndex].ID;
NCOM::CPropVariant prop1, prop2; NCOM::CPropVariant prop1, prop2;
// Name must be first property // Name must be first property
@@ -215,7 +215,7 @@ void CPanel::SortItems(int index)
{ {
_sortIndex = index; _sortIndex = index;
_ascending = true; _ascending = true;
switch (_properties[_sortIndex].ID) switch (_columns[_sortIndex].ID)
{ {
case kpidSize: case kpidSize:
case kpidPackedSize: case kpidPackedSize:
@@ -229,13 +229,15 @@ void CPanel::SortItems(int index)
_listView.SortItems(CompareItems, (LPARAM)this); _listView.SortItems(CompareItems, (LPARAM)this);
_listView.EnsureVisible(_listView.GetFocusedItem(), false); _listView.EnsureVisible(_listView.GetFocusedItem(), false);
} }
void CPanel::SortItemsWithPropID(PROPID propID) void CPanel::SortItemsWithPropID(PROPID propID)
{ {
int index = _properties.FindItemWithID(propID); int index = _columns.FindItem_for_PropID(propID);
if (index >= 0) if (index >= 0)
SortItems(index); SortItems(index);
} }
*/ */
void CPanel::SortItemsWithPropID(PROPID propID) void CPanel::SortItemsWithPropID(PROPID propID)
{ {
if (propID == _sortID) if (propID == _sortID)
@@ -264,8 +266,8 @@ void CPanel::SortItemsWithPropID(PROPID propID)
void CPanel::OnColumnClick(LPNMLISTVIEW info) void CPanel::OnColumnClick(LPNMLISTVIEW info)
{ {
/* /*
int index = _properties.FindItemWithID(_visibleProperties[info->iSubItem].ID); int index = _columns.FindItem_for_PropID(_visibleColumns[info->iSubItem].ID);
SortItems(index); SortItems(index);
*/ */
SortItemsWithPropID(_visibleProperties[info->iSubItem].ID); SortItemsWithPropID(_visibleColumns[info->iSubItem].ID);
} }

View File

@@ -164,4 +164,4 @@ bool ReadFlatView(UInt32 panelIndex) { return ReadOption(GetFlatViewName(panelIn
/* /*
void Save_ShowDeleted(bool enable) { SaveOption(kShowDeletedFiles, enable); } void Save_ShowDeleted(bool enable) { SaveOption(kShowDeletedFiles, enable); }
bool Read_ShowDeleted() { return ReadOption(kShowDeletedFiles, false); } bool Read_ShowDeleted() { return ReadOption(kShowDeletedFiles, false); }
*/ */

View File

@@ -252,4 +252,4 @@ int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName)
{ {
return GetIconIndex(attrib, fileName, NULL); return GetIconIndex(attrib, fileName, NULL);
} }
*/ */

View File

@@ -97,6 +97,8 @@ void CListViewInfo::Read(const UString &id)
Get32(buf + 4, SortID); Get32(buf + 4, SortID);
GetBool(buf + 8, Ascending); GetBool(buf + 8, Ascending);
IsLoaded = true;
size -= kListViewHeaderSize; size -= kListViewHeaderSize;
if (size % kColumnInfoSize != 0) if (size % kColumnInfoSize != 0)
return; return;

View File

@@ -23,14 +23,22 @@ struct CListViewInfo
CRecordVector<CColumnInfo> Columns; CRecordVector<CColumnInfo> Columns;
PROPID SortID; PROPID SortID;
bool Ascending; bool Ascending;
bool IsLoaded;
void Clear() void Clear()
{ {
SortID = 0; SortID = 0;
Ascending = true; Ascending = true;
IsLoaded = false;
Columns.Clear(); Columns.Clear();
} }
CListViewInfo():
SortID(0),
Ascending(true),
IsLoaded(false)
{}
/* /*
int FindColumnWithID(PROPID propID) const int FindColumnWithID(PROPID propID) const
{ {

View File

@@ -177,7 +177,9 @@ bool CBenchmarkDialog::OnInit()
m_Dictionary.Attach(GetItem(IDC_BENCH_DICTIONARY)); m_Dictionary.Attach(GetItem(IDC_BENCH_DICTIONARY));
cur = 0; cur = 0;
UInt64 ramSize = NSystem::GetRamSize();
UInt64 ramSize = (UInt64)(sizeof(size_t)) << 29;
bool ramSize_Defined = NSystem::GetRamSize(ramSize);
#ifdef UNDER_CE #ifdef UNDER_CE
const UInt32 kNormalizedCeSize = (16 << 20); const UInt32 kNormalizedCeSize = (16 << 20);
@@ -187,8 +189,14 @@ bool CBenchmarkDialog::OnInit()
if (Sync.DictionarySize == (UInt32)(Int32)-1) if (Sync.DictionarySize == (UInt32)(Int32)-1)
{ {
unsigned dicSizeLog; unsigned dicSizeLog = 25;
for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
#ifdef UNDER_CE
dicSizeLog = 20;
#endif
if (ramSize_Defined)
for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
if (GetBenchMemoryUsage(Sync.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize) if (GetBenchMemoryUsage(Sync.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
break; break;
Sync.DictionarySize = (1 << dicSizeLog); Sync.DictionarySize = (1 << dicSizeLog);

View File

@@ -250,9 +250,10 @@ static bool IsMethodSupportedBySfx(int methodID)
return false; return false;
} }
static UInt64 GetMaxRamSizeForProgram() static bool GetMaxRamSizeForProgram(UInt64 &physSize)
{ {
UInt64 physSize = NSystem::GetRamSize(); physSize = (UInt64)(sizeof(size_t)) << 29;
bool ramSize_Defined = NSystem::GetRamSize(physSize);
const UInt64 kMinSysSize = (1 << 24); const UInt64 kMinSysSize = (1 << 24);
if (physSize <= kMinSysSize) if (physSize <= kMinSysSize)
physSize = 0; physSize = 0;
@@ -261,7 +262,7 @@ static UInt64 GetMaxRamSizeForProgram()
const UInt64 kMinUseSize = (1 << 24); const UInt64 kMinUseSize = (1 << 24);
if (physSize < kMinUseSize) if (physSize < kMinUseSize)
physSize = kMinUseSize; physSize = kMinUseSize;
return physSize; return ramSize_Defined;
} }
@@ -1170,7 +1171,8 @@ void CCompressDialog::SetDictionary()
UInt32 level = GetLevel2(); UInt32 level = GetLevel2();
if (methodID < 0) if (methodID < 0)
return; return;
const UInt64 maxRamSize = GetMaxRamSizeForProgram(); UInt64 maxRamSize;
bool maxRamSize_Defined = GetMaxRamSizeForProgram(maxRamSize);
switch (methodID) switch (methodID)
{ {
@@ -1196,18 +1198,20 @@ void CCompressDialog::SetDictionary()
if (i == 20 && j > 0) if (i == 20 && j > 0)
continue; continue;
UInt32 dict = ((UInt32)(2 + j) << (i - 1)); UInt32 dict = ((UInt32)(2 + j) << (i - 1));
if (dict > if (dict >
#ifdef MY_CPU_64BIT #ifdef MY_CPU_64BIT
(3 << 29) (3 << 29)
#else #else
(1 << 26) (1 << 26)
#endif #endif
) )
continue; continue;
AddDictionarySize(dict); AddDictionarySize(dict);
UInt64 decomprSize; UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize); UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
if (dict <= defaultDict && requiredComprSize <= maxRamSize) if (dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
} }
@@ -1242,11 +1246,12 @@ void CCompressDialog::SetDictionary()
AddDictionarySize(dict); AddDictionarySize(dict);
UInt64 decomprSize; UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize); UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
if (dict <= defaultDict && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0) if ((dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
|| m_Dictionary.GetCount() == 1)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
} }
SetNearestSelectComboBox(m_Dictionary, defaultDict); // SetNearestSelectComboBox(m_Dictionary, defaultDict);
break; break;
} }
@@ -1295,11 +1300,12 @@ void CCompressDialog::SetDictionary()
AddDictionarySize(dict); AddDictionarySize(dict);
UInt64 decomprSize; UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize); UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
if (dict <= defaultDict && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0) if ((dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
|| m_Dictionary.GetCount() == 1)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
} }
SetNearestSelectComboBox(m_Dictionary, defaultDict); // SetNearestSelectComboBox(m_Dictionary, defaultDict);
break; break;
} }
} }

View File

@@ -175,6 +175,7 @@ void AddHashBundleRes(UString &s, const CHashBundle &hb, const UString &firstFil
AddValuePair(s, IDS_PROP_NUM_ERRORS, hb.NumErrors); AddValuePair(s, IDS_PROP_NUM_ERRORS, hb.NumErrors);
s.Add_LF(); s.Add_LF();
} }
if (hb.NumFiles == 1 && hb.NumDirs == 0 && !firstFileName.IsEmpty()) if (hb.NumFiles == 1 && hb.NumDirs == 0 && !firstFileName.IsEmpty())
{ {
AddLangString(s, IDS_PROP_NAME); AddLangString(s, IDS_PROP_NAME);
@@ -197,6 +198,12 @@ void AddHashBundleRes(UString &s, const CHashBundle &hb, const UString &firstFil
AddSizeValuePair(s, IDS_PROP_ALT_STREAMS_SIZE, hb.AltStreamsSize); AddSizeValuePair(s, IDS_PROP_ALT_STREAMS_SIZE, hb.AltStreamsSize);
} }
if (hb.NumErrors == 0 && hb.Hashers.IsEmpty())
{
s.Add_LF();
AddLangString(s, IDS_MESSAGE_NO_ERRORS);
}
FOR_VECTOR (i, hb.Hashers) FOR_VECTOR (i, hb.Hashers)
{ {
s.Add_LF(); s.Add_LF();

View File

@@ -257,4 +257,4 @@ void CXml::AppendTo(AString &s) const
{ {
Root.AppendTo(s); Root.AppendTo(s);
} }
*/ */

View File

@@ -109,7 +109,7 @@ void * __cdecl operator new(size_t size)
} }
if (p == 0) if (p == 0)
throw CNewException(); throw CNewException();
printf("Alloc %6d, size = %8d\n", numAllocs, size); printf("Alloc %6d, size = %8u\n", numAllocs, (unsigned)size);
return p; return p;
} }

View File

@@ -12,5 +12,3 @@ public:
}; };
#endif #endif

View File

@@ -185,7 +185,7 @@ static void UnicodeStringToMultiByte2(AString &dest, const UString &src, UINT co
{ {
BOOL defUsed = FALSE; BOOL defUsed = FALSE;
bool isUtf = (codePage == CP_UTF8 || codePage == CP_UTF7); bool isUtf = (codePage == CP_UTF8 || codePage == CP_UTF7);
defaultChar = defaultChar; // defaultChar = defaultChar;
len = WideCharToMultiByte(codePage, 0, src, src.Len(), len = WideCharToMultiByte(codePage, 0, src, src.Len(),
dest.GetBuf(len), len, dest.GetBuf(len), len,
(isUtf ? NULL : &defaultChar), (isUtf ? NULL : &defaultChar),

View File

@@ -17,5 +17,3 @@ int FindTextConfigItem(const CObjectVector<CTextConfigPair> &pairs, const UStrin
UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const UString &id); UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const UString &id);
#endif #endif

View File

@@ -32,6 +32,18 @@ public:
int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); } int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
int InsertColumn(int columnIndex, LPCTSTR text, int width); int InsertColumn(int columnIndex, LPCTSTR text, int width);
bool SetColumnOrderArray(int count, const int *columns) { return BOOLToBool(ListView_SetColumnOrderArray(_window, count, columns)); }
/*
int GetNumColumns()
{
HWND header = ListView_GetHeader(_window);
if (!header)
return -1;
return Header_GetItemCount(header);
}
*/
int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); } int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
int InsertItem(int index, LPCTSTR text); int InsertItem(int index, LPCTSTR text);
bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); } bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }

View File

@@ -10,5 +10,3 @@ void ProcessMessages(HWND window);
} }
#endif #endif

View File

@@ -179,4 +179,3 @@ bool AddLockMemoryPrivilege()
} }
}} }}

View File

@@ -11,6 +11,8 @@
namespace NWindows { namespace NWindows {
namespace NSystem { namespace NSystem {
#ifdef _WIN32
UInt32 GetNumberOfProcessors() UInt32 GetNumberOfProcessors()
{ {
SYSTEM_INFO systemInfo; SYSTEM_INFO systemInfo;
@@ -18,6 +20,18 @@ UInt32 GetNumberOfProcessors()
return (UInt32)systemInfo.dwNumberOfProcessors; return (UInt32)systemInfo.dwNumberOfProcessors;
} }
#else
UInt32 GetNumberOfProcessors()
{
return 1;
}
#endif
#ifdef _WIN32
#ifndef UNDER_CE #ifndef UNDER_CE
#if !defined(_WIN64) && defined(__GNUC__) #if !defined(_WIN64) && defined(__GNUC__)
@@ -45,29 +59,53 @@ typedef BOOL (WINAPI *GlobalMemoryStatusExP)(MY_LPMEMORYSTATUSEX lpBuffer);
#endif #endif
UInt64 GetRamSize() #endif
bool GetRamSize(UInt64 &size)
{ {
size = (UInt64)(sizeof(size_t)) << 29;
#ifdef _WIN32
#ifndef UNDER_CE #ifndef UNDER_CE
MY_MEMORYSTATUSEX stat; MY_MEMORYSTATUSEX stat;
stat.dwLength = sizeof(stat);
#endif
#ifdef _WIN64
if (!::GlobalMemoryStatusEx(&stat))
return 0;
return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
#else
#ifndef UNDER_CE
GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GlobalMemoryStatusEx");
if (globalMemoryStatusEx != 0 && globalMemoryStatusEx(&stat))
return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
#endif
{
MEMORYSTATUS stat;
stat.dwLength = sizeof(stat); stat.dwLength = sizeof(stat);
::GlobalMemoryStatus(&stat); #endif
return MyMin(stat.dwTotalVirtual, stat.dwTotalPhys);
} #ifdef _WIN64
if (!::GlobalMemoryStatusEx(&stat))
return false;
size = MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
return true;
#else
#ifndef UNDER_CE
GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GlobalMemoryStatusEx");
if (globalMemoryStatusEx && globalMemoryStatusEx(&stat))
{
size = MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
return true;
}
#endif
{
MEMORYSTATUS stat2;
stat2.dwLength = sizeof(stat2);
::GlobalMemoryStatus(&stat2);
size = MyMin(stat2.dwTotalVirtual, stat2.dwTotalPhys);
return true;
}
#endif
#else
return false;
#endif #endif
} }

View File

@@ -9,7 +9,8 @@ namespace NWindows {
namespace NSystem { namespace NSystem {
UInt32 GetNumberOfProcessors(); UInt32 GetNumberOfProcessors();
UInt64 GetRamSize();
bool GetRamSize(UInt64 &size); // returns false, if unknown ram size
}} }}

View File

@@ -39,6 +39,8 @@ cmdline\switches\method.htm
cmdline\switches\ar_include.htm cmdline\switches\ar_include.htm
cmdline\switches\ar_exclude.htm cmdline\switches\ar_exclude.htm
cmdline\switches\ar_no.htm cmdline\switches\ar_no.htm
cmdline\switches\bb.htm
cmdline\switches\bs.htm
cmdline\switches\charset.htm cmdline\switches\charset.htm
cmdline\switches\email.htm cmdline\switches\email.htm
cmdline\switches\list_tech.htm cmdline\switches\list_tech.htm
@@ -61,6 +63,7 @@ cmdline\switches\stdin.htm
cmdline\switches\stdout.htm cmdline\switches\stdout.htm
cmdline\switches\stl.htm cmdline\switches\stl.htm
cmdline\switches\stop_switch.htm cmdline\switches\stop_switch.htm
cmdline\switches\stx.htm
cmdline\switches\type.htm cmdline\switches\type.htm
cmdline\switches\update.htm cmdline\switches\update.htm
cmdline\switches\working_dir.htm cmdline\switches\working_dir.htm

View File

@@ -10,8 +10,8 @@ AppName = "7-Zip"
InstallDir = %CE1%\%AppName% InstallDir = %CE1%\%AppName%
[Strings] [Strings]
AppVer = "15.10" AppVer = "15.12"
AppDate = "2015-11-01" AppDate = "2015-11-19"
[CEDevice] [CEDevice]
; ProcessorType = 2577 ; ARM ; ProcessorType = 2577 ; ARM

View File

@@ -2,8 +2,8 @@
;Defines ;Defines
!define VERSION_MAJOR 15 !define VERSION_MAJOR 15
!define VERSION_MINOR 10 !define VERSION_MINOR 12
!define VERSION_POSTFIX_FULL " beta" !define VERSION_POSTFIX_FULL ""
!ifdef WIN64 !ifdef WIN64
!ifdef IA64 !ifdef IA64
!define VERSION_SYS_POSTFIX_FULL " for Windows IA-64" !define VERSION_SYS_POSTFIX_FULL " for Windows IA-64"

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<?define VerMajor = "15" ?> <?define VerMajor = "15" ?>
<?define VerMinor = "10" ?> <?define VerMinor = "12" ?>
<?define VerBuild = "00" ?> <?define VerBuild = "00" ?>
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?> <?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
<?define MmHex = "$(var.VerMajor)$(var.VerMinor)" ?> <?define MmHex = "$(var.VerMajor)$(var.VerMinor)" ?>

View File

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

View File

@@ -1,6 +1,21 @@
HISTORY of the 7-Zip source code HISTORY of the 7-Zip source code
-------------------------------- --------------------------------
15.12 2015-11-19
-------------------------
- The BUG in C version of 7z decoder was fixed:
7zDec.c : SzDecodeLzma2()
7z decoder could mistakenly report about decoding error for some 7z archives
that use LZMA2 compression method.
The probability to get that mistaken decoding error report was about
one error per 16384 solid blocks for solid blocks larger than 16 KB (compressed size).
- The BUG (in 9.26-15.11) in C version of 7z decoder was fixed:
7zArcIn.c : SzReadHeader2()
7z decoder worked incorrectly for 7z archives that contain
empty solid blocks, that can be placed to 7z archive, if some file is
unavailable for reading during archive creation.
15.09 beta 2015-10-16 15.09 beta 2015-10-16
------------------------- -------------------------
- The BUG in LZMA / LZMA2 encoding code was fixed. - The BUG in LZMA / LZMA2 encoding code was fixed.