mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-17 04:11:51 -06:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c8a265a15 | ||
|
|
a663a6deb7 | ||
|
|
6543c28020 |
@@ -1,5 +1,5 @@
|
||||
/* 7zArcIn.c -- 7z Input functions
|
||||
2015-05-16 : Igor Pavlov : Public domain */
|
||||
2015-09-28 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#define MY_VER_MAJOR 15
|
||||
#define MY_VER_MINOR 07
|
||||
#define MY_VER_BUILD 00
|
||||
#define MY_VERSION_NUMBERS "15.07"
|
||||
#define MY_VERSION "15.07 beta"
|
||||
#define MY_DATE "2015-09-17"
|
||||
#define MY_VER_MINOR 10
|
||||
#define MY_VER_BUILD 0
|
||||
#define MY_VERSION_NUMBERS "15.10"
|
||||
#define MY_VERSION "15.10 beta"
|
||||
#define MY_DATE "2015-11-01"
|
||||
#undef MY_COPYRIGHT
|
||||
#undef MY_VERSION_COPYRIGHT_DATE
|
||||
#define MY_AUTHOR_NAME "Igor Pavlov"
|
||||
|
||||
40
C/CpuArch.h
40
C/CpuArch.h
@@ -1,5 +1,5 @@
|
||||
/* CpuArch.h -- CPU specific code
|
||||
2015-08-02: Igor Pavlov : Public domain */
|
||||
2015-10-31: Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __CPU_ARCH_H
|
||||
#define __CPU_ARCH_H
|
||||
@@ -10,13 +10,17 @@ EXTERN_C_BEGIN
|
||||
|
||||
/*
|
||||
MY_CPU_LE means that CPU is LITTLE ENDIAN.
|
||||
If MY_CPU_LE is not defined, we don't know about that property of platform (it can be LITTLE ENDIAN).
|
||||
MY_CPU_BE means that CPU is BIG ENDIAN.
|
||||
If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of platform.
|
||||
|
||||
MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.
|
||||
If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform.
|
||||
*/
|
||||
|
||||
#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__)
|
||||
#if defined(_M_X64) \
|
||||
|| defined(_M_AMD64) \
|
||||
|| defined(__x86_64__) \
|
||||
|| defined(__AMD64__) \
|
||||
|| defined(__amd64__)
|
||||
#define MY_CPU_AMD64
|
||||
#endif
|
||||
|
||||
@@ -52,10 +56,6 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
||||
#define MY_CPU_IA64_LE
|
||||
#endif
|
||||
|
||||
#if defined(MY_CPU_X86_OR_AMD64)
|
||||
#define MY_CPU_LE_UNALIGN
|
||||
#endif
|
||||
|
||||
#if defined(MY_CPU_X86_OR_AMD64) \
|
||||
|| defined(MY_CPU_ARM_LE) \
|
||||
|| defined(MY_CPU_IA64_LE) \
|
||||
@@ -65,7 +65,8 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
||||
|| defined(__AARCH64EL__) \
|
||||
|| defined(__MIPSEL__) \
|
||||
|| defined(__MIPSEL) \
|
||||
|| defined(_MIPSEL)
|
||||
|| defined(_MIPSEL) \
|
||||
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
||||
#define MY_CPU_LE
|
||||
#endif
|
||||
|
||||
@@ -76,7 +77,9 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
||||
|| defined(__MIPSEB__) \
|
||||
|| defined(__MIPSEB) \
|
||||
|| defined(_MIPSEB) \
|
||||
|| defined(__m68k__)
|
||||
|| defined(__m68k__) \
|
||||
|| defined(__s390x__) \
|
||||
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
|
||||
#define MY_CPU_BE
|
||||
#endif
|
||||
|
||||
@@ -85,6 +88,14 @@ Stop_Compiling_Bad_Endian
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MY_CPU_LE
|
||||
#if defined(MY_CPU_X86_OR_AMD64) \
|
||||
/* || defined(__AARCH64EL__) */
|
||||
#define MY_CPU_LE_UNALIGN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MY_CPU_LE_UNALIGN
|
||||
|
||||
#define GetUi16(p) (*(const UInt16 *)(const void *)(p))
|
||||
@@ -128,6 +139,8 @@ Stop_Compiling_Bad_Endian
|
||||
|
||||
#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)
|
||||
|
||||
/* Note: we use bswap instruction, that is unsupported in 386 cpu */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#pragma intrinsic(_byteswap_ulong)
|
||||
@@ -137,6 +150,13 @@ Stop_Compiling_Bad_Endian
|
||||
|
||||
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
|
||||
|
||||
#elif defined(MY_CPU_LE_UNALIGN) && defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||
|
||||
#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))
|
||||
#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))
|
||||
|
||||
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v)
|
||||
|
||||
#else
|
||||
|
||||
#define GetBe32(p) ( \
|
||||
|
||||
20
C/LzFind.c
20
C/LzFind.c
@@ -1,5 +1,5 @@
|
||||
/* LzFind.c -- Match finder for LZ algorithms
|
||||
2015-05-15 : Igor Pavlov : Public domain */
|
||||
2015-10-15 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define kEmptyHashValue 0
|
||||
#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
|
||||
#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
|
||||
#define kNormalizeMask (~(kNormalizeStepMin - 1))
|
||||
#define kNormalizeMask (~(UInt32)(kNormalizeStepMin - 1))
|
||||
#define kMaxHistorySize ((UInt32)7 << 29)
|
||||
|
||||
#define kStartMaxLen 3
|
||||
@@ -60,9 +60,11 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
|
||||
if (p->streamEndWasReached || p->result != SZ_OK)
|
||||
return;
|
||||
|
||||
/* We use (p->streamPos - p->pos) value. (p->streamPos < p->pos) is allowed. */
|
||||
|
||||
if (p->directInput)
|
||||
{
|
||||
UInt32 curSize = 0xFFFFFFFF - p->streamPos;
|
||||
UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos);
|
||||
if (curSize > p->directInputRem)
|
||||
curSize = (UInt32)p->directInputRem;
|
||||
p->directInputRem -= curSize;
|
||||
@@ -97,7 +99,7 @@ void MatchFinder_MoveBlock(CMatchFinder *p)
|
||||
{
|
||||
memmove(p->bufferBase,
|
||||
p->buffer - p->keepSizeBefore,
|
||||
(size_t)(p->streamPos - p->pos + p->keepSizeBefore));
|
||||
(size_t)(p->streamPos - p->pos) + p->keepSizeBefore);
|
||||
p->buffer = p->bufferBase + p->keepSizeBefore;
|
||||
}
|
||||
|
||||
@@ -290,7 +292,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
|
||||
p->posLimit = p->pos + limit;
|
||||
}
|
||||
|
||||
void MatchFinder_Init(CMatchFinder *p)
|
||||
void MatchFinder_Init_2(CMatchFinder *p, int readData)
|
||||
{
|
||||
UInt32 i;
|
||||
UInt32 *hash = p->hash;
|
||||
@@ -303,10 +305,18 @@ void MatchFinder_Init(CMatchFinder *p)
|
||||
p->pos = p->streamPos = p->cyclicBufferSize;
|
||||
p->result = SZ_OK;
|
||||
p->streamEndWasReached = 0;
|
||||
|
||||
if (readData)
|
||||
MatchFinder_ReadBlock(p);
|
||||
|
||||
MatchFinder_SetLimits(p);
|
||||
}
|
||||
|
||||
void MatchFinder_Init(CMatchFinder *p)
|
||||
{
|
||||
MatchFinder_Init_2(p, True);
|
||||
}
|
||||
|
||||
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
|
||||
{
|
||||
return (p->pos - p->historySize - 1) & kNormalizeMask;
|
||||
|
||||
10
C/LzFind.h
10
C/LzFind.h
@@ -1,5 +1,5 @@
|
||||
/* LzFind.h -- Match finder for LZ algorithms
|
||||
2015-05-01 : Igor Pavlov : Public domain */
|
||||
2015-10-15 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __LZ_FIND_H
|
||||
#define __LZ_FIND_H
|
||||
@@ -53,6 +53,11 @@ typedef struct _CMatchFinder
|
||||
|
||||
#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
|
||||
|
||||
#define Inline_MatchFinder_IsFinishedOK(p) \
|
||||
((p)->streamEndWasReached \
|
||||
&& (p)->streamPos == (p)->pos \
|
||||
&& (!(p)->directInput || (p)->directInputRem == 0))
|
||||
|
||||
int MatchFinder_NeedMove(CMatchFinder *p);
|
||||
Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
|
||||
void MatchFinder_MoveBlock(CMatchFinder *p);
|
||||
@@ -98,9 +103,12 @@ typedef struct _IMatchFinder
|
||||
|
||||
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
|
||||
|
||||
void MatchFinder_Init_2(CMatchFinder *p, int readData);
|
||||
void MatchFinder_Init(CMatchFinder *p);
|
||||
|
||||
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
||||
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
||||
|
||||
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
||||
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
||||
|
||||
|
||||
19
C/LzFindMt.c
19
C/LzFindMt.c
@@ -1,5 +1,5 @@
|
||||
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
|
||||
2015-05-03 : Igor Pavlov : Public domain */
|
||||
2015-10-15 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -173,12 +173,12 @@ static void HashThreadFunc(CMatchFinderMt *mt)
|
||||
CriticalSection_Enter(&mt->btSync.cs);
|
||||
CriticalSection_Enter(&mt->hashSync.cs);
|
||||
{
|
||||
const Byte *beforePtr = MatchFinder_GetPointerToCurrentPos(mf);
|
||||
const Byte *afterPtr;
|
||||
const Byte *beforePtr = Inline_MatchFinder_GetPointerToCurrentPos(mf);
|
||||
ptrdiff_t offset;
|
||||
MatchFinder_MoveBlock(mf);
|
||||
afterPtr = MatchFinder_GetPointerToCurrentPos(mf);
|
||||
mt->pointerToCurPos -= beforePtr - afterPtr;
|
||||
mt->buffer -= beforePtr - afterPtr;
|
||||
offset = beforePtr - Inline_MatchFinder_GetPointerToCurrentPos(mf);
|
||||
mt->pointerToCurPos -= offset;
|
||||
mt->buffer -= offset;
|
||||
}
|
||||
CriticalSection_Leave(&mt->btSync.cs);
|
||||
CriticalSection_Leave(&mt->hashSync.cs);
|
||||
@@ -501,8 +501,11 @@ void MatchFinderMt_Init(CMatchFinderMt *p)
|
||||
CMatchFinder *mf = p->MatchFinder;
|
||||
p->btBufPos = p->btBufPosLimit = 0;
|
||||
p->hashBufPos = p->hashBufPosLimit = 0;
|
||||
MatchFinder_Init(mf);
|
||||
p->pointerToCurPos = MatchFinder_GetPointerToCurrentPos(mf);
|
||||
|
||||
/* Init without data reading. We don't want to read data in this thread */
|
||||
MatchFinder_Init_2(mf, False);
|
||||
|
||||
p->pointerToCurPos = Inline_MatchFinder_GetPointerToCurrentPos(mf);
|
||||
p->btNumAvailBytes = 0;
|
||||
p->lzPos = p->historySize + 1;
|
||||
|
||||
|
||||
18
C/Lzma2Enc.c
18
C/Lzma2Enc.c
@@ -1,5 +1,5 @@
|
||||
/* Lzma2Enc.c -- LZMA2 Encoder
|
||||
2015-09-16 : Igor Pavlov : Public domain */
|
||||
2015-10-04 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -479,7 +479,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
|
||||
|
||||
for (i = 0; i < p->props.numBlockThreads; i++)
|
||||
{
|
||||
CLzma2EncInt *t = &p->coders[i];
|
||||
CLzma2EncInt *t = &p->coders[(unsigned)i];
|
||||
if (!t->enc)
|
||||
{
|
||||
t->enc = LzmaEnc_Create(p->alloc);
|
||||
@@ -489,11 +489,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
|
||||
}
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
if (p->props.numBlockThreads <= 1)
|
||||
#endif
|
||||
return Lzma2Enc_EncodeMt1(&p->coders[0], p, outStream, inStream, progress);
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
if (p->props.numBlockThreads > 1)
|
||||
{
|
||||
CMtCallbackImp mtCallback;
|
||||
|
||||
@@ -508,9 +504,17 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
|
||||
|
||||
p->mtCoder.blockSize = p->props.blockSize;
|
||||
p->mtCoder.destBlockSize = p->props.blockSize + (p->props.blockSize >> 10) + 16;
|
||||
if (p->mtCoder.destBlockSize < p->props.blockSize)
|
||||
{
|
||||
p->mtCoder.destBlockSize = (size_t)0 - 1;
|
||||
if (p->mtCoder.destBlockSize < p->props.blockSize)
|
||||
return SZ_ERROR_FAIL;
|
||||
}
|
||||
p->mtCoder.numThreads = p->props.numBlockThreads;
|
||||
|
||||
return MtCoder_Code(&p->mtCoder);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Lzma2Enc_EncodeMt1(&p->coders[0], p, outStream, inStream, progress);
|
||||
}
|
||||
|
||||
55
C/LzmaEnc.c
55
C/LzmaEnc.c
@@ -1,5 +1,5 @@
|
||||
/* LzmaEnc.c -- LZMA Encoder
|
||||
2015-05-15 Igor Pavlov : Public domain */
|
||||
2015-10-15 Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -505,8 +505,8 @@ static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11,
|
||||
|
||||
static void RangeEnc_Construct(CRangeEnc *p)
|
||||
{
|
||||
p->outStream = 0;
|
||||
p->bufBase = 0;
|
||||
p->outStream = NULL;
|
||||
p->bufBase = NULL;
|
||||
}
|
||||
|
||||
#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize)
|
||||
@@ -514,10 +514,10 @@ static void RangeEnc_Construct(CRangeEnc *p)
|
||||
#define RC_BUF_SIZE (1 << 16)
|
||||
static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
|
||||
{
|
||||
if (p->bufBase == 0)
|
||||
if (!p->bufBase)
|
||||
{
|
||||
p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE);
|
||||
if (p->bufBase == 0)
|
||||
if (!p->bufBase)
|
||||
return 0;
|
||||
p->bufLim = p->bufBase + RC_BUF_SIZE;
|
||||
}
|
||||
@@ -1749,15 +1749,15 @@ void LzmaEnc_Construct(CLzmaEnc *p)
|
||||
#endif
|
||||
|
||||
LzmaEnc_InitPriceTables(p->ProbPrices);
|
||||
p->litProbs = 0;
|
||||
p->saveState.litProbs = 0;
|
||||
p->litProbs = NULL;
|
||||
p->saveState.litProbs = NULL;
|
||||
}
|
||||
|
||||
CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)
|
||||
{
|
||||
void *p;
|
||||
p = alloc->Alloc(alloc, sizeof(CLzmaEnc));
|
||||
if (p != 0)
|
||||
if (p)
|
||||
LzmaEnc_Construct((CLzmaEnc *)p);
|
||||
return p;
|
||||
}
|
||||
@@ -1766,8 +1766,8 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
|
||||
{
|
||||
alloc->Free(alloc, p->litProbs);
|
||||
alloc->Free(alloc, p->saveState.litProbs);
|
||||
p->litProbs = 0;
|
||||
p->saveState.litProbs = 0;
|
||||
p->litProbs = NULL;
|
||||
p->saveState.litProbs = NULL;
|
||||
}
|
||||
|
||||
void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
|
||||
@@ -1963,12 +1963,12 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, I
|
||||
|
||||
{
|
||||
unsigned lclp = p->lc + p->lp;
|
||||
if (p->litProbs == 0 || p->saveState.litProbs == 0 || p->lclp != lclp)
|
||||
if (!p->litProbs || !p->saveState.litProbs || p->lclp != lclp)
|
||||
{
|
||||
LzmaEnc_FreeLits(p, alloc);
|
||||
p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb));
|
||||
p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb));
|
||||
if (p->litProbs == 0 || p->saveState.litProbs == 0)
|
||||
if (!p->litProbs || !p->saveState.litProbs)
|
||||
{
|
||||
LzmaEnc_FreeLits(p, alloc);
|
||||
return SZ_ERROR_MEM;
|
||||
@@ -2140,6 +2140,7 @@ void LzmaEnc_Finish(CLzmaEncHandle pp)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ISeqOutStream funcTable;
|
||||
@@ -2169,12 +2170,14 @@ UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
|
||||
return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
|
||||
}
|
||||
|
||||
|
||||
const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
|
||||
{
|
||||
const CLzmaEnc *p = (CLzmaEnc *)pp;
|
||||
return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
|
||||
}
|
||||
|
||||
|
||||
SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
||||
Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
|
||||
{
|
||||
@@ -2209,6 +2212,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
|
||||
{
|
||||
SRes res = SZ_OK;
|
||||
@@ -2222,9 +2226,9 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
|
||||
for (;;)
|
||||
{
|
||||
res = LzmaEnc_CodeOneBlock(p, False, 0, 0);
|
||||
if (res != SZ_OK || p->finished != 0)
|
||||
if (res != SZ_OK || p->finished)
|
||||
break;
|
||||
if (progress != 0)
|
||||
if (progress)
|
||||
{
|
||||
res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc));
|
||||
if (res != SZ_OK)
|
||||
@@ -2234,10 +2238,19 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LzmaEnc_Finish(p);
|
||||
|
||||
/*
|
||||
if (res == S_OK && !Inline_MatchFinder_IsFinishedOK(&p->matchFinderBase))
|
||||
res = SZ_ERROR_FAIL;
|
||||
}
|
||||
*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
|
||||
ISzAlloc *alloc, ISzAlloc *allocBig)
|
||||
{
|
||||
@@ -2245,6 +2258,7 @@ SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *i
|
||||
return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
|
||||
}
|
||||
|
||||
|
||||
SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
|
||||
{
|
||||
CLzmaEnc *p = (CLzmaEnc *)pp;
|
||||
@@ -2272,6 +2286,7 @@ SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
|
||||
SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||
int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
|
||||
{
|
||||
@@ -2280,19 +2295,22 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte
|
||||
|
||||
CSeqOutStreamBuf outStream;
|
||||
|
||||
LzmaEnc_SetInputBuf(p, src, srcLen);
|
||||
|
||||
outStream.funcTable.Write = MyWrite;
|
||||
outStream.data = dest;
|
||||
outStream.rem = *destLen;
|
||||
outStream.overflow = False;
|
||||
|
||||
p->writeEndMark = writeEndMark;
|
||||
|
||||
p->rc.outStream = &outStream.funcTable;
|
||||
|
||||
res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig);
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
res = LzmaEnc_Encode2(p, progress);
|
||||
if (res == SZ_OK && p->nowPos64 != srcLen)
|
||||
res = SZ_ERROR_FAIL;
|
||||
}
|
||||
|
||||
*destLen -= outStream.rem;
|
||||
if (outStream.overflow)
|
||||
@@ -2300,13 +2318,14 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
||||
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
|
||||
{
|
||||
CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
|
||||
SRes res;
|
||||
if (p == 0)
|
||||
if (!p)
|
||||
return SZ_ERROR_MEM;
|
||||
|
||||
res = LzmaEnc_SetProps(p, props);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
/* MtCoder.c -- Multi-thread Coder
|
||||
2010-09-24 : Igor Pavlov : Public domain */
|
||||
2015-10-13 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "MtCoder.h"
|
||||
|
||||
void LoopThread_Construct(CLoopThread *p)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Ppmd7.c -- PPMdH codec
|
||||
2010-03-12 : Igor Pavlov : Public domain
|
||||
2015-09-28 : Igor Pavlov : Public domain
|
||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Ppmd7Enc.c -- PPMdH Encoder
|
||||
2010-03-12 : Igor Pavlov : Public domain
|
||||
2015-09-28 : Igor Pavlov : Public domain
|
||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Ppmd8.c -- PPMdI codec
|
||||
2013-11-12 : Igor Pavlov : Public domain
|
||||
2015-09-28 : Igor Pavlov : Public domain
|
||||
This code is based on PPMd var.I (2002): Dmitry Shkarin : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* 7zipInstall.c - 7-Zip Installer
|
||||
2015-08-04 : Igor Pavlov : Public domain */
|
||||
2015-09-28 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
|
||||
@@ -158,14 +158,6 @@ SOURCE=.\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -350,14 +342,6 @@ SOURCE=..\Common\CoderMixer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\HandlerOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -254,8 +254,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
lps->Init(extractCallback, false);
|
||||
|
||||
CDecoder decoder(
|
||||
#ifndef USE_MIXER_ST
|
||||
#if !defined(USE_MIXER_MT)
|
||||
false
|
||||
#elif !defined(USE_MIXER_ST)
|
||||
true
|
||||
#elif !defined(__7Z_SET_PROPERTIES)
|
||||
#ifdef _7ZIP_ST
|
||||
false
|
||||
#else
|
||||
true
|
||||
#endif
|
||||
#else
|
||||
_useMultiThreadMixer
|
||||
#endif
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// 7zFolderOutStream.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
@@ -1,6 +0,0 @@
|
||||
// 7zFolderOutStream.h
|
||||
|
||||
#ifndef __7Z_FOLDER_OUT_STREAM_H
|
||||
#define __7Z_FOLDER_OUT_STREAM_H
|
||||
|
||||
#endif
|
||||
@@ -36,10 +36,14 @@ CHandler::CHandler()
|
||||
#endif
|
||||
|
||||
#ifdef EXTRACT_ONLY
|
||||
|
||||
_crcSize = 4;
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
_numThreads = NSystem::GetNumberOfProcessors();
|
||||
_useMultiThreadMixer = true;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -722,10 +726,14 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
return E_INVALIDARG;
|
||||
const PROPVARIANT &value = values[i];
|
||||
UInt32 number;
|
||||
int index = ParseStringToUInt32(name, number);
|
||||
unsigned index = ParseStringToUInt32(name, number);
|
||||
if (index == 0)
|
||||
{
|
||||
if (name.IsEqualTo("mtf")) return PROPVARIANT_to_bool(value, _useMultiThreadMixer);
|
||||
if (name.IsEqualTo("mtf"))
|
||||
{
|
||||
RINOK(PROPVARIANT_to_bool(value, _useMultiThreadMixer));
|
||||
continue;
|
||||
}
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||
{
|
||||
RINOK(ParseMtProp(name.Ptr(2), value, numProcessors, _numThreads));
|
||||
|
||||
@@ -1338,7 +1338,7 @@ HRESULT CInArchive::ReadHeader(
|
||||
db.UnsupportedFeatureWarning = true;
|
||||
_inByteBack->SkipRem();
|
||||
}
|
||||
// SkipData worked incorrectly in some versions before v4.59 (7zVer <= 00.02)
|
||||
// SkipData worked incorrectly in some versions before v4.59 (7zVer <= 0.02)
|
||||
if (_inByteBack->GetRem() != 0)
|
||||
ThrowIncorrect();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace N7z {
|
||||
struct CPropMap
|
||||
{
|
||||
UInt32 FilePropID;
|
||||
STATPROPSTG StatPROPSTG;
|
||||
CStatProp StatProp;
|
||||
};
|
||||
|
||||
static const CPropMap kPropMap[] =
|
||||
@@ -24,11 +24,11 @@ static const CPropMap kPropMap[] =
|
||||
{ NID::kPackInfo, { NULL, kpidPackSize, VT_UI8 } },
|
||||
|
||||
#ifdef _MULTI_PACK
|
||||
{ 100, { L"Pack0", kpidPackedSize0, VT_UI8 } },
|
||||
{ 101, { L"Pack1", kpidPackedSize1, VT_UI8 } },
|
||||
{ 102, { L"Pack2", kpidPackedSize2, VT_UI8 } },
|
||||
{ 103, { L"Pack3", kpidPackedSize3, VT_UI8 } },
|
||||
{ 104, { L"Pack4", kpidPackedSize4, VT_UI8 } },
|
||||
{ 100, { "Pack0", kpidPackedSize0, VT_UI8 } },
|
||||
{ 101, { "Pack1", kpidPackedSize1, VT_UI8 } },
|
||||
{ 102, { "Pack2", kpidPackedSize2, VT_UI8 } },
|
||||
{ 103, { "Pack3", kpidPackedSize3, VT_UI8 } },
|
||||
{ 104, { "Pack4", kpidPackedSize4, VT_UI8 } },
|
||||
#endif
|
||||
|
||||
{ NID::kCTime, { NULL, kpidCTime, VT_FILETIME } },
|
||||
@@ -156,8 +156,8 @@ STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID,
|
||||
const CPropMap &pr = kPropMap[i];
|
||||
if (pr.FilePropID == id)
|
||||
{
|
||||
const STATPROPSTG &st = pr.StatPROPSTG;
|
||||
*propID = st.propid;
|
||||
const CStatProp &st = pr.StatProp;
|
||||
*propID = st.PropID;
|
||||
*varType = st.vt;
|
||||
/*
|
||||
if (st.lpwstrName)
|
||||
|
||||
@@ -13,7 +13,6 @@ AR_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
@@ -65,7 +64,6 @@ COMPRESS_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
|
||||
@@ -83,8 +83,14 @@ class CHandler: public CHandlerCont
|
||||
HRESULT ReadTables(IInStream *stream);
|
||||
UInt64 BlocksToBytes(UInt32 i) const { return (UInt64)i << _blockSizeLog; }
|
||||
|
||||
virtual UInt64 GetItemPos(UInt32 index) const { return BlocksToBytes(_items[index].StartBlock); }
|
||||
virtual UInt64 GetItemSize(UInt32 index) const { return BlocksToBytes(_items[index].NumBlocks); }
|
||||
virtual int GetItem_ExtractInfo(UInt32 index, UInt64 &pos, UInt64 &size) const
|
||||
{
|
||||
const CItem &item = _items[index];
|
||||
pos = BlocksToBytes(item.StartBlock);
|
||||
size = BlocksToBytes(item.NumBlocks);
|
||||
return NExtract::NOperationResult::kOK;
|
||||
}
|
||||
|
||||
public:
|
||||
INTERFACE_IInArchive_Cont(;)
|
||||
};
|
||||
|
||||
@@ -101,6 +101,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NCOM::CPropVariant prop;
|
||||
|
||||
if (m_Database.NewFormat)
|
||||
{
|
||||
switch (propID)
|
||||
@@ -112,12 +113,15 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
int entryIndex;
|
||||
|
||||
unsigned entryIndex;
|
||||
if (m_Database.LowLevel)
|
||||
entryIndex = index;
|
||||
else
|
||||
entryIndex = m_Database.Indices[index];
|
||||
|
||||
const CItem &item = m_Database.Items[entryIndex];
|
||||
|
||||
switch (propID)
|
||||
{
|
||||
case kpidPath:
|
||||
@@ -161,6 +165,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
@@ -244,9 +249,9 @@ public:
|
||||
UInt64 m_PosInFolder;
|
||||
UInt64 m_PosInSection;
|
||||
const CRecordVector<bool> *m_ExtractStatuses;
|
||||
int m_StartIndex;
|
||||
int m_CurrentIndex;
|
||||
int m_NumFiles;
|
||||
unsigned m_StartIndex;
|
||||
unsigned m_CurrentIndex;
|
||||
unsigned m_NumFiles;
|
||||
|
||||
private:
|
||||
const CFilesDatabase *m_Database;
|
||||
@@ -368,7 +373,7 @@ HRESULT CChmFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce
|
||||
// return E_FAIL;
|
||||
}
|
||||
|
||||
int fullIndex = m_StartIndex + m_CurrentIndex;
|
||||
unsigned fullIndex = m_StartIndex + m_CurrentIndex;
|
||||
m_RemainFileSize = m_Database->GetFileSize(fullIndex);
|
||||
UInt64 fileOffset = m_Database->GetFileOffset(fullIndex);
|
||||
if (fileOffset < m_PosInSection)
|
||||
@@ -408,7 +413,7 @@ HRESULT CChmFolderOutStream::FlushCorrupted(UInt64 maxSize)
|
||||
{
|
||||
const UInt32 kBufferSize = (1 << 10);
|
||||
Byte buffer[kBufferSize];
|
||||
for (int i = 0; i < kBufferSize; i++)
|
||||
for (unsigned i = 0; i < kBufferSize; i++)
|
||||
buffer[i] = 0;
|
||||
if (maxSize > m_FolderSize)
|
||||
maxSize = m_FolderSize;
|
||||
@@ -531,9 +536,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
UInt32 index = allFilesMode ? i : indices[i];
|
||||
int entryIndex = m_Database.Indices[index];
|
||||
const CItem &item = m_Database.Items[entryIndex];
|
||||
UInt64 sectionIndex = item.Section;
|
||||
const CItem &item = m_Database.Items[m_Database.Indices[index]];
|
||||
const UInt64 sectionIndex = item.Section;
|
||||
if (item.IsDir() || item.Size == 0)
|
||||
continue;
|
||||
if (sectionIndex == 0)
|
||||
@@ -567,14 +571,17 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
CByteBuffer packBuf;
|
||||
|
||||
for (i = 0; i < numItems;)
|
||||
for (i = 0;;)
|
||||
{
|
||||
RINOK(extractCallback->SetCompleted(¤tTotalSize));
|
||||
|
||||
if (i >= numItems)
|
||||
break;
|
||||
|
||||
UInt32 index = allFilesMode ? i : indices[i];
|
||||
i++;
|
||||
int entryIndex = m_Database.Indices[index];
|
||||
const CItem &item = m_Database.Items[entryIndex];
|
||||
UInt64 sectionIndex = item.Section;
|
||||
const CItem &item = m_Database.Items[m_Database.Indices[index]];
|
||||
const UInt64 sectionIndex = item.Section;
|
||||
Int32 askMode= testMode ?
|
||||
NExtract::NAskMode::kTest :
|
||||
NExtract::NAskMode::kExtract;
|
||||
@@ -645,7 +652,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
UInt64 folderIndex = m_Database.GetFolder(index);
|
||||
|
||||
UInt64 compressedPos = m_Database.ContentOffset + section.Offset;
|
||||
const UInt64 compressedPos = m_Database.ContentOffset + section.Offset;
|
||||
RINOK(lzxDecoderSpec->SetParams_and_Alloc(lzxInfo.GetNumDictBits()));
|
||||
|
||||
const CItem *lastItem = &item;
|
||||
@@ -673,9 +680,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
{
|
||||
for (; i < numItems; i++)
|
||||
{
|
||||
UInt32 nextIndex = allFilesMode ? i : indices[i];
|
||||
int entryIndex = m_Database.Indices[nextIndex];
|
||||
const CItem &nextItem = m_Database.Items[entryIndex];
|
||||
const UInt32 nextIndex = allFilesMode ? i : indices[i];
|
||||
const CItem &nextItem = m_Database.Items[m_Database.Indices[nextIndex]];
|
||||
if (nextItem.Section != sectionIndex)
|
||||
break;
|
||||
UInt64 nextFolderIndex = m_Database.GetFolder(nextIndex);
|
||||
|
||||
@@ -656,7 +656,7 @@ static AString GetSectionPrefix(const AString &name)
|
||||
|
||||
#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
|
||||
|
||||
static int CompareFiles(const int *p1, const int *p2, void *param)
|
||||
static int CompareFiles(const unsigned *p1, const unsigned *p2, void *param)
|
||||
{
|
||||
const CObjectVector<CItem> &items = *(const CObjectVector<CItem> *)param;
|
||||
const CItem &item1 = items[*p1];
|
||||
@@ -731,7 +731,7 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
||||
RINOK(DecompressStream(inStream, database, kNameList));
|
||||
/* UInt16 length = */ ReadUInt16();
|
||||
UInt16 numSections = ReadUInt16();
|
||||
for (int i = 0; i < numSections; i++)
|
||||
for (unsigned i = 0; i < numSections; i++)
|
||||
{
|
||||
CSectionInfo section;
|
||||
UInt16 nameLen = ReadUInt16();
|
||||
@@ -766,10 +766,10 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
||||
RINOK(DecompressStream(inStream, database, transformPrefix + kTransformList));
|
||||
if ((_chunkSize & 0xF) != 0)
|
||||
return S_FALSE;
|
||||
int numGuids = (int)(_chunkSize / 0x10);
|
||||
unsigned numGuids = (unsigned)(_chunkSize / 0x10);
|
||||
if (numGuids < 1)
|
||||
return S_FALSE;
|
||||
for (int i = 0; i < numGuids; i++)
|
||||
for (unsigned i = 0; i < numGuids; i++)
|
||||
{
|
||||
CMethodInfo method;
|
||||
ReadGUID(method.Guid);
|
||||
@@ -803,14 +803,17 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
||||
return S_FALSE;
|
||||
|
||||
{
|
||||
int n = GetLog(ReadUInt32());
|
||||
// There is bug in VC6, if we use function call as parameter for inline function
|
||||
UInt32 val32 = ReadUInt32();
|
||||
int n = GetLog(val32);
|
||||
if (n < 0 || n > 16)
|
||||
return S_FALSE;
|
||||
li.ResetIntervalBits = n;
|
||||
}
|
||||
|
||||
{
|
||||
int n = GetLog(ReadUInt32());
|
||||
UInt32 val32 = ReadUInt32();
|
||||
int n = GetLog(val32);
|
||||
if (n < 0 || n > 16)
|
||||
return S_FALSE;
|
||||
li.WindowSizeBits = n;
|
||||
|
||||
@@ -177,25 +177,25 @@ class CFilesDatabase: public CDatabase
|
||||
{
|
||||
public:
|
||||
bool LowLevel;
|
||||
CRecordVector<int> Indices;
|
||||
CUIntVector Indices;
|
||||
CObjectVector<CSectionInfo> Sections;
|
||||
|
||||
UInt64 GetFileSize(int fileIndex) const { return Items[Indices[fileIndex]].Size; }
|
||||
UInt64 GetFileOffset(int fileIndex) const { return Items[Indices[fileIndex]].Offset; }
|
||||
UInt64 GetFileSize(unsigned fileIndex) const { return Items[Indices[fileIndex]].Size; }
|
||||
UInt64 GetFileOffset(unsigned fileIndex) const { return Items[Indices[fileIndex]].Offset; }
|
||||
|
||||
UInt64 GetFolder(int fileIndex) const
|
||||
UInt64 GetFolder(unsigned fileIndex) const
|
||||
{
|
||||
const CItem &item = Items[Indices[fileIndex]];
|
||||
const CSectionInfo §ion = Sections[(int)item.Section];
|
||||
const CSectionInfo §ion = Sections[(unsigned)item.Section];
|
||||
if (section.IsLzx())
|
||||
return section.Methods[0].LzxInfo.GetFolder(item.Offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
UInt64 GetLastFolder(int fileIndex) const
|
||||
UInt64 GetLastFolder(unsigned fileIndex) const
|
||||
{
|
||||
const CItem &item = Items[Indices[fileIndex]];
|
||||
const CSectionInfo §ion = Sections[(int)item.Section];
|
||||
const CSectionInfo §ion = Sections[(unsigned)item.Section];
|
||||
if (section.IsLzx())
|
||||
return section.Methods[0].LzxInfo.GetFolder(item.Offset + item.Size - 1);
|
||||
return 0;
|
||||
|
||||
@@ -433,9 +433,9 @@ HRESULT CDatabase::Open(IInStream *inStream)
|
||||
SectorSizeBits = sectorSizeBits;
|
||||
MiniSectorSizeBits = miniSectorSizeBits;
|
||||
|
||||
if (sectorSizeBits > 28 ||
|
||||
if (sectorSizeBits > 24 ||
|
||||
sectorSizeBits < 7 ||
|
||||
miniSectorSizeBits > 28 ||
|
||||
miniSectorSizeBits > 24 ||
|
||||
miniSectorSizeBits < 2 ||
|
||||
miniSectorSizeBits > sectorSizeBits)
|
||||
return S_FALSE;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// CrossThreadProgress.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "CrossThreadProgress.h"
|
||||
|
||||
STDMETHODIMP CCrossThreadProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
|
||||
{
|
||||
InSize = inSize;
|
||||
OutSize = outSize;
|
||||
ProgressEvent.Set();
|
||||
WaitEvent.Lock();
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// CrossThreadProgress.h
|
||||
|
||||
#ifndef __CROSSTHREADPROGRESS_H
|
||||
#define __CROSSTHREADPROGRESS_H
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
class CCrossThreadProgress:
|
||||
public ICompressProgressInfo,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
const UInt64 *InSize;
|
||||
const UInt64 *OutSize;
|
||||
HRESULT Result;
|
||||
NWindows::NSynchronization::CAutoResetEvent ProgressEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent WaitEvent;
|
||||
|
||||
HRes Create()
|
||||
{
|
||||
RINOK(ProgressEvent.CreateIfNotCreated());
|
||||
return WaitEvent.CreateIfNotCreated();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
ProgressEvent.Reset();
|
||||
WaitEvent.Reset();
|
||||
}
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -147,7 +147,9 @@ HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PR
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return ParseMethodFromPROPVARIANT(names[i], value);
|
||||
{
|
||||
RINOK(ParseMethodFromPROPVARIANT(names[i], value));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ HRESULT COutVolumeStream::Flush()
|
||||
/*
|
||||
STDMETHODIMP COutMultiStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
if(processedSize != NULL)
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
while (size > 0)
|
||||
{
|
||||
@@ -157,7 +157,7 @@ STDMETHODIMP COutMultiStream::Write(const void *data, UInt32 size, UInt32 *proce
|
||||
_absPos += realProcessed;
|
||||
if (_absPos > _length)
|
||||
_length = _absPos;
|
||||
if(processedSize != NULL)
|
||||
if (processedSize)
|
||||
*processedSize += realProcessed;
|
||||
if (subStream.Pos == subStream.Size)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "../../../C/CpuArch.h"
|
||||
|
||||
#include "../../Common/ComTry.h"
|
||||
#include "../../Common/MyLinux.h"
|
||||
#include "../../Common/StringConvert.h"
|
||||
#include "../../Common/StringToInt.h"
|
||||
#include "../../Common/UTFConvert.h"
|
||||
@@ -121,7 +122,7 @@ struct CItem
|
||||
|
||||
bool IsBin() const { return Type == k_Type_BinLe || Type == k_Type_BinBe; }
|
||||
bool IsCrcFormat() const { return Type == k_Type_HexCrc; }
|
||||
bool IsDir() const { return (Mode & 0170000) == 0040000; }
|
||||
bool IsDir() const { return MY_LIN_S_ISDIR(Mode); }
|
||||
bool IsTrailer() const { return strcmp(Name, kName_TRAILER) == 0; }
|
||||
UInt64 GetDataPosition() const { return HeaderPos + HeaderSize; }
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "../../../C/LzmaDec.h"
|
||||
|
||||
#include "../../Common/ComTry.h"
|
||||
#include "../../Common/MyLinux.h"
|
||||
#include "../../Common/StringConvert.h"
|
||||
|
||||
#include "../../Windows/PropVariantUtils.h"
|
||||
@@ -98,7 +99,7 @@ struct CNode
|
||||
#define Get32(p) (be ? GetBe32(p) : GetUi32(p))
|
||||
|
||||
static UInt32 GetMode(const Byte *p, bool be) { return be ? GetBe16(p) : GetUi16(p); }
|
||||
static bool IsDir(const Byte *p, bool be) { return (GetMode(p, be) & 0xF000) == 0x4000; }
|
||||
static bool IsDir(const Byte *p, bool be) { return MY_LIN_S_ISDIR(GetMode(p, be)); }
|
||||
|
||||
static UInt32 GetSize(const Byte *p, bool be)
|
||||
{
|
||||
@@ -660,10 +661,6 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
CMyComPtr<ICompressProgressInfo> progress = lps;
|
||||
lps->Init(extractCallback, false);
|
||||
|
||||
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
|
||||
CMyComPtr<ISequentialInStream> inStream(streamSpec);
|
||||
streamSpec->SetStream(_stream);
|
||||
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
lps->InSize = totalPackSize;
|
||||
@@ -701,20 +698,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
int res = NExtract::NOperationResult::kDataError;
|
||||
{
|
||||
CMyComPtr<ISequentialInStream> inSeqStream;
|
||||
CMyComPtr<IInStream> inStream;
|
||||
HRESULT hres = GetStream(index, &inSeqStream);
|
||||
if (inSeqStream)
|
||||
inSeqStream.QueryInterface(IID_IInStream, &inStream);
|
||||
if (hres == E_OUTOFMEMORY)
|
||||
return E_OUTOFMEMORY;
|
||||
if (hres == S_FALSE || !inStream)
|
||||
if (hres == S_FALSE || !inSeqStream)
|
||||
res = NExtract::NOperationResult::kUnsupportedMethod;
|
||||
else
|
||||
{
|
||||
RINOK(hres);
|
||||
if (inStream)
|
||||
{
|
||||
HRESULT hres = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
|
||||
HRESULT hres = copyCoder->Code(inSeqStream, outStream, NULL, NULL, progress);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
if (copyCoderSpec->TotalSize == curSize)
|
||||
@@ -729,6 +722,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
}
|
||||
RINOK(extractCallback->SetOperationResult(res));
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ enum
|
||||
kpidInfoSection
|
||||
};
|
||||
|
||||
static const STATPROPSTG kProps[] =
|
||||
static const CStatProp kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR },
|
||||
{ NULL, kpidSize, VT_UI8 },
|
||||
@@ -641,8 +641,8 @@ static const STATPROPSTG kProps[] =
|
||||
{ NULL, kpidVa, VT_UI8 },
|
||||
{ NULL, kpidType, VT_BSTR },
|
||||
{ NULL, kpidCharacts, VT_BSTR }
|
||||
, { (LPOLESTR)L"Link Section", kpidLinkSection, VT_BSTR}
|
||||
, { (LPOLESTR)L"Info Section", kpidInfoSection, VT_BSTR}
|
||||
, { "Link Section", kpidLinkSection, VT_BSTR}
|
||||
, { "Info Section", kpidInfoSection, VT_BSTR}
|
||||
};
|
||||
|
||||
IMP_IInArchive_Props_WITH_NAME
|
||||
|
||||
2856
CPP/7zip/Archive/ExtHandler.cpp
Normal file
2856
CPP/7zip/Archive/ExtHandler.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -133,15 +133,23 @@ bool CHeader::Parse(const Byte *p)
|
||||
default: return false;
|
||||
}
|
||||
{
|
||||
int s = GetLog(Get16(p + 11));
|
||||
{
|
||||
UInt32 val32 = Get16(p + 11);
|
||||
int s = GetLog(val32);
|
||||
if (s < 9 || s > 12)
|
||||
return false;
|
||||
SectorSizeLog = (Byte)s;
|
||||
s = GetLog(p[13]);
|
||||
}
|
||||
{
|
||||
UInt32 val32 = p[13];
|
||||
int s = GetLog(val32);
|
||||
if (s < 0)
|
||||
return false;
|
||||
SectorsPerClusterLog = (Byte)s;
|
||||
}
|
||||
ClusterSizeLog = (Byte)(SectorSizeLog + SectorsPerClusterLog);
|
||||
if (ClusterSizeLog > 24)
|
||||
return false;
|
||||
}
|
||||
|
||||
NumReservedSectors = Get16(p + 14);
|
||||
@@ -805,7 +813,7 @@ enum
|
||||
// kpidFileSysType
|
||||
};
|
||||
|
||||
static const STATPROPSTG kArcProps[] =
|
||||
static const CStatProp kArcProps[] =
|
||||
{
|
||||
{ NULL, kpidFileSystem, VT_BSTR},
|
||||
{ NULL, kpidClusterSize, VT_UI4},
|
||||
@@ -814,12 +822,12 @@ static const STATPROPSTG kArcProps[] =
|
||||
{ NULL, kpidMTime, VT_FILETIME},
|
||||
{ NULL, kpidVolumeName, VT_BSTR},
|
||||
|
||||
{ (LPOLESTR)L"FATs", kpidNumFats, VT_UI4},
|
||||
{ "FATs", kpidNumFats, VT_UI4},
|
||||
{ NULL, kpidSectorSize, VT_UI4},
|
||||
{ NULL, kpidId, VT_UI4},
|
||||
// { (LPOLESTR)L"OEM Name", kpidOemName, VT_BSTR},
|
||||
// { (LPOLESTR)L"Volume Name", kpidVolName, VT_BSTR},
|
||||
// { (LPOLESTR)L"File System Type", kpidFileSysType, VT_BSTR}
|
||||
// { "OEM Name", kpidOemName, VT_BSTR},
|
||||
// { "Volume Name", kpidVolName, VT_BSTR},
|
||||
// { "File System Type", kpidFileSysType, VT_BSTR}
|
||||
// { NULL, kpidSectorsPerTrack, VT_UI4},
|
||||
// { NULL, kpidNumHeads, VT_UI4},
|
||||
// { NULL, kpidHiddenSectors, VT_UI4}
|
||||
|
||||
@@ -156,8 +156,15 @@ class CHandler: public CHandlerCont
|
||||
CByteBuffer _buffer;
|
||||
|
||||
HRESULT Open2(IInStream *stream);
|
||||
virtual UInt64 GetItemPos(UInt32 index) const { return _items[index].GetPos(); }
|
||||
virtual UInt64 GetItemSize(UInt32 index) const { return _items[index].GetSize(); }
|
||||
|
||||
virtual int GetItem_ExtractInfo(UInt32 index, UInt64 &pos, UInt64 &size) const
|
||||
{
|
||||
const CPartition &item = _items[index];
|
||||
pos = item.GetPos();
|
||||
size = item.GetSize();
|
||||
return NExtract::NOperationResult::kOK;
|
||||
}
|
||||
|
||||
public:
|
||||
INTERFACE_IInArchive_Cont(;)
|
||||
};
|
||||
|
||||
@@ -28,7 +28,11 @@ STDMETHODIMP CHandlerCont::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
UInt64 totalSize = 0;
|
||||
UInt32 i;
|
||||
for (i = 0; i < numItems; i++)
|
||||
totalSize += GetItemSize(allFilesMode ? i : indices[i]);
|
||||
{
|
||||
UInt64 pos, size;
|
||||
GetItem_ExtractInfo(allFilesMode ? i : indices[i], pos, size);
|
||||
totalSize += size;
|
||||
}
|
||||
extractCallback->SetTotal(totalSize);
|
||||
|
||||
totalSize = 0;
|
||||
@@ -56,21 +60,31 @@ STDMETHODIMP CHandlerCont::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
Int32 index = allFilesMode ? i : indices[i];
|
||||
|
||||
RINOK(extractCallback->GetStream(index, &outStream, askMode));
|
||||
UInt64 size = GetItemSize(index);
|
||||
|
||||
UInt64 pos, size;
|
||||
int opRes = GetItem_ExtractInfo(index, pos, size);
|
||||
totalSize += size;
|
||||
if (!testMode && !outStream)
|
||||
continue;
|
||||
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
|
||||
RINOK(_stream->Seek(GetItemPos(index), STREAM_SEEK_SET, NULL));
|
||||
if (opRes == NExtract::NOperationResult::kOK)
|
||||
{
|
||||
RINOK(_stream->Seek(pos, STREAM_SEEK_SET, NULL));
|
||||
streamSpec->Init(size);
|
||||
|
||||
RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
|
||||
outStream.Release();
|
||||
int opRes = NExtract::NOperationResult::kDataError;
|
||||
|
||||
opRes = NExtract::NOperationResult::kDataError;
|
||||
|
||||
if (copyCoderSpec->TotalSize == size)
|
||||
opRes = NExtract::NOperationResult::kOK;
|
||||
else if (copyCoderSpec->TotalSize < size)
|
||||
opRes = NExtract::NOperationResult::kUnexpectedEnd;
|
||||
}
|
||||
|
||||
outStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(opRes));
|
||||
}
|
||||
|
||||
@@ -81,13 +95,22 @@ STDMETHODIMP CHandlerCont::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
STDMETHODIMP CHandlerCont::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
// const CPartition &item = _items[index];
|
||||
return CreateLimitedInStream(_stream, GetItemPos(index), GetItemSize(index), stream);
|
||||
*stream = NULL;
|
||||
UInt64 pos, size;
|
||||
if (GetItem_ExtractInfo(index, pos, size) != NExtract::NOperationResult::kOK)
|
||||
return S_FALSE;
|
||||
return CreateLimitedInStream(_stream, pos, size, stream);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
|
||||
CHandlerImg::CHandlerImg():
|
||||
_imgExt(NULL)
|
||||
{
|
||||
ClearStreamVars();
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandlerImg::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
||||
{
|
||||
switch (seekOrigin)
|
||||
@@ -190,6 +213,8 @@ STDMETHODIMP CHandlerImg::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
int opRes = NExtract::NOperationResult::kDataError;
|
||||
|
||||
ClearStreamVars();
|
||||
|
||||
CMyComPtr<ISequentialInStream> inStream;
|
||||
HRESULT hres = GetStream(0, &inStream);
|
||||
if (hres == S_FALSE)
|
||||
@@ -205,6 +230,13 @@ STDMETHODIMP CHandlerImg::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
{
|
||||
if (copyCoderSpec->TotalSize == _size)
|
||||
opRes = NExtract::NOperationResult::kOK;
|
||||
|
||||
if (_stream_unavailData)
|
||||
opRes = NExtract::NOperationResult::kUnavailable;
|
||||
else if (_stream_unsupportedMethod)
|
||||
opRes = NExtract::NOperationResult::kUnsupportedMethod;
|
||||
else if (_stream_dataError)
|
||||
opRes = NExtract::NOperationResult::kDataError;
|
||||
else if (copyCoderSpec->TotalSize < _size)
|
||||
opRes = NExtract::NOperationResult::kUnexpectedEnd;
|
||||
}
|
||||
@@ -227,4 +259,30 @@ STDMETHODIMP CHandlerImg::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
HRESULT ReadZeroTail(ISequentialInStream *stream, bool &areThereNonZeros, UInt64 &numZeros, UInt64 maxSize)
|
||||
{
|
||||
areThereNonZeros = false;
|
||||
numZeros = 0;
|
||||
const size_t kBufSize = 1 << 11;
|
||||
Byte buf[kBufSize];
|
||||
for (;;)
|
||||
{
|
||||
UInt32 size = 0;
|
||||
HRESULT(stream->Read(buf, kBufSize, &size));
|
||||
if (size == 0)
|
||||
return S_OK;
|
||||
for (UInt32 i = 0; i < size; i++)
|
||||
if (buf[i] != 0)
|
||||
{
|
||||
areThereNonZeros = true;
|
||||
numZeros += i;
|
||||
return S_OK;
|
||||
}
|
||||
numZeros += size;
|
||||
if (numZeros > maxSize)
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ class CHandlerCont:
|
||||
protected:
|
||||
CMyComPtr<IInStream> _stream;
|
||||
|
||||
virtual UInt64 GetItemPos(UInt32 index) const = 0;
|
||||
virtual UInt64 GetItemSize(UInt32 index) const = 0;
|
||||
virtual int GetItem_ExtractInfo(UInt32 index, UInt64 &pos, UInt64 &size) const = 0;
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
|
||||
INTERFACE_IInArchive_Cont(PURE)
|
||||
@@ -39,6 +39,9 @@ public:
|
||||
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) MY_NO_THROW_DECL_ONLY;
|
||||
|
||||
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
|
||||
|
||||
// destructor must be virtual for this class
|
||||
virtual ~CHandlerCont() {}
|
||||
};
|
||||
|
||||
|
||||
@@ -69,6 +72,22 @@ protected:
|
||||
CMyComPtr<IInStream> Stream;
|
||||
const char *_imgExt;
|
||||
|
||||
bool _stream_unavailData;
|
||||
bool _stream_unsupportedMethod;
|
||||
bool _stream_dataError;
|
||||
// bool _stream_UsePackSize;
|
||||
// UInt64 _stream_PackSize;
|
||||
|
||||
void ClearStreamVars()
|
||||
{
|
||||
_stream_unavailData = false;
|
||||
_stream_unsupportedMethod = false;
|
||||
_stream_dataError = false;
|
||||
// _stream_UsePackSize = false;
|
||||
// _stream_PackSize = 0;
|
||||
}
|
||||
|
||||
|
||||
virtual HRESULT Open2(IInStream *stream, IArchiveOpenCallback *openCallback) = 0;
|
||||
virtual void CloseAtError();
|
||||
public:
|
||||
@@ -83,8 +102,15 @@ public:
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) = 0;
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
|
||||
CHandlerImg();
|
||||
// destructor must be virtual for this class
|
||||
virtual ~CHandlerImg() {}
|
||||
};
|
||||
|
||||
|
||||
HRESULT ReadZeroTail(ISequentialInStream *stream, bool &areThereNonZeros, UInt64 &numZeros, UInt64 maxSize);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -293,12 +293,14 @@ namespace NPropDataType
|
||||
const UInt32 kMask_ZeroEnd = 1 << 4;
|
||||
// const UInt32 kMask_BigEndian = 1 << 5;
|
||||
const UInt32 kMask_Utf = 1 << 6;
|
||||
// const UInt32 kMask_Utf8 = kMask_Utf | 0;
|
||||
const UInt32 kMask_Utf8 = kMask_Utf | 0;
|
||||
const UInt32 kMask_Utf16 = kMask_Utf | 1;
|
||||
// const UInt32 kMask_Utf32 = kMask_Utf | 2;
|
||||
|
||||
const UInt32 kNotDefined = 0;
|
||||
const UInt32 kRaw = 1;
|
||||
|
||||
const UInt32 kUtf8z = kMask_Utf8 | kMask_ZeroEnd;
|
||||
const UInt32 kUtf16z = kMask_Utf16 | kMask_ZeroEnd;
|
||||
};
|
||||
|
||||
@@ -512,12 +514,26 @@ ARCHIVE_INTERFACE(IArchiveAllowTail, 0x05)
|
||||
{ if (index >= ARRAY_SIZE(k)) return E_INVALIDARG; \
|
||||
*propID = k[index]; *varType = k7z_PROPID_To_VARTYPE[(unsigned)*propID]; *name = 0; return S_OK; } \
|
||||
|
||||
|
||||
struct CStatProp
|
||||
{
|
||||
const char *Name;
|
||||
UInt32 PropID;
|
||||
VARTYPE vt;
|
||||
};
|
||||
|
||||
namespace NWindows {
|
||||
namespace NCOM {
|
||||
// PropVariant.cpp
|
||||
BSTR AllocBstrFromAscii(const char *s) throw();
|
||||
}}
|
||||
|
||||
#define IMP_IInArchive_GetProp_WITH_NAME(k) \
|
||||
(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
|
||||
{ if (index >= ARRAY_SIZE(k)) return E_INVALIDARG; \
|
||||
const STATPROPSTG &srcItem = k[index]; \
|
||||
*propID = srcItem.propid; *varType = srcItem.vt; \
|
||||
if (srcItem.lpwstrName == 0) *name = 0; else *name = ::SysAllocString(srcItem.lpwstrName); return S_OK; } \
|
||||
const CStatProp &prop = k[index]; \
|
||||
*propID = (PROPID)prop.PropID; *varType = prop.vt; \
|
||||
*name = NWindows::NCOM::AllocBstrFromAscii(prop.Name); return S_OK; } \
|
||||
|
||||
#define IMP_IInArchive_Props \
|
||||
STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProps) \
|
||||
|
||||
@@ -323,7 +323,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
{
|
||||
lps->InSize = lps->OutSize = currentTotalSize + offset;
|
||||
const CDir &item2 = ref.Dir->_subItems[ref.Index + e];
|
||||
RINOK(_stream->Seek((UInt64)item2.ExtentLocation * _archive.BlockSize, STREAM_SEEK_SET, NULL));
|
||||
RINOK(_stream->Seek((UInt64)item2.ExtentLocation * kBlockSize, STREAM_SEEK_SET, NULL));
|
||||
streamSpec->Init(item2.Size);
|
||||
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
||||
if (copyCoderSpec->TotalSize != item2.Size)
|
||||
@@ -336,7 +336,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(_stream->Seek(blockIndex * _archive.BlockSize, STREAM_SEEK_SET, NULL));
|
||||
RINOK(_stream->Seek((UInt64)blockIndex * kBlockSize, STREAM_SEEK_SET, NULL));
|
||||
streamSpec->Init(currentItemSize);
|
||||
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
||||
if (copyCoderSpec->TotalSize != currentItemSize)
|
||||
@@ -379,7 +379,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
if (item.Size == 0)
|
||||
continue;
|
||||
CSeekExtent se;
|
||||
se.Phy = (UInt64)item.ExtentLocation * _archive.BlockSize;
|
||||
se.Phy = (UInt64)item.ExtentLocation * kBlockSize;
|
||||
se.Virt = virtOffset;
|
||||
extentStreamSpec->Extents.Add(se);
|
||||
virtOffset += item.Size;
|
||||
@@ -405,7 +405,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
blockIndex = be.LoadRBA;
|
||||
}
|
||||
|
||||
return CreateLimitedInStream(_stream, blockIndex * _archive.BlockSize, currentItemSize, stream);
|
||||
return CreateLimitedInStream(_stream, (UInt64)blockIndex * kBlockSize, currentItemSize, stream);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "../HandlerCont.h"
|
||||
|
||||
#include "IsoIn.h"
|
||||
|
||||
namespace NArchive {
|
||||
@@ -86,15 +88,15 @@ AString CBootInitialEntry::GetName() const
|
||||
|
||||
Byte CInArchive::ReadByte()
|
||||
{
|
||||
if (m_BufferPos >= BlockSize)
|
||||
if (m_BufferPos >= kBlockSize)
|
||||
m_BufferPos = 0;
|
||||
if (m_BufferPos == 0)
|
||||
{
|
||||
size_t processed = BlockSize;
|
||||
size_t processed = kBlockSize;
|
||||
HRESULT res = ReadStream(_stream, m_Buffer, &processed);
|
||||
if (res != S_OK)
|
||||
throw CSystemException(res);
|
||||
if (processed != BlockSize)
|
||||
if (processed != kBlockSize)
|
||||
throw CUnexpectedEndException();
|
||||
UInt64 end = _position + processed;
|
||||
if (PhySize < end)
|
||||
@@ -292,7 +294,11 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
|
||||
d.FileStructureVersion = ReadByte(); // = 1
|
||||
SkipZeros(1);
|
||||
ReadBytes(d.ApplicationUse, sizeof(d.ApplicationUse));
|
||||
SkipZeros(653);
|
||||
|
||||
// Most ISO contains zeros in the following field (reserved for future standardization).
|
||||
// But some ISO programs write some data to that area.
|
||||
// So we disable check for zeros.
|
||||
Skip(653); // SkipZeros(653);
|
||||
}
|
||||
|
||||
static const Byte kSig_CD001[5] = { 'C', 'D', '0', '0', '1' };
|
||||
@@ -509,7 +515,7 @@ HRESULT CInArchive::Open2()
|
||||
|
||||
PhySize = _position;
|
||||
m_BufferPos = 0;
|
||||
BlockSize = kBlockSize;
|
||||
// BlockSize = kBlockSize;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -614,6 +620,22 @@ HRESULT CInArchive::Open2()
|
||||
UpdatePhySize(be.LoadRBA, GetBootItemSize(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (PhySize < _fileSize)
|
||||
{
|
||||
UInt64 rem = _fileSize - PhySize;
|
||||
const UInt64 kRemMax = 1 << 21;
|
||||
if (rem <= kRemMax)
|
||||
{
|
||||
RINOK(_stream->Seek(PhySize, STREAM_SEEK_SET, NULL));
|
||||
bool areThereNonZeros = false;
|
||||
UInt64 numZeros = 0;
|
||||
RINOK(ReadZeroTail(_stream, areThereNonZeros, numZeros, kRemMax));
|
||||
if (!areThereNonZeros)
|
||||
PhySize += numZeros;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ public:
|
||||
CRecordVector<CRef> Refs;
|
||||
CObjectVector<CVolumeDescriptor> VolDescs;
|
||||
int MainVolDescIndex;
|
||||
UInt32 BlockSize;
|
||||
// UInt32 BlockSize;
|
||||
CObjectVector<CBootInitialEntry> BootEntries;
|
||||
|
||||
bool IsArc;
|
||||
@@ -297,8 +297,8 @@ public:
|
||||
|
||||
void UpdatePhySize(UInt32 blockIndex, UInt64 size)
|
||||
{
|
||||
UInt64 alignedSize = (size + BlockSize - 1) & ~((UInt64)BlockSize - 1);
|
||||
UInt64 end = blockIndex * BlockSize + alignedSize;
|
||||
const UInt64 alignedSize = (size + kBlockSize - 1) & ~((UInt64)kBlockSize - 1);
|
||||
const UInt64 end = (UInt64)blockIndex * kBlockSize + alignedSize;
|
||||
if (PhySize < end)
|
||||
PhySize = end;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
size = (1440 << 10);
|
||||
else if (be.BootMediaType == NBootMediaType::k2d88Floppy)
|
||||
size = (2880 << 10);
|
||||
UInt64 startPos = (UInt64)be.LoadRBA * BlockSize;
|
||||
UInt64 startPos = (UInt64)be.LoadRBA * kBlockSize;
|
||||
if (startPos < _fileSize)
|
||||
{
|
||||
if (_fileSize - startPos < size)
|
||||
|
||||
@@ -158,6 +158,7 @@ static const CPartType kPartTypes[] =
|
||||
{ 0x1E, kFat, "FAT16-LBA-WIN95-Hidden" },
|
||||
{ 0x82, 0, "Solaris x86 / Linux swap" },
|
||||
{ 0x83, 0, "Linux" },
|
||||
{ 0x8E, "lvm", "Linux LVM" },
|
||||
{ 0xA5, 0, "BSD slice" },
|
||||
{ 0xBE, 0, "Solaris 8 boot" },
|
||||
{ 0xBF, 0, "New Solaris x86" },
|
||||
@@ -189,8 +190,14 @@ class CHandler: public CHandlerCont
|
||||
UInt64 _totalSize;
|
||||
CByteBuffer _buffer;
|
||||
|
||||
virtual UInt64 GetItemPos(UInt32 index) const { return _items[index].Part.GetPos(); }
|
||||
virtual UInt64 GetItemSize(UInt32 index) const { return _items[index].Size; }
|
||||
virtual int GetItem_ExtractInfo(UInt32 index, UInt64 &pos, UInt64 &size) const
|
||||
{
|
||||
const CItem &item = _items[index];
|
||||
pos = item.Part.GetPos();
|
||||
size = item.Size;
|
||||
return NExtract::NOperationResult::kOK;
|
||||
}
|
||||
|
||||
HRESULT ReadTables(IInStream *stream, UInt32 baseLba, UInt32 lba, unsigned level);
|
||||
public:
|
||||
INTERFACE_IInArchive_Cont(;)
|
||||
@@ -332,15 +339,15 @@ enum
|
||||
kpidEndChs
|
||||
};
|
||||
|
||||
static const STATPROPSTG kProps[] =
|
||||
static const CStatProp kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidFileSystem, VT_BSTR},
|
||||
{ NULL, kpidOffset, VT_UI8},
|
||||
{ (LPOLESTR)L"Primary", kpidPrimary, VT_BOOL},
|
||||
{ (LPOLESTR)L"Begin CHS", kpidBegChs, VT_BSTR},
|
||||
{ (LPOLESTR)L"End CHS", kpidEndChs, VT_BSTR}
|
||||
{ "Primary", kpidPrimary, VT_BOOL},
|
||||
{ "Begin CHS", kpidBegChs, VT_BSTR},
|
||||
{ "End CHS", kpidEndChs, VT_BSTR}
|
||||
};
|
||||
|
||||
IMP_IInArchive_Props_WITH_NAME
|
||||
|
||||
@@ -56,8 +56,15 @@ class CHandler: public CHandlerCont
|
||||
CItem _items[kNumFilesMax];
|
||||
|
||||
HRESULT Open2(IInStream *stream);
|
||||
virtual UInt64 GetItemPos(UInt32 index) const { return _items[index].Offset; }
|
||||
virtual UInt64 GetItemSize(UInt32 index) const { return _items[index].Size; }
|
||||
|
||||
virtual int GetItem_ExtractInfo(UInt32 index, UInt64 &pos, UInt64 &size) const
|
||||
{
|
||||
const CItem &item = _items[index];
|
||||
pos = item.Offset;
|
||||
size = item.Size;
|
||||
return NExtract::NOperationResult::kOK;
|
||||
}
|
||||
|
||||
public:
|
||||
INTERFACE_IInArchive_Cont(;)
|
||||
};
|
||||
|
||||
@@ -576,20 +576,20 @@ class CInStream:
|
||||
UInt64 _physPos;
|
||||
UInt64 _curRem;
|
||||
bool _sparseMode;
|
||||
size_t _compressedPos;
|
||||
|
||||
UInt64 _tags[kNumCacheChunks];
|
||||
|
||||
unsigned _chunkSizeLog;
|
||||
UInt64 _tags[kNumCacheChunks];
|
||||
CByteBuffer _inBuf;
|
||||
CByteBuffer _outBuf;
|
||||
public:
|
||||
CMyComPtr<IInStream> Stream;
|
||||
UInt64 Size;
|
||||
UInt64 InitializedSize;
|
||||
unsigned BlockSizeLog;
|
||||
unsigned CompressionUnit;
|
||||
bool InUse;
|
||||
CRecordVector<CExtent> Extents;
|
||||
bool InUse;
|
||||
CMyComPtr<IInStream> Stream;
|
||||
|
||||
HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
|
||||
|
||||
@@ -597,11 +597,11 @@ public:
|
||||
HRESULT InitAndSeek(unsigned compressionUnit)
|
||||
{
|
||||
CompressionUnit = compressionUnit;
|
||||
_chunkSizeLog = BlockSizeLog + CompressionUnit;
|
||||
if (compressionUnit != 0)
|
||||
{
|
||||
UInt32 cuSize = GetCuSize();
|
||||
_inBuf.Alloc(cuSize);
|
||||
_chunkSizeLog = BlockSizeLog + CompressionUnit;
|
||||
_outBuf.Alloc(kNumCacheChunks << _chunkSizeLog);
|
||||
}
|
||||
for (size_t i = 0; i < kNumCacheChunks; i++)
|
||||
@@ -2173,7 +2173,7 @@ enum
|
||||
kpidATime2
|
||||
};
|
||||
|
||||
static const STATPROPSTG kProps[] =
|
||||
static const CStatProp kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
@@ -2181,20 +2181,20 @@ static const STATPROPSTG kProps[] =
|
||||
|
||||
// { NULL, kpidLink, VT_BSTR},
|
||||
|
||||
// { (LPOLESTR)L"Link 2", kpidLink2, VT_BSTR},
|
||||
// { (LPOLESTR)L"Link Type", kpidLinkType, VT_UI2},
|
||||
// { "Link 2", kpidLink2, VT_BSTR},
|
||||
// { "Link Type", kpidLinkType, VT_UI2},
|
||||
{ NULL, kpidINode, VT_UI8},
|
||||
|
||||
{ NULL, kpidMTime, VT_FILETIME},
|
||||
{ NULL, kpidCTime, VT_FILETIME},
|
||||
{ NULL, kpidATime, VT_FILETIME},
|
||||
|
||||
// { (LPOLESTR)L"Record Modified", kpidRecMTime, VT_FILETIME},
|
||||
// { "Record Modified", kpidRecMTime, VT_FILETIME},
|
||||
|
||||
// { (LPOLESTR)L"Modified 2", kpidMTime2, VT_FILETIME},
|
||||
// { (LPOLESTR)L"Created 2", kpidCTime2, VT_FILETIME},
|
||||
// { (LPOLESTR)L"Accessed 2", kpidATime2, VT_FILETIME},
|
||||
// { (LPOLESTR)L"Record Modified 2", kpidRecMTime2, VT_FILETIME},
|
||||
// { "Modified 2", kpidMTime2, VT_FILETIME},
|
||||
// { "Created 2", kpidCTime2, VT_FILETIME},
|
||||
// { "Accessed 2", kpidATime2, VT_FILETIME},
|
||||
// { "Record Modified 2", kpidRecMTime2, VT_FILETIME},
|
||||
|
||||
{ NULL, kpidAttrib, VT_UI4},
|
||||
{ NULL, kpidNumBlocks, VT_UI4},
|
||||
@@ -2226,13 +2226,13 @@ enum
|
||||
kpidRecordSize = kpidUserDefined
|
||||
};
|
||||
|
||||
static const STATPROPSTG kArcProps[] =
|
||||
static const CStatProp kArcProps[] =
|
||||
{
|
||||
{ NULL, kpidVolumeName, VT_BSTR},
|
||||
{ NULL, kpidFileSystem, VT_BSTR},
|
||||
{ NULL, kpidClusterSize, VT_UI4},
|
||||
{ NULL, kpidSectorSize, VT_UI4},
|
||||
{ (LPOLESTR)L"Record Size", kpidRecordSize, VT_UI4},
|
||||
{ "Record Size", kpidRecordSize, VT_UI4},
|
||||
{ NULL, kpidHeadersSize, VT_UI8},
|
||||
{ NULL, kpidCTime, VT_FILETIME},
|
||||
{ NULL, kpidId, VT_UI8},
|
||||
|
||||
@@ -765,7 +765,7 @@ enum
|
||||
// kpidBaseOfData32,
|
||||
};
|
||||
|
||||
static const STATPROPSTG kArcProps[] =
|
||||
static const CStatProp kArcProps[] =
|
||||
{
|
||||
// { NULL, kpidWarning, VT_BSTR},
|
||||
{ NULL, kpidCpu, VT_BSTR},
|
||||
@@ -776,28 +776,28 @@ static const STATPROPSTG kArcProps[] =
|
||||
{ NULL, kpidChecksum, VT_UI4},
|
||||
{ NULL, kpidName, VT_BSTR},
|
||||
|
||||
{ (LPOLESTR)L"Image Size", kpidImageSize, VT_UI4},
|
||||
{ (LPOLESTR)L"Section Alignment", kpidSectAlign, VT_UI4},
|
||||
{ (LPOLESTR)L"File Alignment", kpidFileAlign, VT_UI4},
|
||||
{ (LPOLESTR)L"Code Size", kpidCodeSize, VT_UI4},
|
||||
{ (LPOLESTR)L"Initialized Data Size", kpidInitDataSize, VT_UI4},
|
||||
{ (LPOLESTR)L"Uninitialized Data Size", kpidUnInitDataSize, VT_UI4},
|
||||
{ (LPOLESTR)L"Linker Version", kpidLinkerVer, VT_BSTR},
|
||||
{ (LPOLESTR)L"OS Version", kpidOsVer, VT_BSTR},
|
||||
{ (LPOLESTR)L"Image Version", kpidImageVer, VT_BSTR},
|
||||
{ (LPOLESTR)L"Subsystem Version", kpidSubsysVer, VT_BSTR},
|
||||
{ (LPOLESTR)L"Subsystem", kpidSubSystem, VT_BSTR},
|
||||
{ (LPOLESTR)L"DLL Characteristics", kpidDllCharacts, VT_BSTR},
|
||||
{ (LPOLESTR)L"Stack Reserve", kpidStackReserve, VT_UI8},
|
||||
{ (LPOLESTR)L"Stack Commit", kpidStackCommit, VT_UI8},
|
||||
{ (LPOLESTR)L"Heap Reserve", kpidHeapReserve, VT_UI8},
|
||||
{ (LPOLESTR)L"Heap Commit", kpidHeapCommit, VT_UI8},
|
||||
{ (LPOLESTR)L"Image Base", kpidImageBase, VT_UI8},
|
||||
{ "Image Size", kpidImageSize, VT_UI4},
|
||||
{ "Section Alignment", kpidSectAlign, VT_UI4},
|
||||
{ "File Alignment", kpidFileAlign, VT_UI4},
|
||||
{ "Code Size", kpidCodeSize, VT_UI4},
|
||||
{ "Initialized Data Size", kpidInitDataSize, VT_UI4},
|
||||
{ "Uninitialized Data Size", kpidUnInitDataSize, VT_UI4},
|
||||
{ "Linker Version", kpidLinkerVer, VT_BSTR},
|
||||
{ "OS Version", kpidOsVer, VT_BSTR},
|
||||
{ "Image Version", kpidImageVer, VT_BSTR},
|
||||
{ "Subsystem Version", kpidSubsysVer, VT_BSTR},
|
||||
{ "Subsystem", kpidSubSystem, VT_BSTR},
|
||||
{ "DLL Characteristics", kpidDllCharacts, VT_BSTR},
|
||||
{ "Stack Reserve", kpidStackReserve, VT_UI8},
|
||||
{ "Stack Commit", kpidStackCommit, VT_UI8},
|
||||
{ "Heap Reserve", kpidHeapReserve, VT_UI8},
|
||||
{ "Heap Commit", kpidHeapCommit, VT_UI8},
|
||||
{ "Image Base", kpidImageBase, VT_UI8},
|
||||
{ NULL, kpidComment, VT_BSTR},
|
||||
|
||||
// { (LPOLESTR)L"Address Of Entry Point", kpidAddressOfEntryPoint, VT_UI8},
|
||||
// { (LPOLESTR)L"Base Of Code", kpidBaseOfCode, VT_UI8},
|
||||
// { (LPOLESTR)L"Base Of Data", kpidBaseOfData32, VT_UI8},
|
||||
// { "Address Of Entry Point", kpidAddressOfEntryPoint, VT_UI8},
|
||||
// { "Base Of Code", kpidBaseOfCode, VT_UI8},
|
||||
// { "Base Of Data", kpidBaseOfData32, VT_UI8},
|
||||
};
|
||||
|
||||
static const Byte kProps[] =
|
||||
@@ -2798,12 +2798,12 @@ enum
|
||||
// , kpidImageBase
|
||||
};
|
||||
|
||||
static const STATPROPSTG kArcProps[] =
|
||||
static const CStatProp kArcProps[] =
|
||||
{
|
||||
// { NULL, kpidHeadersSize, VT_UI4 },
|
||||
{ NULL, kpidCpu, VT_BSTR},
|
||||
{ (LPOLESTR)L"Subsystem", kpidSubSystem, VT_BSTR },
|
||||
// { (LPOLESTR)L"Image Base", kpidImageBase, VT_UI8 }
|
||||
{ "Subsystem", kpidSubSystem, VT_BSTR },
|
||||
// { "Image Base", kpidImageBase, VT_UI8 }
|
||||
};
|
||||
|
||||
IMP_IInArchive_Props
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "../Common/FindSignature.h"
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
|
||||
#include "../HandlerCont.h"
|
||||
|
||||
#include "RarVol.h"
|
||||
#include "Rar5Handler.h"
|
||||
|
||||
@@ -38,13 +40,6 @@ using namespace NWindows;
|
||||
#define Get32(p) GetUi32(p)
|
||||
|
||||
namespace NArchive {
|
||||
|
||||
namespace NRar {
|
||||
|
||||
HRESULT ReadZeroTail(ISequentialInStream *stream, bool &areThereNonZeros, UInt64 &numZeros, UInt64 maxSize);
|
||||
|
||||
}
|
||||
|
||||
namespace NRar5 {
|
||||
|
||||
static const unsigned kMarkerSize = 8;
|
||||
@@ -1297,6 +1292,18 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidError:
|
||||
{
|
||||
if (/* &_missingVol || */ !_missingVolName.IsEmpty())
|
||||
{
|
||||
UString s;
|
||||
s.SetFromAscii("Missing volume : ");
|
||||
s += _missingVolName;
|
||||
prop = s;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidErrorFlags:
|
||||
{
|
||||
UInt32 v = _errorFlags;
|
||||
@@ -1845,14 +1852,19 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
break;
|
||||
}
|
||||
|
||||
HRESULT result = openVolumeCallback->GetStream(seqName.GetNextName(), &inStream);
|
||||
if (result == S_FALSE)
|
||||
break;
|
||||
if (result != S_OK)
|
||||
const UString volName = seqName.GetNextName();
|
||||
|
||||
HRESULT result = openVolumeCallback->GetStream(volName, &inStream);
|
||||
|
||||
if (result != S_OK && result != S_FALSE)
|
||||
return result;
|
||||
if (!inStream)
|
||||
|
||||
if (!inStream || result != S_OK)
|
||||
{
|
||||
_missingVolName = volName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UInt64 endPos = 0;
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &arch.StreamStartPosition));
|
||||
@@ -1938,7 +1950,7 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
bool areThereNonZeros;
|
||||
UInt64 numZeros;
|
||||
const UInt64 maxSize = 1 << 12;
|
||||
RINOK(NRar::ReadZeroTail(inStream, areThereNonZeros, numZeros, maxSize));
|
||||
RINOK(ReadZeroTail(inStream, areThereNonZeros, numZeros, maxSize));
|
||||
if (!areThereNonZeros && numZeros != 0 && numZeros <= maxSize)
|
||||
arcInfo.EndPos += numZeros;
|
||||
}
|
||||
@@ -2125,6 +2137,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
_missingVolName.Empty();
|
||||
_errorFlags = 0;
|
||||
// _warningFlags = 0;
|
||||
_isArc = false;
|
||||
|
||||
@@ -381,6 +381,7 @@ private:
|
||||
// UInt32 _warningFlags;
|
||||
bool _isArc;
|
||||
CByteBuffer _comment;
|
||||
UString _missingVolName;
|
||||
|
||||
DECL_EXTERNAL_CODECS_VARS
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
#include "../Common/OutStreamWithCRC.h"
|
||||
|
||||
#include "../HandlerCont.h"
|
||||
|
||||
#include "RarVol.h"
|
||||
#include "RarHandler.h"
|
||||
|
||||
@@ -853,7 +855,20 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
break;
|
||||
}
|
||||
|
||||
// case kpidError: if (!_errorMessage.IsEmpty()) prop = _errorMessage; break;
|
||||
|
||||
case kpidError:
|
||||
{
|
||||
// if (!_errorMessage.IsEmpty()) prop = _errorMessage; break;
|
||||
|
||||
if (/* &_missingVol || */ !_missingVolName.IsEmpty())
|
||||
{
|
||||
UString s;
|
||||
s.SetFromAscii("Missing volume : ");
|
||||
s += _missingVolName;
|
||||
prop = s;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidErrorFlags:
|
||||
{
|
||||
@@ -998,31 +1013,6 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
}
|
||||
|
||||
|
||||
HRESULT ReadZeroTail(ISequentialInStream *stream, bool &areThereNonZeros, UInt64 &numZeros, UInt64 maxSize)
|
||||
{
|
||||
areThereNonZeros = false;
|
||||
numZeros = 0;
|
||||
const size_t kBufSize = 1 << 9;
|
||||
Byte buf[kBufSize];
|
||||
for (;;)
|
||||
{
|
||||
UInt32 size = 0;
|
||||
HRESULT(stream->Read(buf, kBufSize, &size));
|
||||
if (size == 0)
|
||||
return S_OK;
|
||||
for (UInt32 i = 0; i < size; i++)
|
||||
if (buf[i] != 0)
|
||||
{
|
||||
areThereNonZeros = true;
|
||||
numZeros += i;
|
||||
return S_OK;
|
||||
}
|
||||
numZeros += size;
|
||||
if (numZeros > maxSize)
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CHandler::Open2(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
IArchiveOpenCallback *openCallback)
|
||||
@@ -1073,15 +1063,19 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
*/
|
||||
}
|
||||
|
||||
UString fullName = seqName.GetNextName();
|
||||
HRESULT result = openVolumeCallback->GetStream(fullName, &inStream);
|
||||
if (result == S_FALSE)
|
||||
break;
|
||||
if (result != S_OK)
|
||||
const UString volName = seqName.GetNextName();
|
||||
|
||||
HRESULT result = openVolumeCallback->GetStream(volName, &inStream);
|
||||
|
||||
if (result != S_OK && result != S_FALSE)
|
||||
return result;
|
||||
if (!inStream)
|
||||
|
||||
if (!inStream || result != S_OK)
|
||||
{
|
||||
_missingVolName = volName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
inStream = stream;
|
||||
|
||||
@@ -1239,6 +1233,7 @@ STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
// _errorMessage.Empty();
|
||||
_missingVolName.Empty();
|
||||
_errorFlags = 0;
|
||||
_warningFlags = 0;
|
||||
_isArc = false;
|
||||
|
||||
@@ -79,6 +79,7 @@ class CHandler:
|
||||
UInt32 _errorFlags;
|
||||
UInt32 _warningFlags;
|
||||
bool _isArc;
|
||||
UString _missingVolName;
|
||||
|
||||
DECL_EXTERNAL_CODECS_VARS
|
||||
|
||||
|
||||
@@ -226,8 +226,13 @@ class CHandler: public CHandlerCont
|
||||
HRESULT ReadHeader(ISequentialInStream *stream, bool isMainHeader);
|
||||
HRESULT Open2(ISequentialInStream *stream);
|
||||
|
||||
virtual UInt64 GetItemPos(UInt32) const { return _headersSize; }
|
||||
virtual UInt64 GetItemSize(UInt32) const { return _size; }
|
||||
virtual int GetItem_ExtractInfo(UInt32 /* index */, UInt64 &pos, UInt64 &size) const
|
||||
{
|
||||
pos = _headersSize;
|
||||
size = _size;
|
||||
return NExtract::NOperationResult::kOK;
|
||||
}
|
||||
|
||||
public:
|
||||
INTERFACE_IInArchive_Cont(;)
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "../../../C/Xz.h"
|
||||
|
||||
#include "../../Common/ComTry.h"
|
||||
#include "../../Common/MyLinux.h"
|
||||
#include "../../Common/IntToString.h"
|
||||
#include "../../Common/StringConvert.h"
|
||||
|
||||
@@ -76,14 +77,6 @@ static const char * const k_Methods[] =
|
||||
static const UInt32 kMetadataBlockSizeLog = 13;
|
||||
static const UInt32 kMetadataBlockSize = (1 << kMetadataBlockSizeLog);
|
||||
|
||||
#define MY_S_IFIFO 0x1000
|
||||
#define MY_S_IFCHR 0x2000
|
||||
#define MY_S_IFDIR 0x4000
|
||||
#define MY_S_IFBLK 0x6000
|
||||
#define MY_S_IFREG 0x8000
|
||||
#define MY_S_IFLNK 0xA000
|
||||
#define MY_S_IFSOCK 0xC000
|
||||
|
||||
enum
|
||||
{
|
||||
kType_IPC,
|
||||
@@ -99,8 +92,8 @@ enum
|
||||
static const UInt32 k_TypeToMode[] =
|
||||
{
|
||||
0,
|
||||
MY_S_IFDIR, MY_S_IFREG, MY_S_IFLNK, MY_S_IFBLK, MY_S_IFCHR, MY_S_IFIFO, MY_S_IFSOCK,
|
||||
MY_S_IFDIR, MY_S_IFREG, MY_S_IFLNK, MY_S_IFBLK, MY_S_IFCHR, MY_S_IFIFO, MY_S_IFSOCK
|
||||
MY_LIN_S_IFDIR, MY_LIN_S_IFREG, MY_LIN_S_IFLNK, MY_LIN_S_IFBLK, MY_LIN_S_IFCHR, MY_LIN_S_IFIFO, MY_LIN_S_IFSOCK,
|
||||
MY_LIN_S_IFDIR, MY_LIN_S_IFREG, MY_LIN_S_IFLNK, MY_LIN_S_IFBLK, MY_LIN_S_IFCHR, MY_LIN_S_IFIFO, MY_LIN_S_IFSOCK
|
||||
};
|
||||
|
||||
|
||||
@@ -939,7 +932,7 @@ static const Byte kArcProps[] =
|
||||
kpidHeadersSize,
|
||||
kpidFileSystem,
|
||||
kpidMethod,
|
||||
kpidBlock,
|
||||
kpidClusterSize,
|
||||
kpidBigEndian,
|
||||
kpidCTime,
|
||||
kpidCharacts
|
||||
@@ -1850,7 +1843,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
prop = res;
|
||||
break;
|
||||
}
|
||||
case kpidBlock: prop = _h.BlockSize; break;
|
||||
case kpidClusterSize: prop = _h.BlockSize; break;
|
||||
case kpidBigEndian: prop = _h.be; break;
|
||||
case kpidCTime:
|
||||
if (_h.CTime != 0)
|
||||
@@ -2111,11 +2104,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
int res = NExtract::NOperationResult::kDataError;
|
||||
{
|
||||
CMyComPtr<ISequentialInStream> inSeqStream;
|
||||
CMyComPtr<IInStream> inStream;
|
||||
HRESULT hres = GetStream(index, &inSeqStream);
|
||||
if (inSeqStream)
|
||||
inSeqStream.QueryInterface(IID_IInStream, &inStream);
|
||||
if (hres == S_FALSE || !inStream)
|
||||
if (hres == S_FALSE || !inSeqStream)
|
||||
{
|
||||
if (hres == E_OUTOFMEMORY)
|
||||
return hres;
|
||||
@@ -2124,9 +2114,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
else
|
||||
{
|
||||
RINOK(hres);
|
||||
if (inStream)
|
||||
{
|
||||
HRESULT hres = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
|
||||
HRESULT hres = copyCoder->Code(inSeqStream, outStream, NULL, NULL, progress);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
if (copyCoderSpec->TotalSize == unpackSize)
|
||||
@@ -2143,8 +2132,10 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RINOK(extractCallback->SetOperationResult(res));
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -639,6 +639,7 @@ void CHandler::Init()
|
||||
_forceCodePage = false;
|
||||
// _codePage = CP_OEMCP;
|
||||
_curCodePage = _specifiedCodePage = CP_UTF8; // CP_OEMCP;
|
||||
_thereIsPaxExtendedHeader = false;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "../../../Common/ComTry.h"
|
||||
#include "../../../Common/Defs.h"
|
||||
#include "../../../Common/MyLinux.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/UTFConvert.h"
|
||||
|
||||
@@ -113,7 +114,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(callback->GetProperty(i, kpidPosixAttrib, &prop));
|
||||
if (prop.vt == VT_EMPTY)
|
||||
ui.Mode = 0777 | (ui.IsDir ? 0040000 : 0100000);
|
||||
ui.Mode =
|
||||
MY_LIN_S_IRWXO
|
||||
| MY_LIN_S_IRWXG
|
||||
| MY_LIN_S_IRWXU
|
||||
| (ui.IsDir ? MY_LIN_S_IFDIR : MY_LIN_S_IFREG);
|
||||
else if (prop.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
else
|
||||
|
||||
@@ -564,7 +564,7 @@ HRESULT CInArchive::ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &la
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::FillRefs(CFileSet &fs, int fileIndex, int parent, int numRecurseAllowed)
|
||||
HRESULT CInArchive::FillRefs(CFileSet &fs, unsigned fileIndex, int parent, int numRecurseAllowed)
|
||||
{
|
||||
if ((_numRefs & 0xFFF) == 0)
|
||||
{
|
||||
|
||||
@@ -252,7 +252,7 @@ struct CItem
|
||||
bool IsInline;
|
||||
CByteBuffer InlineData;
|
||||
CRecordVector<CMyExtent> Extents;
|
||||
CRecordVector<int> SubFiles;
|
||||
CUIntVector SubFiles;
|
||||
|
||||
void Parse(const Byte *buf);
|
||||
|
||||
@@ -282,7 +282,7 @@ struct CItem
|
||||
struct CRef
|
||||
{
|
||||
int Parent;
|
||||
int FileIndex;
|
||||
unsigned FileIndex;
|
||||
};
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ class CInArchive
|
||||
HRESULT ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed);
|
||||
|
||||
HRESULT Open2();
|
||||
HRESULT FillRefs(CFileSet &fs, int fileIndex, int parent, int numRecurseAllowed);
|
||||
HRESULT FillRefs(CFileSet &fs, unsigned fileIndex, int parent, int numRecurseAllowed);
|
||||
|
||||
UInt64 _processedProgressBytes;
|
||||
|
||||
|
||||
@@ -599,17 +599,17 @@ enum
|
||||
kpidSavedState
|
||||
};
|
||||
|
||||
static const STATPROPSTG kArcProps[] =
|
||||
static const CStatProp kArcProps[] =
|
||||
{
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidOffset, VT_UI8},
|
||||
{ NULL, kpidCTime, VT_FILETIME},
|
||||
{ NULL, kpidClusterSize, VT_UI8},
|
||||
{ NULL, kpidMethod, VT_BSTR},
|
||||
{ (LPOLESTR)L"Parent", kpidParent, VT_BSTR},
|
||||
{ "Parent", kpidParent, VT_BSTR},
|
||||
{ NULL, kpidCreatorApp, VT_BSTR},
|
||||
{ NULL, kpidHostOS, VT_BSTR},
|
||||
{ (LPOLESTR)L"Saved State", kpidSavedState, VT_BOOL},
|
||||
{ "Saved State", kpidSavedState, VT_BOOL},
|
||||
{ NULL, kpidId, VT_BSTR}
|
||||
};
|
||||
|
||||
@@ -682,9 +682,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
s += " -> ";
|
||||
const CHandler *p = this;
|
||||
while (p != 0 && p->NeedParent())
|
||||
while (p && p->NeedParent())
|
||||
p = p->Parent;
|
||||
if (p == 0)
|
||||
if (!p)
|
||||
s += '?';
|
||||
else
|
||||
s += p->Footer.GetTypeString();
|
||||
@@ -750,26 +750,24 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback *openArchiveCallback, unsigned level)
|
||||
{
|
||||
Close();
|
||||
Stream = stream;
|
||||
if (level > (1 << 12)) // Maybe we need to increase that limit
|
||||
return S_FALSE;
|
||||
|
||||
RINOK(Open3());
|
||||
|
||||
if (child && memcmp(child->Dyn.ParentId, Footer.Id, 16) != 0)
|
||||
return S_FALSE;
|
||||
if (Footer.Type != kDiskType_Diff)
|
||||
return S_OK;
|
||||
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
|
||||
if (openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback) != S_OK)
|
||||
{
|
||||
// return S_FALSE;
|
||||
}
|
||||
CMyComPtr<IInStream> nextStream;
|
||||
|
||||
bool useRelative;
|
||||
UString name;
|
||||
|
||||
if (!Dyn.RelativeParentNameFromLocator.IsEmpty())
|
||||
{
|
||||
useRelative = true;
|
||||
@@ -780,11 +778,17 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
||||
useRelative = false;
|
||||
name = Dyn.ParentName;
|
||||
}
|
||||
|
||||
Dyn.RelativeNameWasUsed = useRelative;
|
||||
|
||||
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
|
||||
openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
|
||||
|
||||
if (openVolumeCallback)
|
||||
{
|
||||
CMyComPtr<IInStream> nextStream;
|
||||
HRESULT res = openVolumeCallback->GetStream(name, &nextStream);
|
||||
|
||||
if (res == S_FALSE)
|
||||
{
|
||||
if (useRelative && Dyn.ParentName != Dyn.RelativeParentNameFromLocator)
|
||||
@@ -793,19 +797,35 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
||||
if (res == S_OK)
|
||||
Dyn.RelativeNameWasUsed = false;
|
||||
}
|
||||
if (res == S_FALSE)
|
||||
}
|
||||
|
||||
if (res != S_OK && res != S_FALSE)
|
||||
return res;
|
||||
|
||||
if (res == S_FALSE || !nextStream)
|
||||
{
|
||||
UString s;
|
||||
s.SetFromAscii("Missing volume : ");
|
||||
s += name;
|
||||
AddErrorMessage(s);
|
||||
return S_OK;
|
||||
}
|
||||
RINOK(res);
|
||||
|
||||
Parent = new CHandler;
|
||||
ParentStream = Parent;
|
||||
|
||||
res = Parent->Open2(nextStream, this, openArchiveCallback, level + 1);
|
||||
if (res == S_FALSE)
|
||||
|
||||
if (res != S_OK)
|
||||
{
|
||||
Parent = NULL;
|
||||
ParentStream.Release();
|
||||
if (res == E_ABORT)
|
||||
return res;
|
||||
if (res != S_FALSE)
|
||||
{
|
||||
// we must show that error code
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -813,7 +833,7 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
||||
while (p->NeedParent())
|
||||
{
|
||||
p = p->Parent;
|
||||
if (p == 0)
|
||||
if (!p)
|
||||
{
|
||||
AddErrorMessage(L"Can't open parent VHD file:");
|
||||
AddErrorMessage(Dyn.ParentName);
|
||||
@@ -824,12 +844,13 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
void CHandler::CloseAtError()
|
||||
{
|
||||
_phySize = 0;
|
||||
Bat.Clear();
|
||||
NumUsedBlocks = 0;
|
||||
Parent = 0;
|
||||
Parent = NULL;
|
||||
Stream.Release();
|
||||
ParentStream.Release();
|
||||
Dyn.Clear();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -56,7 +56,7 @@ enum
|
||||
kpidBootImage
|
||||
};
|
||||
|
||||
static const STATPROPSTG kArcProps[] =
|
||||
static const CStatProp kArcProps[] =
|
||||
{
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidPackSize, VT_UI8},
|
||||
@@ -69,8 +69,8 @@ static const STATPROPSTG kArcProps[] =
|
||||
{ NULL, kpidIsVolume, VT_BOOL},
|
||||
{ NULL, kpidVolume, VT_UI4},
|
||||
{ NULL, kpidNumVolumes, VT_UI4},
|
||||
{ (LPOLESTR)L"Images", kpidNumImages, VT_UI4},
|
||||
{ (LPOLESTR)L"Boot Image", kpidBootImage, VT_UI4}
|
||||
{ "Images", kpidNumImages, VT_UI4},
|
||||
{ "Boot Image", kpidBootImage, VT_UI4}
|
||||
};
|
||||
|
||||
|
||||
@@ -1028,6 +1028,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCal
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_firstVolumeIndex = -1;
|
||||
@@ -1093,7 +1094,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
CMyComPtr<ICompressProgressInfo> progress = lps;
|
||||
lps->Init(extractCallback, false);
|
||||
|
||||
for (i = 0; i < numItems;
|
||||
for (i = 0;; i++,
|
||||
currentTotalUnPacked += currentItemUnPacked)
|
||||
{
|
||||
currentItemUnPacked = 0;
|
||||
@@ -1102,14 +1103,18 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
lps->OutSize = currentTotalUnPacked;
|
||||
|
||||
RINOK(lps->SetCur());
|
||||
|
||||
if (i >= numItems)
|
||||
break;
|
||||
|
||||
UInt32 index = allFilesMode ? i : indices[i];
|
||||
i++;
|
||||
Int32 askMode = testMode ?
|
||||
NExtract::NAskMode::kTest :
|
||||
NExtract::NAskMode::kExtract;
|
||||
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||
|
||||
if (index >= _db.SortedItems.Size())
|
||||
{
|
||||
if (!testMode && !realOutStream)
|
||||
@@ -1153,13 +1158,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
continue;
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
Int32 opRes = NExtract::NOperationResult::kOK;
|
||||
|
||||
if (streamIndex != prevSuccessStreamIndex || realOutStream)
|
||||
{
|
||||
Byte digest[kHashSize];
|
||||
const CVolume &vol = _volumes[si.PartNumber];
|
||||
bool needDigest = !si.IsEmptyHash();
|
||||
|
||||
HRESULT res = unpacker.Unpack(vol.Stream, si.Resource, vol.Header, &_db,
|
||||
realOutStream, progress, needDigest ? digest : NULL);
|
||||
|
||||
if (res == S_OK)
|
||||
{
|
||||
if (!needDigest || memcmp(digest, si.Hash, kHashSize) == 0)
|
||||
@@ -1174,13 +1182,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
else
|
||||
return res;
|
||||
}
|
||||
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(opRes));
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _db.SortedItems.Size() +
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "../../Common/StreamObjects.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "../../Compress/XPressDecoder.h"
|
||||
#include "../../Compress/XpressDecoder.h"
|
||||
|
||||
#include "../Common/OutStreamWithSha1.h"
|
||||
|
||||
@@ -256,6 +256,11 @@ HRESULT CUnpacker::Unpack2(
|
||||
_solidIndex = resource.SolidIndex;
|
||||
_unpackedChunkIndex = chunkIndex;
|
||||
|
||||
if (cur < offsetInChunk)
|
||||
return E_FAIL;
|
||||
|
||||
cur -= offsetInChunk;
|
||||
|
||||
if (cur > rem)
|
||||
cur = (size_t)rem;
|
||||
|
||||
|
||||
@@ -221,6 +221,7 @@ namespace NHeaderFlags
|
||||
const UInt32 kXPRESS = (UInt32)1 << 17;
|
||||
const UInt32 kLZX = (UInt32)1 << 18;
|
||||
const UInt32 kLZMS = (UInt32)1 << 19;
|
||||
const UInt32 kXPRESS2 = (UInt32)1 << 21; // XPRESS with nonstandard chunk size ?
|
||||
|
||||
const UInt32 kMethodMask = 0xFFFE0000;
|
||||
}
|
||||
@@ -277,7 +278,8 @@ struct CHeader
|
||||
return (!IsCompressed()
|
||||
|| (Flags & NHeaderFlags::kLZX) != 0
|
||||
|| (Flags & NHeaderFlags::kXPRESS) != 0
|
||||
|| (Flags & NHeaderFlags::kLZMS) != 0);
|
||||
|| (Flags & NHeaderFlags::kLZMS) != 0
|
||||
|| (Flags & NHeaderFlags::kXPRESS2) != 0);
|
||||
}
|
||||
|
||||
unsigned GetMethod() const
|
||||
@@ -289,6 +291,7 @@ struct CHeader
|
||||
if (mask == NHeaderFlags::kXPRESS) return NMethod::kXPRESS;
|
||||
if (mask == NHeaderFlags::kLZX) return NMethod::kLZX;
|
||||
if (mask == NHeaderFlags::kLZMS) return NMethod::kLZMS;
|
||||
if (mask == NHeaderFlags::kXPRESS2) return NMethod::kXPRESS;
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "../../../C/CpuArch.h"
|
||||
|
||||
#include "../../Common/ComTry.h"
|
||||
#include "../../Common/MyLinux.h"
|
||||
#include "../../Common/MyXml.h"
|
||||
#include "../../Common/StringToInt.h"
|
||||
#include "../../Common/UTFConvert.h"
|
||||
@@ -511,10 +512,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
if (item.ModeDefined)
|
||||
{
|
||||
UInt32 mode = item.Mode;
|
||||
const UInt32 k_PosixAttrib_Dir = (1 << 14);
|
||||
const UInt32 k_PosixAttrib_RegFile = (1 << 15);
|
||||
if ((mode & 0xF000) == 0)
|
||||
mode |= (item.IsDir ? k_PosixAttrib_Dir : k_PosixAttrib_RegFile);
|
||||
if ((mode & MY_LIN_S_IFMT) == 0)
|
||||
mode |= (item.IsDir ? MY_LIN_S_IFDIR : MY_LIN_S_IFREG);
|
||||
prop = mode;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -153,35 +153,6 @@ namespace NFileHeader
|
||||
};
|
||||
}
|
||||
|
||||
namespace NUnixAttrib
|
||||
{
|
||||
const UInt32 kIFMT = 0170000; // file type mask
|
||||
|
||||
const UInt32 kIFDIR = 0040000; // directory
|
||||
const UInt32 kIFREG = 0100000; // regular file
|
||||
const UInt32 kIFSOCK = 0140000; // socket (BSD, not SysV or Amiga)
|
||||
const UInt32 kIFLNK = 0120000; // symbolic link (not SysV, Amiga)
|
||||
const UInt32 kIFBLK = 0060000; // block special (not Amiga)
|
||||
const UInt32 kIFCHR = 0020000; // character special (not Amiga)
|
||||
const UInt32 kIFIFO = 0010000; // fifo (BCC, not MSC or Amiga)
|
||||
|
||||
const UInt32 kISUID = 04000; // set user id on execution
|
||||
const UInt32 kISGID = 02000; // set group id on execution
|
||||
const UInt32 kISVTX = 01000; // directory permissions control
|
||||
const UInt32 kENFMT = kISGID; // record locking enforcement flag
|
||||
const UInt32 kIRWXU = 00700; // read, write, execute: owner
|
||||
const UInt32 kIRUSR = 00400; // read permission: owner
|
||||
const UInt32 kIWUSR = 00200; // write permission: owner
|
||||
const UInt32 kIXUSR = 00100; // execute permission: owner
|
||||
const UInt32 kIRWXG = 00070; // read, write, execute: group
|
||||
const UInt32 kIRGRP = 00040; // read permission: group
|
||||
const UInt32 kIWGRP = 00020; // write permission: group
|
||||
const UInt32 kIXGRP = 00010; // execute permission: group
|
||||
const UInt32 kIRWXO = 00007; // read, write, execute: other
|
||||
const UInt32 kIROTH = 00004; // read permission: other
|
||||
const UInt32 kIWOTH = 00002; // write permission: other
|
||||
const UInt32 kIXOTH = 00001; // execute permission: other
|
||||
}
|
||||
|
||||
namespace NAmigaAttrib
|
||||
{
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ZipHeader.h"
|
||||
#include "ZipItem.h"
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#include "../../../Common/MyLinux.h"
|
||||
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
|
||||
#include "ZipItem.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NZip {
|
||||
|
||||
@@ -114,7 +117,7 @@ bool CItem::IsDir() const
|
||||
case NHostOS::kMVS:
|
||||
return false; // change it throw kUnknownAttributes;
|
||||
case NHostOS::kUnix:
|
||||
return ((highAttrib & NUnixAttrib::kIFMT) == NUnixAttrib::kIFDIR);
|
||||
return MY_LIN_S_ISDIR(highAttrib);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -151,7 +154,7 @@ bool CItem::GetPosixAttrib(UInt32 &attrib) const
|
||||
}
|
||||
attrib = 0;
|
||||
if (IsDir())
|
||||
attrib = NUnixAttrib::kIFDIR;
|
||||
attrib = MY_LIN_S_IFDIR;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -723,7 +723,7 @@ static HRESULT Update2(
|
||||
|
||||
CThreads threads;
|
||||
CRecordVector<HANDLE> compressingCompletedEvents;
|
||||
CRecordVector<int> threadIndices; // list threads in order of updateItems
|
||||
CUIntVector threadIndices; // list threads in order of updateItems
|
||||
|
||||
{
|
||||
RINOK(memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize)));
|
||||
@@ -759,7 +759,7 @@ static HRESULT Update2(
|
||||
|
||||
while (itemIndex < updateItems.Size())
|
||||
{
|
||||
if ((UInt32)threadIndices.Size() < numThreads && mtItemIndex < updateItems.Size())
|
||||
if (threadIndices.Size() < numThreads && mtItemIndex < updateItems.Size())
|
||||
{
|
||||
CUpdateItem &ui = updateItems[mtItemIndex++];
|
||||
if (!ui.NewData)
|
||||
|
||||
@@ -554,14 +554,6 @@ SOURCE=..\..\Common\CreateCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CWrappers.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -1285,14 +1277,6 @@ SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -77,7 +77,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\FindSignature.obj \
|
||||
$O\HandlerOut.obj \
|
||||
@@ -94,7 +93,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -546,14 +546,6 @@ SOURCE=..\..\Common\CreateCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CWrappers.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -812,14 +804,6 @@ SOURCE=..\..\Compress\LzmaEncoder.h
|
||||
|
||||
SOURCE=..\..\Compress\LzmaRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\RangeCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\RangeCoderBit.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive"
|
||||
|
||||
@@ -865,14 +849,6 @@ SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -67,7 +67,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
@@ -83,7 +82,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -211,122 +211,6 @@ SOURCE=..\..\UI\FileManager\Test.bmp
|
||||
# Begin Group "Archive"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "7z"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zCompressionMode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zDecode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zDecode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zEncode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zEncode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHeader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHeader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zOut.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zProperties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zSpecStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zSpecStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zUpdate.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zUpdate.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
@@ -403,6 +287,114 @@ SOURCE=..\..\Archive\Common\ParseProperties.cpp
|
||||
SOURCE=..\..\Archive\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7z"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zCompressionMode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zDecode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zDecode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zEncode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zEncode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHeader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHeader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zOut.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zProperties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zSpecStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zSpecStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zUpdate.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zUpdate.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\IArchive.h
|
||||
|
||||
@@ -49,7 +49,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
@@ -63,7 +62,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -7,12 +7,12 @@ COMMON_OBJS = \
|
||||
$O\CRC.obj \
|
||||
$O\CrcReg.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\MyString.obj \
|
||||
$O\MyVector.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\Sha256Reg.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
$O\MyVector.obj \
|
||||
$O\Wildcard.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
@@ -42,7 +42,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
@@ -51,7 +50,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zCompressionMode.obj \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHeader.obj \
|
||||
$O\7zIn.obj \
|
||||
|
||||
@@ -42,7 +42,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
@@ -53,7 +52,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zCompressionMode.obj \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHeader.obj \
|
||||
$O\7zIn.obj \
|
||||
|
||||
@@ -61,6 +61,7 @@ AR_OBJS = \
|
||||
$O\DeflateProps.obj \
|
||||
$O\DmgHandler.obj \
|
||||
$O\ElfHandler.obj \
|
||||
$O\ExtHandler.obj \
|
||||
$O\FatHandler.obj \
|
||||
$O\FlvHandler.obj \
|
||||
$O\GzHandler.obj \
|
||||
@@ -92,7 +93,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\FindSignature.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
@@ -110,7 +110,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -283,6 +283,10 @@ SOURCE=..\..\..\Common\MyInitGuid.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyLinux.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyMap.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -2431,6 +2435,10 @@ SOURCE=..\..\Archive\ElfHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\ExtHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\FatHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -47,7 +47,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
@@ -61,7 +60,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -513,10 +513,11 @@ static int main2(int numArgs, const char *args[])
|
||||
if (parser[NKey::kEOS].ThereIs || stdInMode)
|
||||
throw "Can not use stdin in this mode";
|
||||
|
||||
if (fileSize > 0xF0000000)
|
||||
size_t inSize = (size_t)fileSize;
|
||||
|
||||
if (inSize != fileSize)
|
||||
throw "File is too big";
|
||||
|
||||
size_t inSize = (size_t)fileSize;
|
||||
Byte *inBuffer = NULL;
|
||||
|
||||
if (inSize != 0)
|
||||
@@ -535,7 +536,13 @@ static int main2(int numArgs, const char *args[])
|
||||
if (encodeMode)
|
||||
{
|
||||
// we allocate 105% of original size for output buffer
|
||||
outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
|
||||
UInt64 outSize64 = fileSize / 20 * 21 + (1 << 16);
|
||||
|
||||
outSize = (size_t)outSize64;
|
||||
|
||||
if (outSize != outSize64)
|
||||
throw "File is too big";
|
||||
|
||||
if (outSize != 0)
|
||||
{
|
||||
outBuffer = (Byte *)MyAlloc((size_t)outSize);
|
||||
@@ -561,7 +568,7 @@ static int main2(int numArgs, const char *args[])
|
||||
|
||||
outSize = (size_t)outSize64;
|
||||
if (outSize != outSize64)
|
||||
throw "too big";
|
||||
throw "Unpack size is too big";
|
||||
if (outSize != 0)
|
||||
{
|
||||
outBuffer = (Byte *)MyAlloc(outSize);
|
||||
|
||||
@@ -366,6 +366,10 @@ SOURCE=..\..\..\..\C\7zCrcOpt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zTypes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
@@ -464,10 +468,6 @@ SOURCE=..\..\..\..\C\Threads.c
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Types.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -117,14 +117,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -221,14 +213,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -72,7 +72,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
@@ -81,7 +80,6 @@ AR_COMMON_OBJS = \
|
||||
7Z_OBJS = \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zIn.obj \
|
||||
$O\7zRegister.obj \
|
||||
|
||||
@@ -157,14 +157,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -205,14 +197,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -67,14 +67,12 @@ FM_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zIn.obj \
|
||||
$O\7zRegister.obj \
|
||||
|
||||
@@ -149,14 +149,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -197,14 +189,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -92,7 +92,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
@@ -100,7 +99,6 @@ AR_COMMON_OBJS = \
|
||||
7Z_OBJS = \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zIn.obj \
|
||||
$O\7zRegister.obj \
|
||||
|
||||
@@ -86,26 +86,34 @@ STDMETHODIMP CClusterInStream::Read(void *data, UInt32 size, UInt32 *processedSi
|
||||
*processedSize = 0;
|
||||
if (_virtPos >= Size)
|
||||
return S_OK;
|
||||
{
|
||||
UInt64 rem = Size - _virtPos;
|
||||
if (size > rem)
|
||||
size = (UInt32)rem;
|
||||
}
|
||||
if (size == 0)
|
||||
return S_OK;
|
||||
|
||||
if (_curRem == 0)
|
||||
{
|
||||
UInt32 blockSize = (UInt32)1 << BlockSizeLog;
|
||||
UInt32 virtBlock = (UInt32)(_virtPos >> BlockSizeLog);
|
||||
UInt32 offsetInBlock = (UInt32)_virtPos & (blockSize - 1);
|
||||
UInt32 phyBlock = Vector[virtBlock];
|
||||
const UInt32 blockSize = (UInt32)1 << BlockSizeLog;
|
||||
const UInt32 virtBlock = (UInt32)(_virtPos >> BlockSizeLog);
|
||||
const UInt32 offsetInBlock = (UInt32)_virtPos & (blockSize - 1);
|
||||
const UInt32 phyBlock = Vector[virtBlock];
|
||||
|
||||
UInt64 newPos = StartOffset + ((UInt64)phyBlock << BlockSizeLog) + offsetInBlock;
|
||||
if (newPos != _physPos)
|
||||
{
|
||||
_physPos = newPos;
|
||||
RINOK(SeekToPhys());
|
||||
}
|
||||
|
||||
_curRem = blockSize - offsetInBlock;
|
||||
|
||||
for (int i = 1; i < 64 && (virtBlock + i) < (UInt32)Vector.Size() && phyBlock + i == Vector[virtBlock + i]; i++)
|
||||
_curRem += (UInt32)1 << BlockSizeLog;
|
||||
UInt64 rem = Size - _virtPos;
|
||||
if (_curRem > rem)
|
||||
_curRem = (UInt32)rem;
|
||||
}
|
||||
|
||||
if (size > _curRem)
|
||||
size = _curRem;
|
||||
HRESULT res = Stream->Read(data, size, &size);
|
||||
|
||||
@@ -73,11 +73,11 @@ class CClusterInStream:
|
||||
UInt64 _physPos;
|
||||
UInt32 _curRem;
|
||||
public:
|
||||
CMyComPtr<IInStream> Stream;
|
||||
UInt64 StartOffset;
|
||||
UInt64 Size;
|
||||
unsigned BlockSizeLog;
|
||||
UInt64 Size;
|
||||
CMyComPtr<IInStream> Stream;
|
||||
CRecordVector<UInt32> Vector;
|
||||
UInt64 StartOffset;
|
||||
|
||||
HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
|
||||
|
||||
|
||||
@@ -90,51 +90,65 @@ HRESULT ParseMtProp(const UString &name, const PROPVARIANT &prop, UInt32 default
|
||||
return ParsePropToUInt32(name, prop, numThreads);
|
||||
}
|
||||
|
||||
static HRESULT StringToDictSize(const UString &s, UInt32 &dicSize)
|
||||
|
||||
static HRESULT StringToDictSize(const UString &s, NCOM::CPropVariant &destProp)
|
||||
{
|
||||
const wchar_t *end;
|
||||
UInt32 number = ConvertStringToUInt32(s, &end);
|
||||
unsigned numDigits = (unsigned)(end - s);
|
||||
if (numDigits == 0 || s.Len() > numDigits + 1)
|
||||
return E_INVALIDARG;
|
||||
const unsigned kLogDictSizeLimit = 32;
|
||||
|
||||
if (s.Len() == numDigits)
|
||||
{
|
||||
if (number >= kLogDictSizeLimit)
|
||||
if (number >= 64)
|
||||
return E_INVALIDARG;
|
||||
dicSize = (UInt32)1 << (unsigned)number;
|
||||
if (number < 32)
|
||||
destProp = (UInt32)((UInt32)1 << (unsigned)number);
|
||||
else
|
||||
destProp = (UInt64)((UInt64)1 << (unsigned)number);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
unsigned numBits;
|
||||
|
||||
switch (MyCharLower_Ascii(s[numDigits]))
|
||||
{
|
||||
case 'b': dicSize = number; return S_OK;
|
||||
case 'b': destProp = number; return S_OK;
|
||||
case 'k': numBits = 10; break;
|
||||
case 'm': numBits = 20; break;
|
||||
case 'g': numBits = 30; break;
|
||||
default: return E_INVALIDARG;
|
||||
}
|
||||
if (number >= ((UInt32)1 << (kLogDictSizeLimit - numBits)))
|
||||
return E_INVALIDARG;
|
||||
dicSize = number << numBits;
|
||||
|
||||
if (number < ((UInt32)1 << (32 - numBits)))
|
||||
destProp = (UInt32)(number << numBits);
|
||||
else
|
||||
destProp = (UInt64)((UInt64)number << numBits);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT PROPVARIANT_to_DictSize(const PROPVARIANT &prop, UInt32 &resValue)
|
||||
|
||||
static HRESULT PROPVARIANT_to_DictSize(const PROPVARIANT &prop, NCOM::CPropVariant &destProp)
|
||||
{
|
||||
if (prop.vt == VT_UI4)
|
||||
{
|
||||
UInt32 v = prop.ulVal;
|
||||
if (v >= 32)
|
||||
if (v >= 64)
|
||||
return E_INVALIDARG;
|
||||
resValue = (UInt32)1 << v;
|
||||
if (v < 32)
|
||||
destProp = (UInt32)((UInt32)1 << (unsigned)v);
|
||||
else
|
||||
destProp = (UInt64)((UInt64)1 << (unsigned)v);
|
||||
return S_OK;
|
||||
}
|
||||
if (prop.vt == VT_BSTR)
|
||||
return StringToDictSize(prop.bstrVal, resValue);
|
||||
return StringToDictSize(prop.bstrVal, destProp);
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
|
||||
void CProps::AddProp32(PROPID propid, UInt32 level)
|
||||
{
|
||||
CProp &prop = Props.AddNew();
|
||||
@@ -275,10 +289,10 @@ static void SplitParams(const UString &srcString, UStringVector &subStrings)
|
||||
{
|
||||
subStrings.Clear();
|
||||
UString s;
|
||||
int len = srcString.Len();
|
||||
unsigned len = srcString.Len();
|
||||
if (len == 0)
|
||||
return;
|
||||
for (int i = 0; i < len; i++)
|
||||
for (unsigned i = 0; i < len; i++)
|
||||
{
|
||||
wchar_t c = srcString[i];
|
||||
if (c == L':')
|
||||
@@ -336,9 +350,7 @@ HRESULT CMethodProps::SetParam(const UString &name, const UString &value)
|
||||
|
||||
if (IsLogSizeProp(prop.Id))
|
||||
{
|
||||
UInt32 dicSize;
|
||||
RINOK(StringToDictSize(value, dicSize));
|
||||
prop.Value = dicSize;
|
||||
RINOK(StringToDictSize(value, prop.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -406,9 +418,7 @@ HRESULT CMethodProps::ParseParamsFromPROPVARIANT(const UString &realName, const
|
||||
|
||||
if (IsLogSizeProp(prop.Id))
|
||||
{
|
||||
UInt32 dicSize;
|
||||
RINOK(PROPVARIANT_to_DictSize(value, dicSize));
|
||||
prop.Value = dicSize;
|
||||
RINOK(PROPVARIANT_to_DictSize(value, prop.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "../../Common/MyCom.h"
|
||||
|
||||
#include "../../Windows/Defs.h"
|
||||
#include "../../Windows/PropVariant.h"
|
||||
|
||||
#include "../ICoder.h"
|
||||
|
||||
@@ -23,7 +22,7 @@ extern const CHasherInfo *g_Hashers[];
|
||||
static void SetPropFromAscii(const char *s, PROPVARIANT *prop) throw()
|
||||
{
|
||||
UINT len = (UINT)strlen(s);
|
||||
OLECHAR *dest = ::SysAllocStringLen(NULL, len);
|
||||
BSTR dest = ::SysAllocStringLen(NULL, len);
|
||||
if (dest)
|
||||
{
|
||||
for (UINT i = 0; i <= len; i++)
|
||||
|
||||
@@ -38,7 +38,20 @@ HRESULT SetLzma2Prop(PROPID propID, const PROPVARIANT &prop, CLzma2EncProps &lzm
|
||||
switch (propID)
|
||||
{
|
||||
case NCoderPropID::kBlockSize:
|
||||
if (prop.vt != VT_UI4) return E_INVALIDARG; lzma2Props.blockSize = prop.ulVal; break;
|
||||
{
|
||||
if (prop.vt == VT_UI4)
|
||||
lzma2Props.blockSize = prop.ulVal;
|
||||
else if (prop.vt == VT_UI8)
|
||||
{
|
||||
size_t v = (size_t)prop.uhVal.QuadPart;
|
||||
if (v != prop.uhVal.QuadPart)
|
||||
return E_INVALIDARG;
|
||||
lzma2Props.blockSize = v;
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
break;
|
||||
}
|
||||
case NCoderPropID::kNumThreads:
|
||||
if (prop.vt != VT_UI4) return E_INVALIDARG; lzma2Props.numTotalThreads = (int)(prop.ulVal); break;
|
||||
default:
|
||||
|
||||
@@ -457,17 +457,16 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
|
||||
HRESULT CDecoder::Code(const Byte *inData, size_t inSize, UInt32 outSize)
|
||||
{
|
||||
if (_pos == _winSize)
|
||||
{
|
||||
_pos = 0;
|
||||
_overDict = true;
|
||||
}
|
||||
|
||||
if (!_keepHistory)
|
||||
{
|
||||
_pos = 0;
|
||||
_overDict = false;
|
||||
}
|
||||
else if (_pos == _winSize)
|
||||
{
|
||||
_pos = 0;
|
||||
_overDict = true;
|
||||
}
|
||||
|
||||
_writePos = _pos;
|
||||
_unpackedData = _win + _pos;
|
||||
|
||||
@@ -23,7 +23,7 @@ void CBitDecoder::Prepare2() throw()
|
||||
|
||||
size_t rem = _bufLim - _buf;
|
||||
if (rem != 0)
|
||||
memcpy(_bufBase, _buf, rem);
|
||||
memmove(_bufBase, _buf, rem);
|
||||
|
||||
_bufLim = _bufBase + rem;
|
||||
_processedSize += (_buf - _bufBase);
|
||||
|
||||
@@ -163,6 +163,7 @@ Handler GUIDs:
|
||||
0C xz
|
||||
0D ppmd
|
||||
|
||||
C7 Ext
|
||||
C8 VMDK
|
||||
C9 VDI
|
||||
CA Qcow
|
||||
|
||||
@@ -3,10 +3,16 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
// #include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <wchar.h>
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#include "../../../../C/Sort.h"
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#include "../../../Common/UTFConvert.h"
|
||||
#include "../../../Common/Wildcard.h"
|
||||
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
@@ -556,6 +562,9 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
|
||||
|
||||
Files.Alloc(numItems);
|
||||
|
||||
UString tempUString;
|
||||
AString tempAString;
|
||||
|
||||
UInt32 i;
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
@@ -567,12 +576,12 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
|
||||
|
||||
CProxyFile2 &file = Files[i];
|
||||
|
||||
#ifdef MY_CPU_LE
|
||||
const void *p;
|
||||
UInt32 size;
|
||||
UInt32 propType;
|
||||
RINOK(arc.GetRawProps->GetRawProp(i, kpidName, &p, &size, &propType));
|
||||
|
||||
#ifdef MY_CPU_LE
|
||||
if (p && propType == PROP_DATA_TYPE_wchar_t_PTR_Z_LE)
|
||||
{
|
||||
file.Name = (const wchar_t *)p;
|
||||
@@ -582,6 +591,16 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (p && propType == NPropDataType::kUtf8z)
|
||||
{
|
||||
tempAString = (const char *)p;
|
||||
ConvertUTF8ToUnicode(tempAString, tempUString);
|
||||
file.NameLen = tempUString.Len();
|
||||
file.Name = new wchar_t[file.NameLen + 1];
|
||||
file.NeedDeleteName = true;
|
||||
wmemcpy((wchar_t *)file.Name, tempUString.Ptr(), file.NameLen + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(arc.Archive->GetProperty(i, kpidName, &prop));
|
||||
@@ -595,7 +614,7 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
|
||||
file.NameLen = MyStringLen(s);
|
||||
file.Name = new wchar_t[file.NameLen + 1];
|
||||
file.NeedDeleteName = true;
|
||||
MyStringCopy((wchar_t *)file.Name, s);
|
||||
wmemcpy((wchar_t *)file.Name, s, file.NameLen + 1);
|
||||
}
|
||||
|
||||
UInt32 parent = (UInt32)(Int32)-1;
|
||||
|
||||
@@ -441,7 +441,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
|
||||
}
|
||||
}
|
||||
|
||||
if (_outFileStream != NULL)
|
||||
if (_outFileStream)
|
||||
{
|
||||
if (_processedFileInfo.MTimeDefined)
|
||||
_outFileStreamSpec->SetMTime(&_processedFileInfo.MTime);
|
||||
@@ -499,7 +499,6 @@ public:
|
||||
STDMETHOD(SetCompleted)(const UInt64 *completeValue);
|
||||
|
||||
// IUpdateCallback2
|
||||
STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator);
|
||||
STDMETHOD(GetUpdateItemInfo)(UInt32 index,
|
||||
Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive);
|
||||
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||
@@ -551,20 +550,14 @@ STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const UInt64 * /* completeValu
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG ** /* enumerator */)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
|
||||
Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive)
|
||||
{
|
||||
if (newData != NULL)
|
||||
if (newData)
|
||||
*newData = BoolToInt(true);
|
||||
if (newProperties != NULL)
|
||||
if (newProperties)
|
||||
*newProperties = BoolToInt(true);
|
||||
if (indexInArchive != NULL)
|
||||
if (indexInArchive)
|
||||
*indexInArchive = (UInt32)(Int32)-1;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -700,7 +693,7 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef
|
||||
return StringToBstr(Password, password);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Main function
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION PrintError("Unsupported Windows version"); return 1;
|
||||
@@ -716,12 +709,14 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
PrintStringLn(kHelpString);
|
||||
return 1;
|
||||
}
|
||||
|
||||
NDLL::CLibrary lib;
|
||||
if (!lib.Load(NDLL::GetModuleDirPrefix() + FTEXT(kDllName)))
|
||||
{
|
||||
PrintError("Can not load 7-zip library");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Func_CreateObject createObjectFunc = (Func_CreateObject)lib.GetProc("CreateObject");
|
||||
if (!createObjectFunc)
|
||||
{
|
||||
@@ -739,7 +734,9 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
}
|
||||
c = (char)MyCharLower_Ascii(command[0]);
|
||||
}
|
||||
|
||||
FString archiveName = CmdStringToFString(args[2]);
|
||||
|
||||
if (c == 'a')
|
||||
{
|
||||
// create archive command
|
||||
@@ -773,6 +770,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
dirItems.Add(di);
|
||||
}
|
||||
}
|
||||
|
||||
COutFileStream *outFileStreamSpec = new COutFileStream;
|
||||
CMyComPtr<IOutStream> outFileStream = outFileStreamSpec;
|
||||
if (!outFileStreamSpec->Create(archiveName, false))
|
||||
@@ -819,17 +817,21 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
*/
|
||||
|
||||
HRESULT result = outArchive->UpdateItems(outFileStream, dirItems.Size(), updateCallback);
|
||||
|
||||
updateCallbackSpec->Finilize();
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
PrintError("Update Error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
FOR_VECTOR (i, updateCallbackSpec->FailedFiles)
|
||||
{
|
||||
PrintNewLine();
|
||||
PrintError("Error for file", updateCallbackSpec->FailedFiles[i]);
|
||||
}
|
||||
|
||||
if (updateCallbackSpec->FailedFiles.Size() != 0)
|
||||
return 1;
|
||||
}
|
||||
@@ -842,6 +844,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
}
|
||||
|
||||
bool listCommand;
|
||||
|
||||
if (c == 'l')
|
||||
listCommand = true;
|
||||
else if (c == 'x')
|
||||
@@ -920,7 +923,27 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
extractCallbackSpec->PasswordIsDefined = false;
|
||||
// extractCallbackSpec->PasswordIsDefined = true;
|
||||
// extractCallbackSpec->Password = L"1";
|
||||
|
||||
/*
|
||||
const wchar_t *names[] =
|
||||
{
|
||||
L"mt",
|
||||
L"mtf"
|
||||
};
|
||||
const unsigned kNumProps = sizeof(names) / sizeof(names[0]);
|
||||
NCOM::CPropVariant values[kNumProps] =
|
||||
{
|
||||
(UInt32)1,
|
||||
false
|
||||
};
|
||||
CMyComPtr<ISetProperties> setProperties;
|
||||
archive->QueryInterface(IID_ISetProperties, (void **)&setProperties);
|
||||
if (setProperties)
|
||||
setProperties->SetProperties(names, values, kNumProps);
|
||||
*/
|
||||
|
||||
HRESULT result = archive->Extract(NULL, (UInt32)(Int32)(-1), false, extractCallback);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
PrintError("Extract Error");
|
||||
@@ -928,5 +951,6 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1329,5 +1329,5 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
|
||||
{
|
||||
}
|
||||
else
|
||||
throw 9815676711;
|
||||
throw 20150919;
|
||||
}
|
||||
|
||||
@@ -608,6 +608,10 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
_curSizeDefined = false;
|
||||
_index = index;
|
||||
|
||||
_diskFilePath.Empty();
|
||||
|
||||
// _fi.Clear();
|
||||
|
||||
#ifdef SUPPORT_LINKS
|
||||
// _CopyFile_Path.Empty();
|
||||
linkPath.Empty();
|
||||
@@ -1454,7 +1458,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes)
|
||||
}
|
||||
|
||||
#ifdef _USE_SECURITY_CODE
|
||||
if (_ntOptions.NtSecurity.Val && _arc->GetRawProps)
|
||||
if (!_stdOutMode && _extractMode && _ntOptions.NtSecurity.Val && _arc->GetRawProps)
|
||||
{
|
||||
const void *data;
|
||||
UInt32 dataSize;
|
||||
@@ -1497,7 +1501,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes)
|
||||
else
|
||||
NumFiles++;
|
||||
|
||||
if (_extractMode && _fi.AttribDefined)
|
||||
if (!_stdOutMode && _extractMode && _fi.AttribDefined)
|
||||
SetFileAttrib(_diskFilePath, _fi.Attrib);
|
||||
|
||||
RINOK(_extractCallback2->SetOperationResult(opRes, BoolToInt(_encrypted)));
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#define USE_POSIX_TIME
|
||||
#define USE_POSIX_TIME2
|
||||
@@ -39,6 +41,15 @@
|
||||
#include "../../../Windows/Thread.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(UNIX_USE_WIN_FILE)
|
||||
#define USE_WIN_FILE
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIN_FILE
|
||||
#include "../../../Windows/FileIO.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/StringToInt.h"
|
||||
@@ -50,6 +61,8 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static const UInt32 k_LZMA = 0x030101;
|
||||
|
||||
static const UInt64 kComplexInCommands = (UInt64)1 <<
|
||||
#ifdef UNDER_CE
|
||||
31;
|
||||
@@ -57,15 +70,17 @@ static const UInt64 kComplexInCommands = (UInt64)1 <<
|
||||
34;
|
||||
#endif
|
||||
|
||||
static const UInt64 kComplexInSeconds = 4;
|
||||
static const UInt32 kComplexInSeconds = 4;
|
||||
|
||||
static void SetComplexCommands(UInt32 complexInSeconds, UInt64 cpuFreq, UInt64 &complexInCommands)
|
||||
static void SetComplexCommands(UInt32 complexInSeconds,
|
||||
bool isSpecifiedFreq, UInt64 cpuFreq, UInt64 &complexInCommands)
|
||||
{
|
||||
complexInCommands = kComplexInCommands;
|
||||
const UInt64 kMinFreq = (UInt64)1000000 * 30;
|
||||
const UInt64 kMinFreq = (UInt64)1000000 * 4;
|
||||
const UInt64 kMaxFreq = (UInt64)1000000 * 20000;
|
||||
if (cpuFreq < kMinFreq) cpuFreq = kMinFreq;
|
||||
if (cpuFreq < kMaxFreq)
|
||||
if (cpuFreq < kMinFreq && !isSpecifiedFreq)
|
||||
cpuFreq = kMinFreq;
|
||||
if (cpuFreq < kMaxFreq || isSpecifiedFreq)
|
||||
{
|
||||
if (complexInSeconds != 0)
|
||||
complexInCommands = complexInSeconds * cpuFreq;
|
||||
@@ -98,87 +113,154 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CBenchBuffer
|
||||
|
||||
static const unsigned kBufferAlignment = 1 << 4;
|
||||
|
||||
struct CBenchBuffer
|
||||
{
|
||||
public:
|
||||
size_t BufferSize;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
Byte *Buffer;
|
||||
|
||||
CBenchBuffer(): Buffer(0) {}
|
||||
virtual ~CBenchBuffer() { Free(); }
|
||||
void Free()
|
||||
CBenchBuffer(): BufferSize(0), Buffer(NULL) {}
|
||||
~CBenchBuffer() { ::MidFree(Buffer); }
|
||||
|
||||
void AllocAlignedMask(size_t size, size_t)
|
||||
{
|
||||
::MidFree(Buffer);
|
||||
Buffer = 0;
|
||||
BufferSize = 0;
|
||||
Buffer = (Byte *)::MidAlloc(size);
|
||||
if (Buffer)
|
||||
BufferSize = size;
|
||||
}
|
||||
bool Alloc(size_t bufferSize)
|
||||
|
||||
#else
|
||||
|
||||
Byte *Buffer;
|
||||
Byte *_bufBase;
|
||||
|
||||
CBenchBuffer(): BufferSize(0), Buffer(NULL), _bufBase(NULL){}
|
||||
~CBenchBuffer() { ::MidFree(_bufBase); }
|
||||
|
||||
void AllocAlignedMask(size_t size, size_t alignMask)
|
||||
{
|
||||
if (Buffer != 0 && BufferSize == bufferSize)
|
||||
::MidFree(_bufBase);
|
||||
Buffer = NULL;
|
||||
BufferSize = 0;
|
||||
_bufBase = (Byte *)::MidAlloc(size + alignMask);
|
||||
|
||||
if (_bufBase)
|
||||
{
|
||||
// Buffer = (Byte *)(((uintptr_t)_bufBase + alignMask) & ~(uintptr_t)alignMask);
|
||||
Buffer = (Byte *)(((ptrdiff_t)_bufBase + alignMask) & ~(ptrdiff_t)alignMask);
|
||||
BufferSize = size;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool Alloc(size_t size)
|
||||
{
|
||||
if (Buffer && BufferSize == size)
|
||||
return true;
|
||||
Free();
|
||||
Buffer = (Byte *)::MidAlloc(bufferSize);
|
||||
BufferSize = bufferSize;
|
||||
return (Buffer != 0 || bufferSize == 0);
|
||||
AllocAlignedMask(size, kBufferAlignment - 1);
|
||||
return (Buffer != NULL || size == 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CBenchRandomGenerator: public CBenchBuffer
|
||||
{
|
||||
CBaseRandomGenerator *RG;
|
||||
public:
|
||||
void Set(CBaseRandomGenerator *rg) { RG = rg; }
|
||||
UInt32 GetVal(UInt32 &res, unsigned numBits)
|
||||
static UInt32 GetVal(UInt32 &res, unsigned numBits)
|
||||
{
|
||||
UInt32 val = res & (((UInt32)1 << numBits) - 1);
|
||||
res >>= numBits;
|
||||
return val;
|
||||
}
|
||||
UInt32 GetLen(UInt32 &res)
|
||||
|
||||
static UInt32 GetLen(UInt32 &r)
|
||||
{
|
||||
UInt32 len = GetVal(res, 2);
|
||||
return GetVal(res, 1 + len);
|
||||
UInt32 len = GetVal(r, 2);
|
||||
return GetVal(r, 1 + len);
|
||||
}
|
||||
|
||||
void GenerateSimpleRandom()
|
||||
public:
|
||||
|
||||
void GenerateSimpleRandom(CBaseRandomGenerator *_RG_)
|
||||
{
|
||||
for (UInt32 i = 0; i < BufferSize; i++)
|
||||
Buffer[i] = (Byte)RG->GetRnd();
|
||||
CBaseRandomGenerator rg = *_RG_;
|
||||
const size_t bufSize = BufferSize;
|
||||
Byte *buf = Buffer;
|
||||
for (size_t i = 0; i < bufSize; i++)
|
||||
buf[i] = (Byte)rg.GetRnd();
|
||||
*_RG_ = rg;
|
||||
}
|
||||
|
||||
void Generate(unsigned dictBits)
|
||||
void GenerateLz(unsigned dictBits, CBaseRandomGenerator *_RG_)
|
||||
{
|
||||
CBaseRandomGenerator rg = *_RG_;
|
||||
UInt32 pos = 0;
|
||||
UInt32 rep0 = 1;
|
||||
while (pos < BufferSize)
|
||||
const size_t bufSize = BufferSize;
|
||||
Byte *buf = Buffer;
|
||||
unsigned posBits = 1;
|
||||
|
||||
while (pos < bufSize)
|
||||
{
|
||||
UInt32 res = RG->GetRnd();
|
||||
res >>= 1;
|
||||
if (GetVal(res, 1) == 0 || pos < 1024)
|
||||
Buffer[pos++] = (Byte)(res & 0xFF);
|
||||
UInt32 r = rg.GetRnd();
|
||||
if (GetVal(r, 1) == 0 || pos < 1024)
|
||||
buf[pos++] = (Byte)(r & 0xFF);
|
||||
else
|
||||
{
|
||||
UInt32 len;
|
||||
len = 1 + GetLen(res);
|
||||
if (GetVal(res, 3) != 0)
|
||||
len = 1 + GetLen(r);
|
||||
|
||||
if (GetVal(r, 3) != 0)
|
||||
{
|
||||
len += GetLen(res);
|
||||
do
|
||||
len += GetLen(r);
|
||||
|
||||
while (((UInt32)1 << posBits) < pos)
|
||||
posBits++;
|
||||
|
||||
unsigned numBitsMax = dictBits;
|
||||
if (numBitsMax > posBits)
|
||||
numBitsMax = posBits;
|
||||
|
||||
const unsigned kAddBits = 6;
|
||||
unsigned numLogBits = 5;
|
||||
if (numBitsMax <= (1 << 4) - 1 + kAddBits)
|
||||
numLogBits = 4;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
UInt32 ppp = GetVal(res, 5) + 6;
|
||||
res = RG->GetRnd();
|
||||
if (ppp > dictBits)
|
||||
UInt32 ppp = GetVal(r, numLogBits) + kAddBits;
|
||||
r = rg.GetRnd();
|
||||
if (ppp > numBitsMax)
|
||||
continue;
|
||||
rep0 = /* (1 << ppp) +*/ GetVal(res, ppp);
|
||||
res = RG->GetRnd();
|
||||
rep0 = GetVal(r, ppp);
|
||||
if (rep0 < pos)
|
||||
break;
|
||||
r = rg.GetRnd();
|
||||
}
|
||||
while (rep0 >= pos);
|
||||
rep0++;
|
||||
}
|
||||
|
||||
for (UInt32 i = 0; i < len && pos < BufferSize; i++, pos++)
|
||||
Buffer[pos] = Buffer[pos - rep0];
|
||||
{
|
||||
UInt32 rem = (UInt32)bufSize - pos;
|
||||
if (len > rem)
|
||||
len = rem;
|
||||
}
|
||||
Byte *dest = buf + pos;
|
||||
const Byte *src = dest - rep0;
|
||||
pos += len;
|
||||
for (UInt32 i = 0; i < len; i++)
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
*_RG_ = rg;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -238,6 +320,9 @@ public:
|
||||
// _overflow = false;
|
||||
Pos = 0;
|
||||
}
|
||||
|
||||
// void Print() { printf("\n%8d %8d\n", (unsigned)BufferSize, (unsigned)Pos); }
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
@@ -475,11 +560,11 @@ STDMETHODIMP CBenchProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64
|
||||
return res;
|
||||
}
|
||||
|
||||
static const int kSubBits = 8;
|
||||
static const unsigned kSubBits = 8;
|
||||
|
||||
static UInt32 GetLogSize(UInt32 size)
|
||||
{
|
||||
for (int i = kSubBits; i < 32; i++)
|
||||
for (unsigned i = kSubBits; i < 32; i++)
|
||||
for (UInt32 j = 0; j < (1 << kSubBits); j++)
|
||||
if (size <= (((UInt32)1) << i) + (j << (i - kSubBits)))
|
||||
return (i << kSubBits) + j;
|
||||
@@ -651,26 +736,30 @@ struct CEncoderInfo
|
||||
IBenchCallback *callback;
|
||||
IBenchPrintCallback *printCallback;
|
||||
UInt32 crc;
|
||||
UInt32 kBufferSize;
|
||||
size_t kBufferSize;
|
||||
size_t compressedSize;
|
||||
const Byte *uncompressedDataPtr;
|
||||
|
||||
const Byte *fileData;
|
||||
CBenchRandomGenerator rg;
|
||||
|
||||
CBenchBuffer rgCopy; // it must be 16-byte aligned !!!
|
||||
CBenchmarkOutStream *propStreamSpec;
|
||||
CMyComPtr<ISequentialOutStream> propStream;
|
||||
|
||||
// for decode
|
||||
COneMethodInfo _method;
|
||||
UInt32 _uncompressedDataSize;
|
||||
size_t _uncompressedDataSize;
|
||||
|
||||
HRESULT Init(
|
||||
const COneMethodInfo &method,
|
||||
UInt32 uncompressedDataSize,
|
||||
unsigned generateDictBits,
|
||||
CBaseRandomGenerator *rg);
|
||||
HRESULT Encode();
|
||||
HRESULT Decode(UInt32 decoderIndex);
|
||||
|
||||
CEncoderInfo():
|
||||
fileData(NULL),
|
||||
CheckCrc_Enc(true),
|
||||
CheckCrc_Dec(true),
|
||||
outStreamSpec(0), callback(0), printCallback(0), propStreamSpec(0) {}
|
||||
@@ -738,30 +827,42 @@ struct CEncoderInfo
|
||||
#endif
|
||||
};
|
||||
|
||||
static const UInt32 k_LZMA = 0x030101;
|
||||
|
||||
HRESULT CEncoderInfo::Init(
|
||||
const COneMethodInfo &method,
|
||||
UInt32 uncompressedDataSize,
|
||||
unsigned generateDictBits,
|
||||
CBaseRandomGenerator *rgLoc)
|
||||
{
|
||||
rg.Set(rgLoc);
|
||||
kBufferSize = uncompressedDataSize;
|
||||
UInt32 kCompressedBufferSize =
|
||||
kBufferSize + kCompressedAdditionalSize;
|
||||
// (kBufferSize - kBufferSize / 4) + kCompressedAdditionalSize;
|
||||
// we need extra space, if input data is already compressed
|
||||
const size_t kCompressedBufferSize =
|
||||
kCompressedAdditionalSize +
|
||||
kBufferSize + kBufferSize / 16;
|
||||
// kBufferSize / 2;
|
||||
|
||||
if (kCompressedBufferSize < kBufferSize)
|
||||
return E_FAIL;
|
||||
|
||||
uncompressedDataPtr = fileData;
|
||||
|
||||
if (!fileData)
|
||||
{
|
||||
if (!rg.Alloc(kBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
// DWORD ttt = GetTickCount();
|
||||
if (generateDictBits == 0)
|
||||
rg.GenerateSimpleRandom();
|
||||
rg.GenerateSimpleRandom(rgLoc);
|
||||
else
|
||||
rg.Generate(generateDictBits);
|
||||
rg.GenerateLz(generateDictBits, rgLoc);
|
||||
// printf("\n%d\n ", GetTickCount() - ttt);
|
||||
|
||||
crc = CrcCalc(rg.Buffer, rg.BufferSize);
|
||||
uncompressedDataPtr = rg.Buffer;
|
||||
}
|
||||
|
||||
if (_encoderFilter)
|
||||
{
|
||||
if (!rgCopy.Alloc(rg.BufferSize))
|
||||
if (!rgCopy.Alloc(kBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
@@ -793,7 +894,7 @@ HRESULT CEncoderInfo::Init(
|
||||
coder.QueryInterface(IID_ICompressSetCoderProperties, &scp);
|
||||
if (scp)
|
||||
{
|
||||
UInt64 reduceSize = uncompressedDataSize;
|
||||
UInt64 reduceSize = kBufferSize;
|
||||
RINOK(method.SetCoderProps(scp, &reduceSize));
|
||||
}
|
||||
else
|
||||
@@ -839,11 +940,30 @@ HRESULT CEncoderInfo::Init(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static void My_FilterBench(ICompressFilter *filter, Byte *data, size_t size)
|
||||
{
|
||||
while (size != 0)
|
||||
{
|
||||
UInt32 cur = (UInt32)1 << 31;
|
||||
if (cur > size)
|
||||
cur = (UInt32)size;
|
||||
UInt32 processed = filter->Filter(data, cur);
|
||||
data += processed;
|
||||
// if (processed > size) (in AES filter), we must fill last block with zeros.
|
||||
// but it is not important for benchmark. So we just copy that data without filtering.
|
||||
if (processed > size || processed == 0)
|
||||
break;
|
||||
size -= processed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HRESULT CEncoderInfo::Encode()
|
||||
{
|
||||
CBenchInfo &bi = progressInfoSpec[0]->BenchInfo;
|
||||
@@ -882,31 +1002,36 @@ HRESULT CEncoderInfo::Encode()
|
||||
|
||||
if (_encoderFilter)
|
||||
{
|
||||
memcpy(rgCopy.Buffer, rg.Buffer, rg.BufferSize);
|
||||
memcpy(rgCopy.Buffer, uncompressedDataPtr, kBufferSize);
|
||||
_encoderFilter->Init();
|
||||
_encoderFilter->Filter(rgCopy.Buffer, (UInt32)rg.BufferSize);
|
||||
RINOK(WriteStream(outStream, rgCopy.Buffer, rg.BufferSize));
|
||||
My_FilterBench(_encoderFilter, rgCopy.Buffer, kBufferSize);
|
||||
RINOK(WriteStream(outStream, rgCopy.Buffer, kBufferSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
inStreamSpec->Init(rg.Buffer, rg.BufferSize);
|
||||
RINOK(_encoder->Code(inStream, outStream, 0, 0, progressInfo[0]));
|
||||
inStreamSpec->Init(uncompressedDataPtr, kBufferSize);
|
||||
RINOK(_encoder->Code(inStream, outStream, NULL, NULL, progressInfo[0]));
|
||||
}
|
||||
|
||||
// outStreamSpec->Print();
|
||||
|
||||
UInt32 crcNew = CRC_GET_DIGEST(outStreamSpec->Crc);
|
||||
if (i == 0)
|
||||
crcPrev = crcNew;
|
||||
else if (calcCrc && crcPrev != crcNew)
|
||||
return E_FAIL;
|
||||
|
||||
compressedSize = outStreamSpec->Pos;
|
||||
bi.UnpackSize += rg.BufferSize;
|
||||
bi.UnpackSize += kBufferSize;
|
||||
bi.PackSize += compressedSize;
|
||||
}
|
||||
|
||||
_encoder.Release();
|
||||
_encoderFilter.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CEncoderInfo::Decode(UInt32 decoderIndex)
|
||||
{
|
||||
CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
|
||||
@@ -991,29 +1116,33 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex)
|
||||
|
||||
UInt64 outSize = kBufferSize;
|
||||
crcOutStreamSpec->CalcCrc = ((i & 0x7F) == 0 || CheckCrc_Dec);
|
||||
|
||||
if (_decoderFilter)
|
||||
{
|
||||
if (compressedSize > rgCopy.BufferSize)
|
||||
return E_FAIL;
|
||||
memcpy(rgCopy.Buffer, outStreamSpec->Buffer, compressedSize);
|
||||
_decoderFilter->Init();
|
||||
_decoderFilter->Filter(rgCopy.Buffer, (UInt32)compressedSize);
|
||||
RINOK(WriteStream(crcOutStream, rgCopy.Buffer, rg.BufferSize));
|
||||
My_FilterBench(_decoderFilter, rgCopy.Buffer, compressedSize);
|
||||
RINOK(WriteStream(crcOutStream, rgCopy.Buffer, compressedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(decoder->Code(inStream, crcOutStream, 0, &outSize, progressInfo[decoderIndex]));
|
||||
}
|
||||
|
||||
if (crcOutStreamSpec->CalcCrc && CRC_GET_DIGEST(crcOutStreamSpec->Crc) != crc)
|
||||
return S_FALSE;
|
||||
pi->BenchInfo.UnpackSize += kBufferSize;
|
||||
pi->BenchInfo.PackSize += compressedSize;
|
||||
}
|
||||
|
||||
decoder.Release();
|
||||
_decoderFilter.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static const UInt32 kNumThreadsMax = (1 << 12);
|
||||
|
||||
struct CBenchEncoders
|
||||
@@ -1023,6 +1152,7 @@ struct CBenchEncoders
|
||||
~CBenchEncoders() { delete []encoders; }
|
||||
};
|
||||
|
||||
|
||||
static UInt64 GetNumIterations(UInt64 numCommands, UInt64 complexInCommands)
|
||||
{
|
||||
if (numCommands < (1 << 4))
|
||||
@@ -1031,6 +1161,7 @@ static UInt64 GetNumIterations(UInt64 numCommands, UInt64 complexInCommands)
|
||||
return (res == 0 ? 1 : res);
|
||||
}
|
||||
|
||||
|
||||
static HRESULT MethodBench(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 complexInCommands,
|
||||
@@ -1045,7 +1176,8 @@ static HRESULT MethodBench(
|
||||
#endif
|
||||
,
|
||||
const COneMethodInfo &method2,
|
||||
UInt32 uncompressedDataSize,
|
||||
size_t uncompressedDataSize,
|
||||
const Byte *fileData,
|
||||
unsigned generateDictBits,
|
||||
|
||||
IBenchPrintCallback *printCallback,
|
||||
@@ -1086,6 +1218,7 @@ static HRESULT MethodBench(
|
||||
CEncoderInfo *encoders = encodersSpec.encoders;
|
||||
|
||||
UInt32 i;
|
||||
|
||||
for (i = 0; i < numEncoderThreads; i++)
|
||||
{
|
||||
CEncoderInfo &encoder = encoders[i];
|
||||
@@ -1120,12 +1253,21 @@ static HRESULT MethodBench(
|
||||
|
||||
CBaseRandomGenerator rg;
|
||||
rg.Init();
|
||||
|
||||
UInt32 crc = 0;
|
||||
if (fileData)
|
||||
crc = CrcCalc(fileData, uncompressedDataSize);
|
||||
|
||||
for (i = 0; i < numEncoderThreads; i++)
|
||||
{
|
||||
CEncoderInfo &encoder = encoders[i];
|
||||
encoder._method = method;
|
||||
encoder._uncompressedDataSize = uncompressedDataSize;
|
||||
RINOK(encoders[i].Init(method, uncompressedDataSize, generateDictBits, &rg));
|
||||
encoder.kBufferSize = uncompressedDataSize;
|
||||
encoder.fileData = fileData;
|
||||
encoder.crc = crc;
|
||||
|
||||
RINOK(encoders[i].Init(method, generateDictBits, &rg));
|
||||
}
|
||||
|
||||
CBenchProgressStatus status;
|
||||
@@ -1144,6 +1286,7 @@ static HRESULT MethodBench(
|
||||
encoder.progressInfo[j] = spec;
|
||||
spec->Status = &status;
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
CBenchProgressInfo *bpi = encoder.progressInfoSpec[0];
|
||||
@@ -1167,6 +1310,7 @@ static HRESULT MethodBench(
|
||||
RINOK(encoder.Encode());
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
if (numEncoderThreads > 1)
|
||||
for (i = 0; i < numEncoderThreads; i++)
|
||||
@@ -1181,12 +1325,14 @@ static HRESULT MethodBench(
|
||||
info.UnpackSize = 0;
|
||||
info.PackSize = 0;
|
||||
info.NumIterations = encoders[0].NumIterations;
|
||||
|
||||
for (i = 0; i < numEncoderThreads; i++)
|
||||
{
|
||||
CEncoderInfo &encoder = encoders[i];
|
||||
info.UnpackSize += encoder.kBufferSize;
|
||||
info.PackSize += encoder.compressedSize;
|
||||
}
|
||||
|
||||
RINOK(callback->SetEncodeResult(info, true));
|
||||
|
||||
|
||||
@@ -1194,6 +1340,7 @@ static HRESULT MethodBench(
|
||||
status.EncodeMode = false;
|
||||
|
||||
UInt32 numDecoderThreads = numEncoderThreads * numSubDecoderThreads;
|
||||
|
||||
for (i = 0; i < numEncoderThreads; i++)
|
||||
{
|
||||
CEncoderInfo &encoder = encoders[i];
|
||||
@@ -1266,12 +1413,14 @@ static HRESULT MethodBench(
|
||||
info.UnpackSize = 0;
|
||||
info.PackSize = 0;
|
||||
info.NumIterations = numSubDecoderThreads * encoders[0].NumIterations;
|
||||
|
||||
for (i = 0; i < numEncoderThreads; i++)
|
||||
{
|
||||
CEncoderInfo &encoder = encoders[i];
|
||||
info.UnpackSize += encoder.kBufferSize;
|
||||
info.PackSize += encoder.compressedSize;
|
||||
}
|
||||
|
||||
RINOK(callback->SetDecodeResult(info, false));
|
||||
RINOK(callback->SetDecodeResult(info, true));
|
||||
|
||||
@@ -1279,7 +1428,7 @@ static HRESULT MethodBench(
|
||||
}
|
||||
|
||||
|
||||
inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary)
|
||||
static inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary)
|
||||
{
|
||||
UInt32 hs = dictionary - 1;
|
||||
hs |= (hs >> 1);
|
||||
@@ -1295,14 +1444,16 @@ inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary)
|
||||
(1 << 20) + (multiThread ? (6 << 20) : 0);
|
||||
}
|
||||
|
||||
UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary)
|
||||
UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary, bool totalBench)
|
||||
{
|
||||
const UInt32 kBufferSize = dictionary;
|
||||
const UInt32 kCompressedBufferSize = (kBufferSize / 2);
|
||||
UInt32 numSubThreads = (numThreads > 1) ? 2 : 1;
|
||||
UInt32 numBigThreads = numThreads / numSubThreads;
|
||||
return (kBufferSize + kCompressedBufferSize +
|
||||
GetLZMAUsage((numThreads > 1), dictionary) + (2 << 20)) * numBigThreads;
|
||||
const UInt32 kCompressedBufferSize = kBufferSize; // / 2;
|
||||
bool lzmaMt = (totalBench || numThreads > 1);
|
||||
UInt32 numBigThreads = numThreads;
|
||||
if (!totalBench && lzmaMt)
|
||||
numBigThreads /= 2;
|
||||
return ((UInt64)kBufferSize + kCompressedBufferSize +
|
||||
GetLZMAUsage(lzmaMt, dictionary) + (2 << 20)) * numBigThreads;
|
||||
}
|
||||
|
||||
static HRESULT CrcBig(const void *data, UInt32 size, UInt64 numIterations,
|
||||
@@ -1829,7 +1980,11 @@ void PrintRight(IBenchPrintCallback &f, const char *s, unsigned size)
|
||||
static HRESULT TotalBench(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 complexInCommands,
|
||||
UInt32 numThreads, bool forceUnpackSize, UInt32 unpackSize, IBenchPrintCallback *printCallback, CBenchCallbackToPrint *callback)
|
||||
UInt32 numThreads,
|
||||
bool forceUnpackSize,
|
||||
size_t unpackSize,
|
||||
const Byte *fileData,
|
||||
IBenchPrintCallback *printCallback, CBenchCallbackToPrint *callback)
|
||||
{
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(g_Bench); i++)
|
||||
{
|
||||
@@ -1838,12 +1993,13 @@ static HRESULT TotalBench(
|
||||
callback->BenchProps.DecComplexUnc = bench.DecComplexUnc;
|
||||
callback->BenchProps.DecComplexCompr = bench.DecComplexCompr;
|
||||
callback->BenchProps.EncComplex = bench.EncComplex;
|
||||
|
||||
COneMethodInfo method;
|
||||
NCOM::CPropVariant propVariant;
|
||||
propVariant = bench.Name;
|
||||
RINOK(method.ParseMethodFromPROPVARIANT(UString(), propVariant));
|
||||
|
||||
UInt32 unpackSize2 = unpackSize;
|
||||
size_t unpackSize2 = unpackSize;
|
||||
if (!forceUnpackSize && bench.DictBits == 0)
|
||||
unpackSize2 = kFilterUnpackSize;
|
||||
|
||||
@@ -1853,8 +2009,11 @@ static HRESULT TotalBench(
|
||||
HRESULT res = MethodBench(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
complexInCommands,
|
||||
false, numThreads, method, unpackSize2, bench.DictBits,
|
||||
false, numThreads, method,
|
||||
unpackSize2, fileData,
|
||||
bench.DictBits,
|
||||
printCallback, callback, &callback->BenchProps);
|
||||
|
||||
if (res == E_NOTIMPL)
|
||||
{
|
||||
// callback->Print(" ---");
|
||||
@@ -1866,6 +2025,7 @@ static HRESULT TotalBench(
|
||||
{
|
||||
RINOK(res);
|
||||
}
|
||||
|
||||
callback->NewLine();
|
||||
}
|
||||
return S_OK;
|
||||
@@ -1877,6 +2037,7 @@ static HRESULT FreqBench(
|
||||
UInt32 numThreads,
|
||||
IBenchPrintCallback *_file,
|
||||
bool showFreq,
|
||||
UInt64 specifiedFreq,
|
||||
UInt64 &cpuFreq,
|
||||
UInt32 &res)
|
||||
{
|
||||
@@ -1938,6 +2099,7 @@ static HRESULT FreqBench(
|
||||
}
|
||||
res += sum;
|
||||
}
|
||||
|
||||
CBenchInfo info;
|
||||
progressInfoSpec.SetFinishTime(info);
|
||||
|
||||
@@ -1954,7 +2116,7 @@ static HRESULT FreqBench(
|
||||
PrintResults(_file, info,
|
||||
0, // weight
|
||||
rating,
|
||||
showFreq, showFreq ? cpuFreq : 0, NULL);
|
||||
showFreq, showFreq ? (specifiedFreq != 0 ? specifiedFreq : cpuFreq) : 0, NULL);
|
||||
}
|
||||
RINOK(_file->CheckBreak());
|
||||
}
|
||||
@@ -2275,6 +2437,7 @@ void GetCpuName(AString &s)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
HRESULT Bench(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IBenchPrintCallback *printCallback,
|
||||
@@ -2301,23 +2464,86 @@ HRESULT Bench(
|
||||
|
||||
UInt32 testTime = kComplexInSeconds;
|
||||
|
||||
UInt64 specifiedFreq = 0;
|
||||
|
||||
bool multiThreadTests = false;
|
||||
|
||||
COneMethodInfo method;
|
||||
unsigned i;
|
||||
|
||||
CBenchBuffer fileDataBuffer;
|
||||
|
||||
for (i = 0; i < props.Size(); i++)
|
||||
{
|
||||
const CProperty &property = props[i];
|
||||
NCOM::CPropVariant propVariant;
|
||||
UString name = property.Name;
|
||||
name.MakeLower_Ascii();
|
||||
|
||||
if (name.IsEqualTo("file"))
|
||||
{
|
||||
if (property.Value.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifdef USE_WIN_FILE
|
||||
|
||||
NFile::NIO::CInFile file;
|
||||
if (!file.Open(property.Value))
|
||||
return E_INVALIDARG;
|
||||
UInt64 len;
|
||||
if (!file.GetLength(len))
|
||||
return E_FAIL;
|
||||
if (len >= ((UInt32)1 << 31) || len == 0)
|
||||
return E_INVALIDARG;
|
||||
if (!fileDataBuffer.Alloc((size_t)len))
|
||||
return E_OUTOFMEMORY;
|
||||
UInt32 processedSize;
|
||||
file.Read(fileDataBuffer.Buffer, (UInt32)len, processedSize);
|
||||
if (processedSize != len)
|
||||
return E_FAIL;
|
||||
if (printCallback)
|
||||
{
|
||||
printCallback->Print("file size =");
|
||||
// printCallback->Print(GetOemString(property.Value));
|
||||
PrintNumber(*printCallback, len, 0);
|
||||
printCallback->NewLine();
|
||||
}
|
||||
continue;
|
||||
|
||||
#else
|
||||
|
||||
return E_NOTIMPL;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (!property.Value.IsEmpty())
|
||||
ParseNumberString(property.Value, propVariant);
|
||||
if (name.IsEqualTo("testtime"))
|
||||
|
||||
if (name.IsEqualTo("time"))
|
||||
{
|
||||
RINOK(ParsePropToUInt32(L"", propVariant, testTime));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name.IsEqualTo("freq"))
|
||||
{
|
||||
UInt32 freq32 = 0;
|
||||
RINOK(ParsePropToUInt32(L"", propVariant, freq32));
|
||||
if (freq32 == 0)
|
||||
return E_INVALIDARG;
|
||||
specifiedFreq = (UInt64)freq32 * 1000000;
|
||||
|
||||
if (printCallback)
|
||||
{
|
||||
printCallback->Print("freq=");
|
||||
PrintNumber(*printCallback, freq32, 0);
|
||||
printCallback->NewLine();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||
{
|
||||
UString s = name.Ptr(2);
|
||||
@@ -2339,6 +2565,7 @@ HRESULT Bench(
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
RINOK(method.ParseMethodFromPROPVARIANT(name, propVariant));
|
||||
}
|
||||
|
||||
@@ -2359,7 +2586,12 @@ HRESULT Bench(
|
||||
|
||||
if (printCallback /* || benchCallback */)
|
||||
{
|
||||
UInt64 numMilCommands = (1 << 6);
|
||||
UInt64 numMilCommands = 1 << 6;
|
||||
if (specifiedFreq != 0)
|
||||
{
|
||||
while (numMilCommands > 1 && specifiedFreq < (numMilCommands * 1000000))
|
||||
numMilCommands >>= 1;
|
||||
}
|
||||
|
||||
for (int jj = 0;; jj++)
|
||||
{
|
||||
@@ -2369,22 +2601,33 @@ HRESULT Bench(
|
||||
UInt64 start = ::GetTimeCount();
|
||||
UInt32 sum = (UInt32)start;
|
||||
sum = CountCpuFreq(sum, (UInt32)(numMilCommands * 1000000 / kNumFreqCommands), g_BenchCpuFreqTemp);
|
||||
start = ::GetTimeCount() - start;
|
||||
const UInt64 realDelta = ::GetTimeCount() - start;
|
||||
start = realDelta;
|
||||
if (start == 0)
|
||||
start = 1;
|
||||
UInt64 freq = GetFreq();
|
||||
UInt64 mips = numMilCommands * freq / start;
|
||||
// mips is constant in some compilers
|
||||
const UInt64 mipsVal = numMilCommands * freq / start;
|
||||
if (printCallback)
|
||||
PrintNumber(*printCallback, mips, 5 + ((sum == 0xF1541213) ? 1 : 0));
|
||||
|
||||
{
|
||||
if (realDelta == 0)
|
||||
{
|
||||
printCallback->Print(" -");
|
||||
}
|
||||
else
|
||||
{
|
||||
// PrintNumber(*printCallback, start, 0);
|
||||
PrintNumber(*printCallback, mipsVal, 5 + ((sum == 0xF1541213) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (benchCallback)
|
||||
benchCallback->AddCpuFreq(mips);
|
||||
benchCallback->AddCpuFreq(mipsVal);
|
||||
*/
|
||||
|
||||
if (jj >= 3)
|
||||
{
|
||||
SetComplexCommands(testTime, mips * 1000000, complexInCommands);
|
||||
SetComplexCommands(testTime, false, mipsVal * 1000000, complexInCommands);
|
||||
if (jj >= 8 || start >= freq)
|
||||
break;
|
||||
// break; // change it
|
||||
@@ -2419,7 +2662,8 @@ HRESULT Bench(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
complexInCommands,
|
||||
true, numThreadsSpecified,
|
||||
method, uncompressedDataSize,
|
||||
method,
|
||||
uncompressedDataSize, fileDataBuffer.Buffer,
|
||||
kOldLzmaDictBits, printCallback, benchCallback, &benchProps);
|
||||
}
|
||||
|
||||
@@ -2533,6 +2777,12 @@ HRESULT Bench(
|
||||
bool use2Columns = false;
|
||||
|
||||
bool totalBenchMode = (method.MethodName.IsEqualTo_Ascii_NoCase("*"));
|
||||
bool onlyHashBench = false;
|
||||
if (method.MethodName.IsEqualTo_Ascii_NoCase("hash"))
|
||||
{
|
||||
onlyHashBench = true;
|
||||
totalBenchMode = true;
|
||||
}
|
||||
|
||||
// ---------- Threads loop ----------
|
||||
for (unsigned threadsPassIndex = 0; threadsPassIndex < 3; threadsPassIndex++)
|
||||
@@ -2577,14 +2827,28 @@ HRESULT Bench(
|
||||
|
||||
if (!dictIsDefined)
|
||||
{
|
||||
unsigned dicSizeLog = (totalBenchMode ? 24 : 25);
|
||||
const unsigned dicSizeLog_Main = (totalBenchMode ? 24 : 25);
|
||||
unsigned dicSizeLog = dicSizeLog_Main;
|
||||
|
||||
#ifdef UNDER_CE
|
||||
dicSizeLog = (UInt64)1 << 20;
|
||||
#endif
|
||||
|
||||
for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
|
||||
if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
|
||||
if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog), totalBenchMode) + (8 << 20) <= ramSize)
|
||||
break;
|
||||
|
||||
dict = (UInt32)1 << dicSizeLog;
|
||||
|
||||
if (totalBenchMode && dicSizeLog != dicSizeLog_Main)
|
||||
{
|
||||
f.Print("Dictionary reduced to: ");
|
||||
PrintNumber(f, dicSizeLog, 1);
|
||||
f.NewLine();
|
||||
}
|
||||
}
|
||||
|
||||
PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dict), "Benchmark threads: ", numThreads);
|
||||
PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dict, totalBenchMode), "Benchmark threads: ", numThreads);
|
||||
|
||||
f.NewLine();
|
||||
|
||||
@@ -2664,15 +2928,12 @@ HRESULT Bench(
|
||||
f.NewLine();
|
||||
f.NewLine();
|
||||
|
||||
if (specifiedFreq != 0)
|
||||
cpuFreq = specifiedFreq;
|
||||
|
||||
|
||||
if (totalBenchMode)
|
||||
{
|
||||
if (!dictIsDefined)
|
||||
dict =
|
||||
#ifdef UNDER_CE
|
||||
(UInt64)1 << 20;
|
||||
#else
|
||||
(UInt64)1 << 24;
|
||||
#endif
|
||||
for (UInt32 i = 0; i < numIterations; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
@@ -2685,17 +2946,32 @@ HRESULT Bench(
|
||||
{
|
||||
PrintLeft(f, "CPU", kFieldSize_Name);
|
||||
UInt32 resVal;
|
||||
RINOK(FreqBench(complexInCommands, numThreads, printCallback, freqTest == kNumCpuTests - 1, cpuFreq, resVal));
|
||||
RINOK(FreqBench(complexInCommands, numThreads, printCallback,
|
||||
(freqTest == kNumCpuTests - 1 || specifiedFreq != 0), // showFreq
|
||||
specifiedFreq,
|
||||
cpuFreq, resVal));
|
||||
callback.NewLine();
|
||||
|
||||
if (specifiedFreq != 0)
|
||||
cpuFreq = specifiedFreq;
|
||||
|
||||
if (freqTest == kNumCpuTests - 1)
|
||||
SetComplexCommands(testTime, cpuFreq, complexInCommands);
|
||||
SetComplexCommands(testTime, specifiedFreq != 0, cpuFreq, complexInCommands);
|
||||
}
|
||||
callback.NewLine();
|
||||
|
||||
callback.SetFreq(true, cpuFreq);
|
||||
res = TotalBench(EXTERNAL_CODECS_LOC_VARS complexInCommands, numThreads, dictIsDefined, dict, printCallback, &callback);
|
||||
|
||||
if (!onlyHashBench)
|
||||
{
|
||||
res = TotalBench(EXTERNAL_CODECS_LOC_VARS
|
||||
complexInCommands, numThreads,
|
||||
dictIsDefined || fileDataBuffer.Buffer, // forceUnpackSize
|
||||
fileDataBuffer.Buffer ? fileDataBuffer.BufferSize : dict,
|
||||
fileDataBuffer.Buffer,
|
||||
printCallback, &callback);
|
||||
RINOK(res);
|
||||
}
|
||||
|
||||
res = TotalBench_Hash(EXTERNAL_CODECS_LOC_VARS complexInCommands, numThreads,
|
||||
1 << kNumHashDictBits, printCallback, &callback, &callback.EncodeRes, true, cpuFreq);
|
||||
@@ -2706,7 +2982,10 @@ HRESULT Bench(
|
||||
PrintLeft(f, "CPU", kFieldSize_Name);
|
||||
UInt32 resVal;
|
||||
UInt64 cpuFreqLastTemp = cpuFreq;
|
||||
RINOK(FreqBench(complexInCommands, numThreads, printCallback, false, cpuFreqLastTemp, resVal));
|
||||
RINOK(FreqBench(complexInCommands, numThreads, printCallback,
|
||||
specifiedFreq != 0, // showFreq
|
||||
specifiedFreq,
|
||||
cpuFreqLastTemp, resVal));
|
||||
callback.NewLine();
|
||||
}
|
||||
}
|
||||
@@ -2762,15 +3041,24 @@ HRESULT Bench(
|
||||
RINOK(method2.ParseMethodFromPROPVARIANT(L"d", propVariant));
|
||||
}
|
||||
|
||||
UInt32 uncompressedDataSize = callback.DictSize;
|
||||
size_t uncompressedDataSize;
|
||||
if (fileDataBuffer.Buffer)
|
||||
{
|
||||
uncompressedDataSize = fileDataBuffer.BufferSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
uncompressedDataSize = callback.DictSize;
|
||||
if (uncompressedDataSize >= (1 << 18))
|
||||
uncompressedDataSize += kAdditionalSize;
|
||||
}
|
||||
|
||||
HRESULT res = MethodBench(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
complexInCommands,
|
||||
true, numThreads,
|
||||
method2, uncompressedDataSize,
|
||||
method2,
|
||||
uncompressedDataSize, fileDataBuffer.Buffer,
|
||||
kOldLzmaDictBits, printCallback, &callback, &callback.BenchProps);
|
||||
f.NewLine();
|
||||
RINOK(res);
|
||||
|
||||
@@ -32,9 +32,9 @@ struct IBenchCallback
|
||||
UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
|
||||
UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt64 numIterations);
|
||||
|
||||
const int kBenchMinDicLogSize = 18;
|
||||
const unsigned kBenchMinDicLogSize = 18;
|
||||
|
||||
UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary);
|
||||
UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary, bool totalBench = false);
|
||||
|
||||
struct IBenchPrintCallback
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ static void ReplaceIncorrectChars(UString &s)
|
||||
#ifdef _WIN32
|
||||
c == ':' || c == '*' || c == '?' || c < 0x20 || c == '<' || c == '>' || c == '|' || c == '"'
|
||||
|| c == '/'
|
||||
|| c == 0x202E // RLO
|
||||
// || c == 0x202E // RLO
|
||||
||
|
||||
#endif
|
||||
c == WCHAR_PATH_SEPARATOR)
|
||||
@@ -190,9 +190,7 @@ void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir)
|
||||
{
|
||||
UString &s = parts[i];
|
||||
|
||||
#ifdef _WIN32
|
||||
Correct_PathPart(s);
|
||||
#endif
|
||||
|
||||
if (s.IsEmpty())
|
||||
{
|
||||
|
||||
@@ -268,7 +268,7 @@ void CHandler::AddItem(const CParseItem &item)
|
||||
}
|
||||
|
||||
/*
|
||||
static const STATPROPSTG kProps[] =
|
||||
static const CStatProp kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user