mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-18 06:11:52 -06:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e24f7fba53 | ||
|
|
7c8a265a15 | ||
|
|
a663a6deb7 |
@@ -1,5 +1,5 @@
|
|||||||
/* 7zAlloc.c -- Allocation functions
|
/* 7zAlloc.c -- Allocation functions
|
||||||
2015-02-21 : Igor Pavlov : Public domain */
|
2015-11-09 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ void *SzAlloc(void *p, size_t size)
|
|||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount);
|
fprintf(stderr, "\nAlloc %10u bytes; count = %10d", (unsigned)size, g_allocCount);
|
||||||
g_allocCount++;
|
g_allocCount++;
|
||||||
#endif
|
#endif
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
@@ -51,7 +51,7 @@ void *SzAllocTemp(void *p, size_t size)
|
|||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp);
|
fprintf(stderr, "\nAlloc_temp %10u bytes; count = %10d", (unsigned)size, g_allocCountTemp);
|
||||||
g_allocCountTemp++;
|
g_allocCountTemp++;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return HeapAlloc(GetProcessHeap(), 0, size);
|
return HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
|
|||||||
63
C/7zArcIn.c
63
C/7zArcIn.c
@@ -1,5 +1,5 @@
|
|||||||
/* 7zArcIn.c -- 7z Input functions
|
/* 7zArcIn.c -- 7z Input functions
|
||||||
2015-09-28 : Igor Pavlov : Public domain */
|
2015-11-13 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -942,7 +942,6 @@ typedef struct
|
|||||||
static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
|
static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
|
||||||
{
|
{
|
||||||
UInt64 type = 0;
|
UInt64 type = 0;
|
||||||
UInt32 i;
|
|
||||||
UInt32 numSubDigests = 0;
|
UInt32 numSubDigests = 0;
|
||||||
UInt32 numFolders = p->NumFolders;
|
UInt32 numFolders = p->NumFolders;
|
||||||
UInt32 numUnpackStreams = numFolders;
|
UInt32 numUnpackStreams = numFolders;
|
||||||
@@ -953,6 +952,7 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
|
|||||||
RINOK(ReadID(sd, &type));
|
RINOK(ReadID(sd, &type));
|
||||||
if (type == k7zIdNumUnpackStream)
|
if (type == k7zIdNumUnpackStream)
|
||||||
{
|
{
|
||||||
|
UInt32 i;
|
||||||
ssi->sdNumSubStreams.Data = sd->Data;
|
ssi->sdNumSubStreams.Data = sd->Data;
|
||||||
numUnpackStreams = 0;
|
numUnpackStreams = 0;
|
||||||
numSubDigests = 0;
|
numSubDigests = 0;
|
||||||
@@ -1215,7 +1215,6 @@ static SRes SzReadHeader2(
|
|||||||
UInt64 type;
|
UInt64 type;
|
||||||
UInt32 numFiles = 0;
|
UInt32 numFiles = 0;
|
||||||
UInt32 numEmptyStreams = 0;
|
UInt32 numEmptyStreams = 0;
|
||||||
UInt32 i;
|
|
||||||
CSubStreamInfo ssi;
|
CSubStreamInfo ssi;
|
||||||
const Byte *emptyStreams = 0;
|
const Byte *emptyStreams = 0;
|
||||||
const Byte *emptyFiles = 0;
|
const Byte *emptyFiles = 0;
|
||||||
@@ -1397,22 +1396,22 @@ static SRes SzReadHeader2(
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
UInt32 i;
|
||||||
UInt32 emptyFileIndex = 0;
|
UInt32 emptyFileIndex = 0;
|
||||||
|
|
||||||
UInt32 folderIndex = 0;
|
UInt32 folderIndex = 0;
|
||||||
UInt32 indexInFolder = 0;
|
UInt32 remSubStreams = 0;
|
||||||
|
UInt32 numSubStreams = 0;
|
||||||
UInt64 unpackPos = 0;
|
UInt64 unpackPos = 0;
|
||||||
const Byte *digestsDefs = 0;
|
const Byte *digestsDefs = 0;
|
||||||
const Byte *digestsVals = 0;
|
const Byte *digestsVals = 0;
|
||||||
UInt32 digestsValsIndex = 0;
|
UInt32 digestsValsIndex = 0;
|
||||||
UInt32 digestIndex;
|
UInt32 digestIndex;
|
||||||
Byte allDigestsDefined = 0;
|
Byte allDigestsDefined = 0;
|
||||||
UInt32 curNumSubStreams = (UInt32)(Int32)-1;
|
|
||||||
Byte isDirMask = 0;
|
Byte isDirMask = 0;
|
||||||
Byte crcMask = 0;
|
Byte crcMask = 0;
|
||||||
Byte mask = 0x80;
|
Byte mask = 0x80;
|
||||||
// size_t unpSizesOffset = 0;
|
|
||||||
CSzData sdCodersUnpSizes;
|
CSzData sdCodersUnpSizes;
|
||||||
|
|
||||||
sdCodersUnpSizes.Data = p->db.UnpackSizesData;
|
sdCodersUnpSizes.Data = p->db.UnpackSizesData;
|
||||||
sdCodersUnpSizes.Size = p->db.UnpackSizesDataSize;
|
sdCodersUnpSizes.Size = p->db.UnpackSizesDataSize;
|
||||||
|
|
||||||
@@ -1437,6 +1436,7 @@ static SRes SzReadHeader2(
|
|||||||
}
|
}
|
||||||
|
|
||||||
digestIndex = 0;
|
digestIndex = 0;
|
||||||
|
|
||||||
for (i = 0; i < numFiles; i++, mask >>= 1)
|
for (i = 0; i < numFiles; i++, mask >>= 1)
|
||||||
{
|
{
|
||||||
if (mask == 0)
|
if (mask == 0)
|
||||||
@@ -1451,49 +1451,45 @@ static SRes SzReadHeader2(
|
|||||||
|
|
||||||
p->UnpackPositions[i] = unpackPos;
|
p->UnpackPositions[i] = unpackPos;
|
||||||
p->CRCs.Vals[i] = 0;
|
p->CRCs.Vals[i] = 0;
|
||||||
// p->CRCs.Defs[i] = 0;
|
|
||||||
if (emptyStreams && SzBitArray_Check(emptyStreams , i))
|
if (emptyStreams && SzBitArray_Check(emptyStreams, i))
|
||||||
{
|
{
|
||||||
if (!emptyFiles || !SzBitArray_Check(emptyFiles, emptyFileIndex))
|
if (!emptyFiles || !SzBitArray_Check(emptyFiles, emptyFileIndex))
|
||||||
isDirMask |= mask;
|
isDirMask |= mask;
|
||||||
emptyFileIndex++;
|
emptyFileIndex++;
|
||||||
if (indexInFolder == 0)
|
if (remSubStreams == 0)
|
||||||
{
|
{
|
||||||
p->FileIndexToFolderIndexMap[i] = (UInt32)-1;
|
p->FileIndexToFolderIndexMap[i] = (UInt32)-1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (indexInFolder == 0)
|
|
||||||
|
if (remSubStreams == 0)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
v3.13 incorrectly worked with empty folders
|
|
||||||
v4.07: Loop for skipping empty folders
|
|
||||||
*/
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (folderIndex >= p->db.NumFolders)
|
if (folderIndex >= p->db.NumFolders)
|
||||||
return SZ_ERROR_ARCHIVE;
|
return SZ_ERROR_ARCHIVE;
|
||||||
p->FolderStartFileIndex[folderIndex] = i;
|
p->FolderStartFileIndex[folderIndex] = i;
|
||||||
if (curNumSubStreams == (UInt32)(Int32)-1);
|
numSubStreams = 1;
|
||||||
|
if (ssi.sdNumSubStreams.Data)
|
||||||
{
|
{
|
||||||
curNumSubStreams = 1;
|
RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams));
|
||||||
if (ssi.sdNumSubStreams.Data != 0)
|
|
||||||
{
|
|
||||||
RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &curNumSubStreams));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (curNumSubStreams != 0)
|
remSubStreams = numSubStreams;
|
||||||
|
if (numSubStreams != 0)
|
||||||
break;
|
break;
|
||||||
curNumSubStreams = (UInt32)(Int32)-1;
|
p->db.FoSizesOffsets[folderIndex] = sdCodersUnpSizes.Data - p->db.UnpackSizesData;
|
||||||
folderIndex++; // check it
|
folderIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p->FileIndexToFolderIndexMap[i] = folderIndex;
|
p->FileIndexToFolderIndexMap[i] = folderIndex;
|
||||||
if (emptyStreams && SzBitArray_Check(emptyStreams , i))
|
|
||||||
|
if (emptyStreams && SzBitArray_Check(emptyStreams, i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
indexInFolder++;
|
if (--remSubStreams == 0)
|
||||||
if (indexInFolder >= curNumSubStreams)
|
|
||||||
{
|
{
|
||||||
UInt64 folderUnpackSize = 0;
|
UInt64 folderUnpackSize = 0;
|
||||||
UInt64 startFolderUnpackPos;
|
UInt64 startFolderUnpackPos;
|
||||||
@@ -1523,7 +1519,7 @@ static SRes SzReadHeader2(
|
|||||||
return SZ_ERROR_ARCHIVE;
|
return SZ_ERROR_ARCHIVE;
|
||||||
unpackPos = startFolderUnpackPos + folderUnpackSize;
|
unpackPos = startFolderUnpackPos + folderUnpackSize;
|
||||||
|
|
||||||
if (curNumSubStreams == 1 && SzBitWithVals_Check(&p->db.FolderCRCs, i))
|
if (numSubStreams == 1 && SzBitWithVals_Check(&p->db.FolderCRCs, i))
|
||||||
{
|
{
|
||||||
p->CRCs.Vals[i] = p->db.FolderCRCs.Vals[folderIndex];
|
p->CRCs.Vals[i] = p->db.FolderCRCs.Vals[folderIndex];
|
||||||
crcMask |= mask;
|
crcMask |= mask;
|
||||||
@@ -1534,14 +1530,16 @@ static SRes SzReadHeader2(
|
|||||||
digestsValsIndex++;
|
digestsValsIndex++;
|
||||||
crcMask |= mask;
|
crcMask |= mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
folderIndex++;
|
folderIndex++;
|
||||||
indexInFolder = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UInt64 v;
|
UInt64 v;
|
||||||
RINOK(ReadNumber(&ssi.sdSizes, &v));
|
RINOK(ReadNumber(&ssi.sdSizes, &v));
|
||||||
unpackPos += v;
|
unpackPos += v;
|
||||||
|
if (unpackPos < v)
|
||||||
|
return SZ_ERROR_ARCHIVE;
|
||||||
if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex)))
|
if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex)))
|
||||||
{
|
{
|
||||||
p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4);
|
p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4);
|
||||||
@@ -1550,12 +1548,14 @@ static SRes SzReadHeader2(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask != 0x80)
|
if (mask != 0x80)
|
||||||
{
|
{
|
||||||
UInt32 byteIndex = (i - 1) >> 3;
|
UInt32 byteIndex = (i - 1) >> 3;
|
||||||
p->IsDirs[byteIndex] = isDirMask;
|
p->IsDirs[byteIndex] = isDirMask;
|
||||||
p->CRCs.Defs[byteIndex] = crcMask;
|
p->CRCs.Defs[byteIndex] = crcMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->UnpackPositions[i] = unpackPos;
|
p->UnpackPositions[i] = unpackPos;
|
||||||
p->FolderStartFileIndex[folderIndex] = i;
|
p->FolderStartFileIndex[folderIndex] = i;
|
||||||
p->db.FoSizesOffsets[folderIndex] = sdCodersUnpSizes.Data - p->db.UnpackSizesData;
|
p->db.FoSizesOffsets[folderIndex] = sdCodersUnpSizes.Data - p->db.UnpackSizesData;
|
||||||
@@ -1567,9 +1567,8 @@ static SRes SzReadHeader(
|
|||||||
CSzArEx *p,
|
CSzArEx *p,
|
||||||
CSzData *sd,
|
CSzData *sd,
|
||||||
ILookInStream *inStream,
|
ILookInStream *inStream,
|
||||||
ISzAlloc *allocMain
|
ISzAlloc *allocMain,
|
||||||
,ISzAlloc *allocTemp
|
ISzAlloc *allocTemp)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// Byte *emptyStreamVector = 0;
|
// Byte *emptyStreamVector = 0;
|
||||||
// Byte *emptyFileVector = 0;
|
// Byte *emptyFileVector = 0;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#define MY_VER_MAJOR 15
|
#define MY_VER_MAJOR 15
|
||||||
#define MY_VER_MINOR 8
|
#define MY_VER_MINOR 11
|
||||||
#define MY_VER_BUILD 0
|
#define MY_VER_BUILD 0
|
||||||
#define MY_VERSION_NUMBERS "15.08"
|
#define MY_VERSION_NUMBERS "15.11"
|
||||||
#define MY_VERSION "15.08 beta"
|
#define MY_VERSION "15.11 beta"
|
||||||
#define MY_DATE "2015-10-01"
|
#define MY_DATE "2015-11-14"
|
||||||
#undef MY_COPYRIGHT
|
#undef MY_COPYRIGHT
|
||||||
#undef MY_VERSION_COPYRIGHT_DATE
|
#undef MY_VERSION_COPYRIGHT_DATE
|
||||||
#define MY_AUTHOR_NAME "Igor Pavlov"
|
#define MY_AUTHOR_NAME "Igor Pavlov"
|
||||||
|
|||||||
@@ -513,4 +513,3 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
|
|||||||
#endif
|
#endif
|
||||||
return Groups[0];
|
return Groups[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
42
C/CpuArch.h
42
C/CpuArch.h
@@ -1,5 +1,5 @@
|
|||||||
/* CpuArch.h -- CPU specific code
|
/* CpuArch.h -- CPU specific code
|
||||||
2015-08-02: Igor Pavlov : Public domain */
|
2015-10-31: Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __CPU_ARCH_H
|
#ifndef __CPU_ARCH_H
|
||||||
#define __CPU_ARCH_H
|
#define __CPU_ARCH_H
|
||||||
@@ -10,14 +10,18 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
MY_CPU_LE means that CPU is LITTLE ENDIAN.
|
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.
|
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) \
|
||||||
#define MY_CPU_AMD64
|
|| defined(_M_AMD64) \
|
||||||
|
|| defined(__x86_64__) \
|
||||||
|
|| defined(__AMD64__) \
|
||||||
|
|| defined(__amd64__)
|
||||||
|
#define MY_CPU_AMD64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MY_CPU_AMD64) \
|
#if defined(MY_CPU_AMD64) \
|
||||||
@@ -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
|
#define MY_CPU_IA64_LE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MY_CPU_X86_OR_AMD64)
|
|
||||||
#define MY_CPU_LE_UNALIGN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MY_CPU_X86_OR_AMD64) \
|
#if defined(MY_CPU_X86_OR_AMD64) \
|
||||||
|| defined(MY_CPU_ARM_LE) \
|
|| defined(MY_CPU_ARM_LE) \
|
||||||
|| defined(MY_CPU_IA64_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(__AARCH64EL__) \
|
||||||
|| defined(__MIPSEL__) \
|
|| defined(__MIPSEL__) \
|
||||||
|| defined(__MIPSEL) \
|
|| defined(__MIPSEL) \
|
||||||
|| defined(_MIPSEL)
|
|| defined(_MIPSEL) \
|
||||||
|
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
||||||
#define MY_CPU_LE
|
#define MY_CPU_LE
|
||||||
#endif
|
#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(__MIPSEB) \
|
||||||
|| defined(_MIPSEB) \
|
|| defined(_MIPSEB) \
|
||||||
|| defined(__m68k__)
|
|| defined(__m68k__) \
|
||||||
|
|| defined(__s390x__) \
|
||||||
|
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
|
||||||
#define MY_CPU_BE
|
#define MY_CPU_BE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -85,6 +88,14 @@ Stop_Compiling_Bad_Endian
|
|||||||
#endif
|
#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
|
#ifdef MY_CPU_LE_UNALIGN
|
||||||
|
|
||||||
#define GetUi16(p) (*(const UInt16 *)(const void *)(p))
|
#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)
|
#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>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#pragma intrinsic(_byteswap_ulong)
|
#pragma intrinsic(_byteswap_ulong)
|
||||||
@@ -137,6 +150,13 @@ Stop_Compiling_Bad_Endian
|
|||||||
|
|
||||||
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
|
#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
|
#else
|
||||||
|
|
||||||
#define GetBe32(p) ( \
|
#define GetBe32(p) ( \
|
||||||
|
|||||||
22
C/LzFind.c
22
C/LzFind.c
@@ -1,5 +1,5 @@
|
|||||||
/* LzFind.c -- Match finder for LZ algorithms
|
/* LzFind.c -- Match finder for LZ algorithms
|
||||||
2015-05-15 : Igor Pavlov : Public domain */
|
2015-10-15 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#define kEmptyHashValue 0
|
#define kEmptyHashValue 0
|
||||||
#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
|
#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
|
||||||
#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
|
#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 kMaxHistorySize ((UInt32)7 << 29)
|
||||||
|
|
||||||
#define kStartMaxLen 3
|
#define kStartMaxLen 3
|
||||||
@@ -60,9 +60,11 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
|
|||||||
if (p->streamEndWasReached || p->result != SZ_OK)
|
if (p->streamEndWasReached || p->result != SZ_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* We use (p->streamPos - p->pos) value. (p->streamPos < p->pos) is allowed. */
|
||||||
|
|
||||||
if (p->directInput)
|
if (p->directInput)
|
||||||
{
|
{
|
||||||
UInt32 curSize = 0xFFFFFFFF - p->streamPos;
|
UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos);
|
||||||
if (curSize > p->directInputRem)
|
if (curSize > p->directInputRem)
|
||||||
curSize = (UInt32)p->directInputRem;
|
curSize = (UInt32)p->directInputRem;
|
||||||
p->directInputRem -= curSize;
|
p->directInputRem -= curSize;
|
||||||
@@ -97,7 +99,7 @@ void MatchFinder_MoveBlock(CMatchFinder *p)
|
|||||||
{
|
{
|
||||||
memmove(p->bufferBase,
|
memmove(p->bufferBase,
|
||||||
p->buffer - p->keepSizeBefore,
|
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;
|
p->buffer = p->bufferBase + p->keepSizeBefore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +292,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
|
|||||||
p->posLimit = p->pos + limit;
|
p->posLimit = p->pos + limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatchFinder_Init(CMatchFinder *p)
|
void MatchFinder_Init_2(CMatchFinder *p, int readData)
|
||||||
{
|
{
|
||||||
UInt32 i;
|
UInt32 i;
|
||||||
UInt32 *hash = p->hash;
|
UInt32 *hash = p->hash;
|
||||||
@@ -303,10 +305,18 @@ void MatchFinder_Init(CMatchFinder *p)
|
|||||||
p->pos = p->streamPos = p->cyclicBufferSize;
|
p->pos = p->streamPos = p->cyclicBufferSize;
|
||||||
p->result = SZ_OK;
|
p->result = SZ_OK;
|
||||||
p->streamEndWasReached = 0;
|
p->streamEndWasReached = 0;
|
||||||
MatchFinder_ReadBlock(p);
|
|
||||||
|
if (readData)
|
||||||
|
MatchFinder_ReadBlock(p);
|
||||||
|
|
||||||
MatchFinder_SetLimits(p);
|
MatchFinder_SetLimits(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MatchFinder_Init(CMatchFinder *p)
|
||||||
|
{
|
||||||
|
MatchFinder_Init_2(p, True);
|
||||||
|
}
|
||||||
|
|
||||||
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
|
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
|
||||||
{
|
{
|
||||||
return (p->pos - p->historySize - 1) & kNormalizeMask;
|
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
|
/* 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
|
#ifndef __LZ_FIND_H
|
||||||
#define __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_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);
|
int MatchFinder_NeedMove(CMatchFinder *p);
|
||||||
Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
|
Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
|
||||||
void MatchFinder_MoveBlock(CMatchFinder *p);
|
void MatchFinder_MoveBlock(CMatchFinder *p);
|
||||||
@@ -98,9 +103,12 @@ typedef struct _IMatchFinder
|
|||||||
|
|
||||||
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
|
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
|
||||||
|
|
||||||
|
void MatchFinder_Init_2(CMatchFinder *p, int readData);
|
||||||
void MatchFinder_Init(CMatchFinder *p);
|
void MatchFinder_Init(CMatchFinder *p);
|
||||||
|
|
||||||
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
||||||
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
||||||
|
|
||||||
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
||||||
void Hc3Zip_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
|
/* 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"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -173,12 +173,12 @@ static void HashThreadFunc(CMatchFinderMt *mt)
|
|||||||
CriticalSection_Enter(&mt->btSync.cs);
|
CriticalSection_Enter(&mt->btSync.cs);
|
||||||
CriticalSection_Enter(&mt->hashSync.cs);
|
CriticalSection_Enter(&mt->hashSync.cs);
|
||||||
{
|
{
|
||||||
const Byte *beforePtr = MatchFinder_GetPointerToCurrentPos(mf);
|
const Byte *beforePtr = Inline_MatchFinder_GetPointerToCurrentPos(mf);
|
||||||
const Byte *afterPtr;
|
ptrdiff_t offset;
|
||||||
MatchFinder_MoveBlock(mf);
|
MatchFinder_MoveBlock(mf);
|
||||||
afterPtr = MatchFinder_GetPointerToCurrentPos(mf);
|
offset = beforePtr - Inline_MatchFinder_GetPointerToCurrentPos(mf);
|
||||||
mt->pointerToCurPos -= beforePtr - afterPtr;
|
mt->pointerToCurPos -= offset;
|
||||||
mt->buffer -= beforePtr - afterPtr;
|
mt->buffer -= offset;
|
||||||
}
|
}
|
||||||
CriticalSection_Leave(&mt->btSync.cs);
|
CriticalSection_Leave(&mt->btSync.cs);
|
||||||
CriticalSection_Leave(&mt->hashSync.cs);
|
CriticalSection_Leave(&mt->hashSync.cs);
|
||||||
@@ -501,8 +501,11 @@ void MatchFinderMt_Init(CMatchFinderMt *p)
|
|||||||
CMatchFinder *mf = p->MatchFinder;
|
CMatchFinder *mf = p->MatchFinder;
|
||||||
p->btBufPos = p->btBufPosLimit = 0;
|
p->btBufPos = p->btBufPosLimit = 0;
|
||||||
p->hashBufPos = p->hashBufPosLimit = 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->btNumAvailBytes = 0;
|
||||||
p->lzPos = p->historySize + 1;
|
p->lzPos = p->historySize + 1;
|
||||||
|
|
||||||
|
|||||||
10
C/Lzma2Dec.c
10
C/Lzma2Dec.c
@@ -1,5 +1,5 @@
|
|||||||
/* Lzma2Dec.c -- LZMA2 Decoder
|
/* Lzma2Dec.c -- LZMA2 Decoder
|
||||||
2014-10-29 : Igor Pavlov : Public domain */
|
2015-11-09 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
/* #define SHOW_DEBUG_INFO */
|
/* #define SHOW_DEBUG_INFO */
|
||||||
|
|
||||||
@@ -103,8 +103,8 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
|||||||
{
|
{
|
||||||
case LZMA2_STATE_CONTROL:
|
case LZMA2_STATE_CONTROL:
|
||||||
p->control = b;
|
p->control = b;
|
||||||
PRF(printf("\n %4X ", p->decoder.dicPos));
|
PRF(printf("\n %4X ", (unsigned)p->decoder.dicPos));
|
||||||
PRF(printf(" %2X", b));
|
PRF(printf(" %2X", (unsigned)b));
|
||||||
if (p->control == 0)
|
if (p->control == 0)
|
||||||
return LZMA2_STATE_FINISHED;
|
return LZMA2_STATE_FINISHED;
|
||||||
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
|
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
|
||||||
@@ -124,7 +124,7 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
|||||||
case LZMA2_STATE_UNPACK1:
|
case LZMA2_STATE_UNPACK1:
|
||||||
p->unpackSize |= (UInt32)b;
|
p->unpackSize |= (UInt32)b;
|
||||||
p->unpackSize++;
|
p->unpackSize++;
|
||||||
PRF(printf(" %8d", p->unpackSize));
|
PRF(printf(" %8u", (unsigned)p->unpackSize));
|
||||||
return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
|
return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
|
||||||
|
|
||||||
case LZMA2_STATE_PACK0:
|
case LZMA2_STATE_PACK0:
|
||||||
@@ -134,7 +134,7 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
|||||||
case LZMA2_STATE_PACK1:
|
case LZMA2_STATE_PACK1:
|
||||||
p->packSize |= (UInt32)b;
|
p->packSize |= (UInt32)b;
|
||||||
p->packSize++;
|
p->packSize++;
|
||||||
PRF(printf(" %8d", p->packSize));
|
PRF(printf(" %8u", (unsigned)p->packSize));
|
||||||
return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP:
|
return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP:
|
||||||
(p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA);
|
(p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA);
|
||||||
|
|
||||||
|
|||||||
18
C/Lzma2Enc.c
18
C/Lzma2Enc.c
@@ -1,5 +1,5 @@
|
|||||||
/* Lzma2Enc.c -- LZMA2 Encoder
|
/* Lzma2Enc.c -- LZMA2 Encoder
|
||||||
2015-09-16 : Igor Pavlov : Public domain */
|
2015-10-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
|
|||||||
|
|
||||||
for (i = 0; i < p->props.numBlockThreads; i++)
|
for (i = 0; i < p->props.numBlockThreads; i++)
|
||||||
{
|
{
|
||||||
CLzma2EncInt *t = &p->coders[i];
|
CLzma2EncInt *t = &p->coders[(unsigned)i];
|
||||||
if (!t->enc)
|
if (!t->enc)
|
||||||
{
|
{
|
||||||
t->enc = LzmaEnc_Create(p->alloc);
|
t->enc = LzmaEnc_Create(p->alloc);
|
||||||
@@ -489,11 +489,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
if (p->props.numBlockThreads <= 1)
|
if (p->props.numBlockThreads > 1)
|
||||||
#endif
|
|
||||||
return Lzma2Enc_EncodeMt1(&p->coders[0], p, outStream, inStream, progress);
|
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
|
||||||
{
|
{
|
||||||
CMtCallbackImp mtCallback;
|
CMtCallbackImp mtCallback;
|
||||||
|
|
||||||
@@ -508,9 +504,17 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
|
|||||||
|
|
||||||
p->mtCoder.blockSize = p->props.blockSize;
|
p->mtCoder.blockSize = p->props.blockSize;
|
||||||
p->mtCoder.destBlockSize = p->props.blockSize + (p->props.blockSize >> 10) + 16;
|
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;
|
p->mtCoder.numThreads = p->props.numBlockThreads;
|
||||||
|
|
||||||
return MtCoder_Code(&p->mtCoder);
|
return MtCoder_Code(&p->mtCoder);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return Lzma2Enc_EncodeMt1(&p->coders[0], p, outStream, inStream, progress);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
|
/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
|
||||||
2009-08-14 : Igor Pavlov : Public domain */
|
2015-11-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Lzma86.h"
|
#include "Lzma86.h"
|
||||||
|
|
||||||
@@ -7,8 +9,8 @@
|
|||||||
#include "Bra.h"
|
#include "Bra.h"
|
||||||
#include "LzmaDec.h"
|
#include "LzmaDec.h"
|
||||||
|
|
||||||
static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
|
static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
|
||||||
static void SzFree(void *p, void *address) { p = p; MyFree(address); }
|
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
|
||||||
|
|
||||||
SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
|
SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
|
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
|
||||||
2009-08-14 : Igor Pavlov : Public domain */
|
2015-11-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -11,8 +13,8 @@
|
|||||||
|
|
||||||
#define SZE_OUT_OVERFLOW SZE_DATA_ERROR
|
#define SZE_OUT_OVERFLOW SZE_DATA_ERROR
|
||||||
|
|
||||||
static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
|
static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
|
||||||
static void SzFree(void *p, void *address) { p = p; MyFree(address); }
|
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
|
||||||
|
|
||||||
int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
||||||
int level, UInt32 dictSize, int filterMode)
|
int level, UInt32 dictSize, int filterMode)
|
||||||
|
|||||||
71
C/LzmaEnc.c
71
C/LzmaEnc.c
@@ -1,5 +1,5 @@
|
|||||||
/* LzmaEnc.c -- LZMA Encoder
|
/* LzmaEnc.c -- LZMA Encoder
|
||||||
2015-05-15 Igor Pavlov : Public domain */
|
2015-11-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#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)
|
static void RangeEnc_Construct(CRangeEnc *p)
|
||||||
{
|
{
|
||||||
p->outStream = 0;
|
p->outStream = NULL;
|
||||||
p->bufBase = 0;
|
p->bufBase = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize)
|
#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)
|
#define RC_BUF_SIZE (1 << 16)
|
||||||
static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
|
static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
if (p->bufBase == 0)
|
if (!p->bufBase)
|
||||||
{
|
{
|
||||||
p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE);
|
p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE);
|
||||||
if (p->bufBase == 0)
|
if (!p->bufBase)
|
||||||
return 0;
|
return 0;
|
||||||
p->bufLim = p->bufBase + RC_BUF_SIZE;
|
p->bufLim = p->bufBase + RC_BUF_SIZE;
|
||||||
}
|
}
|
||||||
@@ -854,7 +854,7 @@ static void MovePos(CLzmaEnc *p, UInt32 num)
|
|||||||
{
|
{
|
||||||
#ifdef SHOW_STAT
|
#ifdef SHOW_STAT
|
||||||
g_STAT_OFFSET += num;
|
g_STAT_OFFSET += num;
|
||||||
printf("\n MovePos %d", num);
|
printf("\n MovePos %u", num);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (num != 0)
|
if (num != 0)
|
||||||
@@ -871,12 +871,12 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
|
|||||||
numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);
|
numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);
|
||||||
|
|
||||||
#ifdef SHOW_STAT
|
#ifdef SHOW_STAT
|
||||||
printf("\n i = %d numPairs = %d ", g_STAT_OFFSET, numPairs / 2);
|
printf("\n i = %u numPairs = %u ", g_STAT_OFFSET, numPairs / 2);
|
||||||
g_STAT_OFFSET++;
|
g_STAT_OFFSET++;
|
||||||
{
|
{
|
||||||
UInt32 i;
|
UInt32 i;
|
||||||
for (i = 0; i < numPairs; i += 2)
|
for (i = 0; i < numPairs; i += 2)
|
||||||
printf("%2d %6d | ", p->matches[i], p->matches[i + 1]);
|
printf("%2u %6u | ", p->matches[i], p->matches[i + 1]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1167,12 +1167,12 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
|||||||
cur = 0;
|
cur = 0;
|
||||||
|
|
||||||
#ifdef SHOW_STAT2
|
#ifdef SHOW_STAT2
|
||||||
if (position >= 0)
|
/* if (position >= 0) */
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
printf("\n pos = %4X", position);
|
printf("\n pos = %4X", position);
|
||||||
for (i = cur; i <= lenEnd; i++)
|
for (i = cur; i <= lenEnd; i++)
|
||||||
printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price);
|
printf("\nprice[%4X] = %u", position - cur + i, p->opt[i].price);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1397,13 +1397,13 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
|||||||
{
|
{
|
||||||
UInt32 lenTest2 = lenTest + 1;
|
UInt32 lenTest2 = lenTest + 1;
|
||||||
UInt32 limit = lenTest2 + p->numFastBytes;
|
UInt32 limit = lenTest2 + p->numFastBytes;
|
||||||
UInt32 nextRepMatchPrice;
|
|
||||||
if (limit > numAvailFull)
|
if (limit > numAvailFull)
|
||||||
limit = numAvailFull;
|
limit = numAvailFull;
|
||||||
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
|
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
|
||||||
lenTest2 -= lenTest + 1;
|
lenTest2 -= lenTest + 1;
|
||||||
if (lenTest2 >= 2)
|
if (lenTest2 >= 2)
|
||||||
{
|
{
|
||||||
|
UInt32 nextRepMatchPrice;
|
||||||
UInt32 state2 = kRepNextStates[state];
|
UInt32 state2 = kRepNextStates[state];
|
||||||
UInt32 posStateNext = (position + lenTest) & p->pbMask;
|
UInt32 posStateNext = (position + lenTest) & p->pbMask;
|
||||||
UInt32 curAndLenCharPrice =
|
UInt32 curAndLenCharPrice =
|
||||||
@@ -1487,13 +1487,13 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
|||||||
const Byte *data2 = data - curBack - 1;
|
const Byte *data2 = data - curBack - 1;
|
||||||
UInt32 lenTest2 = lenTest + 1;
|
UInt32 lenTest2 = lenTest + 1;
|
||||||
UInt32 limit = lenTest2 + p->numFastBytes;
|
UInt32 limit = lenTest2 + p->numFastBytes;
|
||||||
UInt32 nextRepMatchPrice;
|
|
||||||
if (limit > numAvailFull)
|
if (limit > numAvailFull)
|
||||||
limit = numAvailFull;
|
limit = numAvailFull;
|
||||||
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
|
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
|
||||||
lenTest2 -= lenTest + 1;
|
lenTest2 -= lenTest + 1;
|
||||||
if (lenTest2 >= 2)
|
if (lenTest2 >= 2)
|
||||||
{
|
{
|
||||||
|
UInt32 nextRepMatchPrice;
|
||||||
UInt32 state2 = kMatchNextStates[state];
|
UInt32 state2 = kMatchNextStates[state];
|
||||||
UInt32 posStateNext = (position + lenTest) & p->pbMask;
|
UInt32 posStateNext = (position + lenTest) & p->pbMask;
|
||||||
UInt32 curAndLenCharPrice = curAndLenPrice +
|
UInt32 curAndLenCharPrice = curAndLenPrice +
|
||||||
@@ -1749,15 +1749,15 @@ void LzmaEnc_Construct(CLzmaEnc *p)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
LzmaEnc_InitPriceTables(p->ProbPrices);
|
LzmaEnc_InitPriceTables(p->ProbPrices);
|
||||||
p->litProbs = 0;
|
p->litProbs = NULL;
|
||||||
p->saveState.litProbs = 0;
|
p->saveState.litProbs = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)
|
CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
p = alloc->Alloc(alloc, sizeof(CLzmaEnc));
|
p = alloc->Alloc(alloc, sizeof(CLzmaEnc));
|
||||||
if (p != 0)
|
if (p)
|
||||||
LzmaEnc_Construct((CLzmaEnc *)p);
|
LzmaEnc_Construct((CLzmaEnc *)p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@@ -1766,8 +1766,8 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
|
|||||||
{
|
{
|
||||||
alloc->Free(alloc, p->litProbs);
|
alloc->Free(alloc, p->litProbs);
|
||||||
alloc->Free(alloc, p->saveState.litProbs);
|
alloc->Free(alloc, p->saveState.litProbs);
|
||||||
p->litProbs = 0;
|
p->litProbs = NULL;
|
||||||
p->saveState.litProbs = 0;
|
p->saveState.litProbs = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
|
void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
|
||||||
@@ -1829,7 +1829,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
|
|||||||
len = GetOptimum(p, nowPos32, &pos);
|
len = GetOptimum(p, nowPos32, &pos);
|
||||||
|
|
||||||
#ifdef SHOW_STAT2
|
#ifdef SHOW_STAT2
|
||||||
printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos);
|
printf("\n pos = %4X, len = %u pos = %u", nowPos32, len, pos);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
posState = nowPos32 & p->pbMask;
|
posState = nowPos32 & p->pbMask;
|
||||||
@@ -1963,12 +1963,12 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, I
|
|||||||
|
|
||||||
{
|
{
|
||||||
unsigned lclp = p->lc + p->lp;
|
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);
|
LzmaEnc_FreeLits(p, alloc);
|
||||||
p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb));
|
p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb));
|
||||||
p->saveState.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);
|
LzmaEnc_FreeLits(p, alloc);
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
@@ -2140,6 +2140,7 @@ void LzmaEnc_Finish(CLzmaEncHandle pp)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
ISeqOutStream funcTable;
|
ISeqOutStream funcTable;
|
||||||
@@ -2169,12 +2170,14 @@ UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
|
|||||||
return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
|
return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
|
const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
|
||||||
{
|
{
|
||||||
const CLzmaEnc *p = (CLzmaEnc *)pp;
|
const CLzmaEnc *p = (CLzmaEnc *)pp;
|
||||||
return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
|
return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
||||||
Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
|
Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
|
||||||
{
|
{
|
||||||
@@ -2209,6 +2212,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
|
static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
|
||||||
{
|
{
|
||||||
SRes res = SZ_OK;
|
SRes res = SZ_OK;
|
||||||
@@ -2222,9 +2226,9 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
res = LzmaEnc_CodeOneBlock(p, False, 0, 0);
|
res = LzmaEnc_CodeOneBlock(p, False, 0, 0);
|
||||||
if (res != SZ_OK || p->finished != 0)
|
if (res != SZ_OK || p->finished)
|
||||||
break;
|
break;
|
||||||
if (progress != 0)
|
if (progress)
|
||||||
{
|
{
|
||||||
res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc));
|
res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc));
|
||||||
if (res != SZ_OK)
|
if (res != SZ_OK)
|
||||||
@@ -2234,10 +2238,19 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LzmaEnc_Finish(p);
|
LzmaEnc_Finish(p);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (res == S_OK && !Inline_MatchFinder_IsFinishedOK(&p->matchFinderBase))
|
||||||
|
res = SZ_ERROR_FAIL;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
|
SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
|
||||||
ISzAlloc *alloc, ISzAlloc *allocBig)
|
ISzAlloc *alloc, ISzAlloc *allocBig)
|
||||||
{
|
{
|
||||||
@@ -2245,6 +2258,7 @@ SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *i
|
|||||||
return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
|
return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
|
SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
|
||||||
{
|
{
|
||||||
CLzmaEnc *p = (CLzmaEnc *)pp;
|
CLzmaEnc *p = (CLzmaEnc *)pp;
|
||||||
@@ -2272,6 +2286,7 @@ SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
|
|||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||||
int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
|
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;
|
CSeqOutStreamBuf outStream;
|
||||||
|
|
||||||
LzmaEnc_SetInputBuf(p, src, srcLen);
|
|
||||||
|
|
||||||
outStream.funcTable.Write = MyWrite;
|
outStream.funcTable.Write = MyWrite;
|
||||||
outStream.data = dest;
|
outStream.data = dest;
|
||||||
outStream.rem = *destLen;
|
outStream.rem = *destLen;
|
||||||
outStream.overflow = False;
|
outStream.overflow = False;
|
||||||
|
|
||||||
p->writeEndMark = writeEndMark;
|
p->writeEndMark = writeEndMark;
|
||||||
|
|
||||||
p->rc.outStream = &outStream.funcTable;
|
p->rc.outStream = &outStream.funcTable;
|
||||||
|
|
||||||
res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig);
|
res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig);
|
||||||
|
|
||||||
if (res == SZ_OK)
|
if (res == SZ_OK)
|
||||||
|
{
|
||||||
res = LzmaEnc_Encode2(p, progress);
|
res = LzmaEnc_Encode2(p, progress);
|
||||||
|
if (res == SZ_OK && p->nowPos64 != srcLen)
|
||||||
|
res = SZ_ERROR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
*destLen -= outStream.rem;
|
*destLen -= outStream.rem;
|
||||||
if (outStream.overflow)
|
if (outStream.overflow)
|
||||||
@@ -2300,13 +2318,14 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||||
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
||||||
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
|
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
|
||||||
{
|
{
|
||||||
CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
|
CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
|
||||||
SRes res;
|
SRes res;
|
||||||
if (p == 0)
|
if (!p)
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
|
|
||||||
res = LzmaEnc_SetProps(p, props);
|
res = LzmaEnc_SetProps(p, props);
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
/* MtCoder.c -- Multi-thread Coder
|
/* MtCoder.c -- Multi-thread Coder
|
||||||
2015-09-28 : Igor Pavlov : Public domain */
|
2015-10-13 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "MtCoder.h"
|
#include "MtCoder.h"
|
||||||
|
|
||||||
void LoopThread_Construct(CLoopThread *p)
|
void LoopThread_Construct(CLoopThread *p)
|
||||||
|
|||||||
37
C/Sha256.c
37
C/Sha256.c
@@ -1,5 +1,5 @@
|
|||||||
/* Crypto/Sha256.c -- SHA-256 Hash
|
/* Crypto/Sha256.c -- SHA-256 Hash
|
||||||
2015-03-02 : Igor Pavlov : Public domain
|
2015-11-14 : Igor Pavlov : Public domain
|
||||||
This code is based on public domain code from Wei Dai's Crypto++ library. */
|
This code is based on public domain code from Wei Dai's Crypto++ library. */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
@@ -113,10 +113,26 @@ static void Sha256_WriteByteBlock(CSha256 *p)
|
|||||||
{
|
{
|
||||||
UInt32 W[16];
|
UInt32 W[16];
|
||||||
unsigned j;
|
unsigned j;
|
||||||
UInt32 *state = p->state;
|
UInt32 *state;
|
||||||
|
|
||||||
#ifdef _SHA256_UNROLL2
|
#ifdef _SHA256_UNROLL2
|
||||||
UInt32 a,b,c,d,e,f,g,h;
|
UInt32 a,b,c,d,e,f,g,h;
|
||||||
|
#else
|
||||||
|
UInt32 T[8];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (j = 0; j < 16; j += 4)
|
||||||
|
{
|
||||||
|
const Byte *ccc = p->buffer + j * 4;
|
||||||
|
W[j ] = GetBe32(ccc);
|
||||||
|
W[j + 1] = GetBe32(ccc + 4);
|
||||||
|
W[j + 2] = GetBe32(ccc + 8);
|
||||||
|
W[j + 3] = GetBe32(ccc + 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
state = p->state;
|
||||||
|
|
||||||
|
#ifdef _SHA256_UNROLL2
|
||||||
a = state[0];
|
a = state[0];
|
||||||
b = state[1];
|
b = state[1];
|
||||||
c = state[2];
|
c = state[2];
|
||||||
@@ -126,17 +142,10 @@ static void Sha256_WriteByteBlock(CSha256 *p)
|
|||||||
g = state[6];
|
g = state[6];
|
||||||
h = state[7];
|
h = state[7];
|
||||||
#else
|
#else
|
||||||
UInt32 T[8];
|
|
||||||
for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
T[j] = state[j];
|
T[j] = state[j];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (j = 0; j < 16; j += 2)
|
|
||||||
{
|
|
||||||
W[j ] = GetBe32(p->buffer + j * 4);
|
|
||||||
W[j + 1] = GetBe32(p->buffer + j * 4 + 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < 64; j += 16)
|
for (j = 0; j < 64; j += 16)
|
||||||
{
|
{
|
||||||
RX_16
|
RX_16
|
||||||
@@ -226,11 +235,13 @@ void Sha256_Final(CSha256 *p, Byte *digest)
|
|||||||
|
|
||||||
Sha256_WriteByteBlock(p);
|
Sha256_WriteByteBlock(p);
|
||||||
|
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i += 2)
|
||||||
{
|
{
|
||||||
UInt32 v = p->state[i];
|
UInt32 v0 = p->state[i];
|
||||||
SetBe32(digest, v);
|
UInt32 v1 = p->state[i + 1];
|
||||||
digest += 4;
|
SetBe32(digest , v0);
|
||||||
|
SetBe32(digest + 4, v1);
|
||||||
|
digest += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sha256_Init(p);
|
Sha256_Init(p);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 7zipInstall.c - 7-Zip Installer
|
/* 7zipInstall.c - 7-Zip Installer
|
||||||
2015-09-28 : Igor Pavlov : Public domain */
|
2015-11-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ static LONG MyRegistry_CreateKeyAndVal(HKEY parentKey, LPCWSTR keyName, LPCWSTR
|
|||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
res = MyRegistry_SetString(destKey, valName, val);
|
res = MyRegistry_SetString(destKey, valName, val);
|
||||||
res = RegCloseKey(destKey);
|
/* res = */ RegCloseKey(destKey);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ static LONG MyRegistry_CreateKeyAndVal_32(HKEY parentKey, LPCWSTR keyName, LPCWS
|
|||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
res = MyRegistry_SetString(destKey, valName, val);
|
res = MyRegistry_SetString(destKey, valName, val);
|
||||||
res = RegCloseKey(destKey);
|
/* res = */ RegCloseKey(destKey);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -322,7 +322,7 @@ static Bool FindSignature(CSzFile *stream, UInt64 *resPos)
|
|||||||
processed -= k7zStartHeaderSize;
|
processed -= k7zStartHeaderSize;
|
||||||
for (pos = 0; pos <= processed; pos++)
|
for (pos = 0; pos <= processed; pos++)
|
||||||
{
|
{
|
||||||
for (; buf[pos] != '7' && pos <= processed; pos++);
|
for (; pos <= processed && buf[pos] != '7'; pos++);
|
||||||
if (pos > processed)
|
if (pos > processed)
|
||||||
break;
|
break;
|
||||||
if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0)
|
if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0)
|
||||||
@@ -598,8 +598,8 @@ static LONG SetRegKey_Path2(HKEY parentKey)
|
|||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
res = MyRegistry_SetString(destKey, k_Reg_Path32, path);
|
res = MyRegistry_SetString(destKey, k_Reg_Path32, path);
|
||||||
res = MyRegistry_SetString(destKey, k_Reg_Path, path);
|
/* res = */ MyRegistry_SetString(destKey, k_Reg_Path, path);
|
||||||
res = RegCloseKey(destKey);
|
/* res = */ RegCloseKey(destKey);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -718,10 +718,10 @@ static void WriteCLSID()
|
|||||||
WCHAR destPath[MAX_PATH + 10];
|
WCHAR destPath[MAX_PATH + 10];
|
||||||
wcscpy(destPath, path);
|
wcscpy(destPath, path);
|
||||||
wcscat(destPath, L"7-zip32.dll");
|
wcscat(destPath, L"7-zip32.dll");
|
||||||
res = MyRegistry_SetString(destKey, NULL, destPath);
|
/* res = */ MyRegistry_SetString(destKey, NULL, destPath);
|
||||||
res = MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
|
/* res = */ MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
|
||||||
// DeleteRegValue(destKey, L"InprocServer32");
|
// DeleteRegValue(destKey, L"InprocServer32");
|
||||||
res = RegCloseKey(destKey);
|
/* res = */ RegCloseKey(destKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -737,10 +737,10 @@ static void WriteCLSID()
|
|||||||
WCHAR destPath[MAX_PATH + 10];
|
WCHAR destPath[MAX_PATH + 10];
|
||||||
wcscpy(destPath, path);
|
wcscpy(destPath, path);
|
||||||
wcscat(destPath, L"7-zip.dll");
|
wcscat(destPath, L"7-zip.dll");
|
||||||
res = MyRegistry_SetString(destKey, NULL, destPath);
|
/* res = */ MyRegistry_SetString(destKey, NULL, destPath);
|
||||||
res = MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
|
/* res = */ MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
|
||||||
// DeleteRegValue(destKey, L"InprocServer32");
|
// DeleteRegValue(destKey, L"InprocServer32");
|
||||||
res = RegCloseKey(destKey);
|
/* res = */ RegCloseKey(destKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1083,7 +1083,6 @@ static int Install()
|
|||||||
WCHAR sfxPath[MAX_PATH + 2];
|
WCHAR sfxPath[MAX_PATH + 2];
|
||||||
|
|
||||||
Bool needReboot = False;
|
Bool needReboot = False;
|
||||||
size_t pathLen;
|
|
||||||
|
|
||||||
allocImp.Alloc = SzAlloc;
|
allocImp.Alloc = SzAlloc;
|
||||||
allocImp.Free = SzFree;
|
allocImp.Free = SzFree;
|
||||||
@@ -1116,6 +1115,7 @@ static int Install()
|
|||||||
|
|
||||||
if (res == SZ_OK)
|
if (res == SZ_OK)
|
||||||
{
|
{
|
||||||
|
size_t pathLen;
|
||||||
if (!g_SilentMode)
|
if (!g_SilentMode)
|
||||||
{
|
{
|
||||||
GetDlgItemTextW(g_HWND, IDE_EXTRACT_PATH, path, MAX_PATH);
|
GetDlgItemTextW(g_HWND, IDE_EXTRACT_PATH, path, MAX_PATH);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 7zipUninstall.c - 7-Zip Uninstaller
|
/* 7zipUninstall.c - 7-Zip Uninstaller
|
||||||
2015-08-09 : Igor Pavlov : Public domain */
|
2015-11-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -384,7 +384,7 @@ static void WriteCLSID()
|
|||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
RegDeleteValueW(destKey, k_7zip_CLSID);
|
RegDeleteValueW(destKey, k_7zip_CLSID);
|
||||||
res = RegCloseKey(destKey);
|
/* res = */ RegCloseKey(destKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,7 +419,7 @@ static void WriteCLSID()
|
|||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
RegDeleteValueW(destKey, k_7zip_CLSID);
|
RegDeleteValueW(destKey, k_7zip_CLSID);
|
||||||
res = RegCloseKey(destKey);
|
/* res = */ RegCloseKey(destKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* LzmaUtil.c -- Test application for LZMA compression
|
/* LzmaUtil.c -- Test application for LZMA compression
|
||||||
2015-06-13 : Igor Pavlov : Public domain */
|
2015-11-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "../../Precomp.h"
|
#include "../../Precomp.h"
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
|
|||||||
SRes res;
|
SRes res;
|
||||||
CLzmaEncProps props;
|
CLzmaEncProps props;
|
||||||
|
|
||||||
rs = rs;
|
UNUSED_VAR(rs);
|
||||||
|
|
||||||
enc = LzmaEnc_Create(&g_Alloc);
|
enc = LzmaEnc_Create(&g_Alloc);
|
||||||
if (enc == 0)
|
if (enc == 0)
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
/* LzmaLibExports.c -- LZMA library DLL Entry point
|
/* LzmaLibExports.c -- LZMA library DLL Entry point
|
||||||
2008-10-04 : Igor Pavlov : Public domain */
|
2015-11-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "../../Precomp.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
hInstance = hInstance;
|
UNUSED_VAR(hInstance);
|
||||||
dwReason = dwReason;
|
UNUSED_VAR(dwReason);
|
||||||
lpReserved = lpReserved;
|
UNUSED_VAR(lpReserved);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* SfxSetup.c - 7z SFX Setup
|
/* SfxSetup.c - 7z SFX Setup
|
||||||
2015-03-25 : Igor Pavlov : Public domain */
|
2015-11-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ static unsigned FindItem(const char * const *items, unsigned num, const wchar_t
|
|||||||
#ifdef _CONSOLE
|
#ifdef _CONSOLE
|
||||||
static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
|
static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
|
||||||
{
|
{
|
||||||
ctrlType = ctrlType;
|
UNUSED_VAR(ctrlType);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -144,7 +144,7 @@ static Bool FindSignature(CSzFile *stream, UInt64 *resPos)
|
|||||||
processed -= k7zStartHeaderSize;
|
processed -= k7zStartHeaderSize;
|
||||||
for (pos = 0; pos <= processed; pos++)
|
for (pos = 0; pos <= processed; pos++)
|
||||||
{
|
{
|
||||||
for (; buf[pos] != '7' && pos <= processed; pos++);
|
for (; pos <= processed && buf[pos] != '7'; pos++);
|
||||||
if (pos > processed)
|
if (pos > processed)
|
||||||
break;
|
break;
|
||||||
if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0)
|
if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0)
|
||||||
@@ -257,10 +257,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
#ifdef _CONSOLE
|
#ifdef _CONSOLE
|
||||||
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
|
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
|
||||||
#else
|
#else
|
||||||
hInstance = hInstance;
|
UNUSED_VAR(hInstance);
|
||||||
hPrevInstance = hPrevInstance;
|
UNUSED_VAR(hPrevInstance);
|
||||||
lpCmdLine = lpCmdLine;
|
UNUSED_VAR(lpCmdLine);
|
||||||
nCmdShow = nCmdShow;
|
UNUSED_VAR(nCmdShow);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CrcGenerateTable();
|
CrcGenerateTable();
|
||||||
|
|||||||
16
C/XzDec.c
16
C/XzDec.c
@@ -1,5 +1,5 @@
|
|||||||
/* XzDec.c -- Xz Decode
|
/* XzDec.c -- Xz Decode
|
||||||
2015-05-01 : Igor Pavlov : Public domain */
|
2015-11-09 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ static void BraState_Free(void *pp, ISzAlloc *alloc)
|
|||||||
static SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
|
static SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
CBraState *p = ((CBraState *)pp);
|
CBraState *p = ((CBraState *)pp);
|
||||||
alloc = alloc;
|
UNUSED_VAR(alloc);
|
||||||
p->ip = 0;
|
p->ip = 0;
|
||||||
if (p->methodId == XZ_ID_Delta)
|
if (p->methodId == XZ_ID_Delta)
|
||||||
{
|
{
|
||||||
@@ -129,9 +129,9 @@ static SRes BraState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src,
|
|||||||
CBraState *p = ((CBraState *)pp);
|
CBraState *p = ((CBraState *)pp);
|
||||||
SizeT destLenOrig = *destLen;
|
SizeT destLenOrig = *destLen;
|
||||||
SizeT srcLenOrig = *srcLen;
|
SizeT srcLenOrig = *srcLen;
|
||||||
|
UNUSED_VAR(finishMode);
|
||||||
*destLen = 0;
|
*destLen = 0;
|
||||||
*srcLen = 0;
|
*srcLen = 0;
|
||||||
finishMode = finishMode;
|
|
||||||
*wasFinished = 0;
|
*wasFinished = 0;
|
||||||
while (destLenOrig > 0)
|
while (destLenOrig > 0)
|
||||||
{
|
{
|
||||||
@@ -236,8 +236,8 @@ static void SbState_Free(void *pp, ISzAlloc *alloc)
|
|||||||
static SRes SbState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
|
static SRes SbState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
UNUSED_VAR(pp);
|
UNUSED_VAR(pp);
|
||||||
props = props;
|
UNUSED_VAR(props);
|
||||||
alloc = alloc;
|
UNUSED_VAR(alloc);
|
||||||
return (propSize == 0) ? SZ_OK : SZ_ERROR_UNSUPPORTED;
|
return (propSize == 0) ? SZ_OK : SZ_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ static SRes SbState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src,
|
|||||||
{
|
{
|
||||||
CSbDec *p = (CSbDec *)pp;
|
CSbDec *p = (CSbDec *)pp;
|
||||||
SRes res;
|
SRes res;
|
||||||
srcWasFinished = srcWasFinished;
|
UNUSED_VAR(srcWasFinished);
|
||||||
p->dest = dest;
|
p->dest = dest;
|
||||||
p->destLen = *destLen;
|
p->destLen = *destLen;
|
||||||
p->src = src;
|
p->src = src;
|
||||||
@@ -308,7 +308,7 @@ static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *sr
|
|||||||
ELzmaStatus status;
|
ELzmaStatus status;
|
||||||
/* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */
|
/* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */
|
||||||
SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, (ELzmaFinishMode)finishMode, &status);
|
SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, (ELzmaFinishMode)finishMode, &status);
|
||||||
srcWasFinished = srcWasFinished;
|
UNUSED_VAR(srcWasFinished);
|
||||||
*wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
|
*wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -555,7 +555,7 @@ SRes XzBlock_Parse(CXzBlock *p, const Byte *header)
|
|||||||
pos += (unsigned)size;
|
pos += (unsigned)size;
|
||||||
|
|
||||||
#ifdef XZ_DUMP
|
#ifdef XZ_DUMP
|
||||||
printf("\nf[%d] = %2X: ", i, filter->id);
|
printf("\nf[%u] = %2X: ", i, (unsigned)filter->id);
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
|
|||||||
5
C/XzIn.c
5
C/XzIn.c
@@ -1,5 +1,5 @@
|
|||||||
/* XzIn.c - Xz input
|
/* XzIn.c - Xz input
|
||||||
2015-04-21 : Igor Pavlov : Public domain */
|
2015-11-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ SRes XzBlock_ReadFooter(CXzBlock *p, CXzStreamFlags f, ISeqInStream *inStream)
|
|||||||
|
|
||||||
static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *alloc)
|
static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
size_t i, numBlocks, pos = 1;
|
size_t numBlocks, pos = 1;
|
||||||
UInt32 crc;
|
UInt32 crc;
|
||||||
|
|
||||||
if (size < 5 || buf[0] != 0)
|
if (size < 5 || buf[0] != 0)
|
||||||
@@ -94,6 +94,7 @@ static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *
|
|||||||
Xz_Free(p, alloc);
|
Xz_Free(p, alloc);
|
||||||
if (numBlocks != 0)
|
if (numBlocks != 0)
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
p->numBlocks = numBlocks;
|
p->numBlocks = numBlocks;
|
||||||
p->numBlocksAllocated = numBlocks;
|
p->numBlocksAllocated = numBlocks;
|
||||||
p->blocks = alloc->Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks);
|
p->blocks = alloc->Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks);
|
||||||
|
|||||||
@@ -158,14 +158,6 @@ SOURCE=.\7zFolderInStream.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=.\7zHandler.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -350,14 +342,6 @@ SOURCE=..\Common\CoderMixer2.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\Common\HandlerOut.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -254,8 +254,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
lps->Init(extractCallback, false);
|
lps->Init(extractCallback, false);
|
||||||
|
|
||||||
CDecoder decoder(
|
CDecoder decoder(
|
||||||
#ifndef USE_MIXER_ST
|
#if !defined(USE_MIXER_MT)
|
||||||
false
|
false
|
||||||
|
#elif !defined(USE_MIXER_ST)
|
||||||
|
true
|
||||||
|
#elif !defined(__7Z_SET_PROPERTIES)
|
||||||
|
#ifdef _7ZIP_ST
|
||||||
|
false
|
||||||
|
#else
|
||||||
|
true
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
_useMultiThreadMixer
|
_useMultiThreadMixer
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
|
||||||
#ifdef EXTRACT_ONLY
|
#ifdef EXTRACT_ONLY
|
||||||
|
|
||||||
_crcSize = 4;
|
_crcSize = 4;
|
||||||
|
|
||||||
#ifdef __7Z_SET_PROPERTIES
|
#ifdef __7Z_SET_PROPERTIES
|
||||||
_numThreads = NSystem::GetNumberOfProcessors();
|
_numThreads = NSystem::GetNumberOfProcessors();
|
||||||
|
_useMultiThreadMixer = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,10 +726,14 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
const PROPVARIANT &value = values[i];
|
const PROPVARIANT &value = values[i];
|
||||||
UInt32 number;
|
UInt32 number;
|
||||||
int index = ParseStringToUInt32(name, number);
|
unsigned index = ParseStringToUInt32(name, number);
|
||||||
if (index == 0)
|
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"))
|
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||||
{
|
{
|
||||||
RINOK(ParseMtProp(name.Ptr(2), value, numProcessors, _numThreads));
|
RINOK(ParseMtProp(name.Ptr(2), value, numProcessors, _numThreads));
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ namespace N7z {
|
|||||||
#ifndef __7Z_SET_PROPERTIES
|
#ifndef __7Z_SET_PROPERTIES
|
||||||
|
|
||||||
#ifdef EXTRACT_ONLY
|
#ifdef EXTRACT_ONLY
|
||||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
||||||
#define __7Z_SET_PROPERTIES
|
#define __7Z_SET_PROPERTIES
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define __7Z_SET_PROPERTIES
|
#define __7Z_SET_PROPERTIES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ struct CFolders
|
|||||||
return PackPositions[index + 1] - PackPositions[index];
|
return PackPositions[index + 1] - PackPositions[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CFolders(): NumPackStreams(0), NumFolders(0) {}
|
||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
NumPackStreams = 0;
|
NumPackStreams = 0;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ AR_OBJS = \
|
|||||||
$O\7zEncode.obj \
|
$O\7zEncode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderInStream.obj \
|
$O\7zFolderInStream.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zHandlerOut.obj \
|
$O\7zHandlerOut.obj \
|
||||||
$O\7zHeader.obj \
|
$O\7zHeader.obj \
|
||||||
@@ -65,7 +64,6 @@ COMPRESS_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\HandlerOut.obj \
|
$O\HandlerOut.obj \
|
||||||
$O\InStreamWithCRC.obj \
|
$O\InStreamWithCRC.obj \
|
||||||
$O\ItemNameUtils.obj \
|
$O\ItemNameUtils.obj \
|
||||||
|
|||||||
@@ -83,8 +83,14 @@ class CHandler: public CHandlerCont
|
|||||||
HRESULT ReadTables(IInStream *stream);
|
HRESULT ReadTables(IInStream *stream);
|
||||||
UInt64 BlocksToBytes(UInt32 i) const { return (UInt64)i << _blockSizeLog; }
|
UInt64 BlocksToBytes(UInt32 i) const { return (UInt64)i << _blockSizeLog; }
|
||||||
|
|
||||||
virtual UInt64 GetItemPos(UInt32 index) const { return BlocksToBytes(_items[index].StartBlock); }
|
virtual int GetItem_ExtractInfo(UInt32 index, UInt64 &pos, UInt64 &size) const
|
||||||
virtual UInt64 GetItemSize(UInt32 index) const { return BlocksToBytes(_items[index].NumBlocks); }
|
{
|
||||||
|
const CItem &item = _items[index];
|
||||||
|
pos = BlocksToBytes(item.StartBlock);
|
||||||
|
size = BlocksToBytes(item.NumBlocks);
|
||||||
|
return NExtract::NOperationResult::kOK;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
INTERFACE_IInArchive_Cont(;)
|
INTERFACE_IInArchive_Cont(;)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
|||||||
{
|
{
|
||||||
COM_TRY_BEGIN
|
COM_TRY_BEGIN
|
||||||
NCOM::CPropVariant prop;
|
NCOM::CPropVariant prop;
|
||||||
|
|
||||||
if (m_Database.NewFormat)
|
if (m_Database.NewFormat)
|
||||||
{
|
{
|
||||||
switch (propID)
|
switch (propID)
|
||||||
@@ -112,12 +113,15 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
|||||||
prop.Detach(value);
|
prop.Detach(value);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
int entryIndex;
|
|
||||||
|
unsigned entryIndex;
|
||||||
if (m_Database.LowLevel)
|
if (m_Database.LowLevel)
|
||||||
entryIndex = index;
|
entryIndex = index;
|
||||||
else
|
else
|
||||||
entryIndex = m_Database.Indices[index];
|
entryIndex = m_Database.Indices[index];
|
||||||
|
|
||||||
const CItem &item = m_Database.Items[entryIndex];
|
const CItem &item = m_Database.Items[entryIndex];
|
||||||
|
|
||||||
switch (propID)
|
switch (propID)
|
||||||
{
|
{
|
||||||
case kpidPath:
|
case kpidPath:
|
||||||
@@ -161,6 +165,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
prop.Detach(value);
|
prop.Detach(value);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
COM_TRY_END
|
COM_TRY_END
|
||||||
@@ -244,9 +249,9 @@ public:
|
|||||||
UInt64 m_PosInFolder;
|
UInt64 m_PosInFolder;
|
||||||
UInt64 m_PosInSection;
|
UInt64 m_PosInSection;
|
||||||
const CRecordVector<bool> *m_ExtractStatuses;
|
const CRecordVector<bool> *m_ExtractStatuses;
|
||||||
int m_StartIndex;
|
unsigned m_StartIndex;
|
||||||
int m_CurrentIndex;
|
unsigned m_CurrentIndex;
|
||||||
int m_NumFiles;
|
unsigned m_NumFiles;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CFilesDatabase *m_Database;
|
const CFilesDatabase *m_Database;
|
||||||
@@ -298,7 +303,7 @@ HRESULT CChmFolderOutStream::WriteEmptyFiles()
|
|||||||
{
|
{
|
||||||
if (m_FileIsOpen)
|
if (m_FileIsOpen)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
for (;m_CurrentIndex < m_NumFiles; m_CurrentIndex++)
|
for (; m_CurrentIndex < m_NumFiles; m_CurrentIndex++)
|
||||||
{
|
{
|
||||||
UInt64 fileSize = m_Database->GetFileSize(m_StartIndex + m_CurrentIndex);
|
UInt64 fileSize = m_Database->GetFileSize(m_StartIndex + m_CurrentIndex);
|
||||||
if (fileSize != 0)
|
if (fileSize != 0)
|
||||||
@@ -368,7 +373,7 @@ HRESULT CChmFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce
|
|||||||
// return E_FAIL;
|
// return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fullIndex = m_StartIndex + m_CurrentIndex;
|
unsigned fullIndex = m_StartIndex + m_CurrentIndex;
|
||||||
m_RemainFileSize = m_Database->GetFileSize(fullIndex);
|
m_RemainFileSize = m_Database->GetFileSize(fullIndex);
|
||||||
UInt64 fileOffset = m_Database->GetFileOffset(fullIndex);
|
UInt64 fileOffset = m_Database->GetFileOffset(fullIndex);
|
||||||
if (fileOffset < m_PosInSection)
|
if (fileOffset < m_PosInSection)
|
||||||
@@ -408,7 +413,7 @@ HRESULT CChmFolderOutStream::FlushCorrupted(UInt64 maxSize)
|
|||||||
{
|
{
|
||||||
const UInt32 kBufferSize = (1 << 10);
|
const UInt32 kBufferSize = (1 << 10);
|
||||||
Byte buffer[kBufferSize];
|
Byte buffer[kBufferSize];
|
||||||
for (int i = 0; i < kBufferSize; i++)
|
for (unsigned i = 0; i < kBufferSize; i++)
|
||||||
buffer[i] = 0;
|
buffer[i] = 0;
|
||||||
if (maxSize > m_FolderSize)
|
if (maxSize > m_FolderSize)
|
||||||
maxSize = m_FolderSize;
|
maxSize = m_FolderSize;
|
||||||
@@ -531,9 +536,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
for (i = 0; i < numItems; i++)
|
for (i = 0; i < numItems; i++)
|
||||||
{
|
{
|
||||||
UInt32 index = allFilesMode ? i : indices[i];
|
UInt32 index = allFilesMode ? i : indices[i];
|
||||||
int entryIndex = m_Database.Indices[index];
|
const CItem &item = m_Database.Items[m_Database.Indices[index]];
|
||||||
const CItem &item = m_Database.Items[entryIndex];
|
const UInt64 sectionIndex = item.Section;
|
||||||
UInt64 sectionIndex = item.Section;
|
|
||||||
if (item.IsDir() || item.Size == 0)
|
if (item.IsDir() || item.Size == 0)
|
||||||
continue;
|
continue;
|
||||||
if (sectionIndex == 0)
|
if (sectionIndex == 0)
|
||||||
@@ -567,14 +571,17 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
|
|
||||||
CByteBuffer packBuf;
|
CByteBuffer packBuf;
|
||||||
|
|
||||||
for (i = 0; i < numItems;)
|
for (i = 0;;)
|
||||||
{
|
{
|
||||||
RINOK(extractCallback->SetCompleted(¤tTotalSize));
|
RINOK(extractCallback->SetCompleted(¤tTotalSize));
|
||||||
|
|
||||||
|
if (i >= numItems)
|
||||||
|
break;
|
||||||
|
|
||||||
UInt32 index = allFilesMode ? i : indices[i];
|
UInt32 index = allFilesMode ? i : indices[i];
|
||||||
i++;
|
i++;
|
||||||
int entryIndex = m_Database.Indices[index];
|
const CItem &item = m_Database.Items[m_Database.Indices[index]];
|
||||||
const CItem &item = m_Database.Items[entryIndex];
|
const UInt64 sectionIndex = item.Section;
|
||||||
UInt64 sectionIndex = item.Section;
|
|
||||||
Int32 askMode= testMode ?
|
Int32 askMode= testMode ?
|
||||||
NExtract::NAskMode::kTest :
|
NExtract::NAskMode::kTest :
|
||||||
NExtract::NAskMode::kExtract;
|
NExtract::NAskMode::kExtract;
|
||||||
@@ -645,7 +652,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
|
|
||||||
UInt64 folderIndex = m_Database.GetFolder(index);
|
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()));
|
RINOK(lzxDecoderSpec->SetParams_and_Alloc(lzxInfo.GetNumDictBits()));
|
||||||
|
|
||||||
const CItem *lastItem = &item;
|
const CItem *lastItem = &item;
|
||||||
@@ -673,9 +680,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
{
|
{
|
||||||
for (; i < numItems; i++)
|
for (; i < numItems; i++)
|
||||||
{
|
{
|
||||||
UInt32 nextIndex = allFilesMode ? i : indices[i];
|
const UInt32 nextIndex = allFilesMode ? i : indices[i];
|
||||||
int entryIndex = m_Database.Indices[nextIndex];
|
const CItem &nextItem = m_Database.Items[m_Database.Indices[nextIndex]];
|
||||||
const CItem &nextItem = m_Database.Items[entryIndex];
|
|
||||||
if (nextItem.Section != sectionIndex)
|
if (nextItem.Section != sectionIndex)
|
||||||
break;
|
break;
|
||||||
UInt64 nextFolderIndex = m_Database.GetFolder(nextIndex);
|
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; }
|
#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 CObjectVector<CItem> &items = *(const CObjectVector<CItem> *)param;
|
||||||
const CItem &item1 = items[*p1];
|
const CItem &item1 = items[*p1];
|
||||||
@@ -731,7 +731,7 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
|||||||
RINOK(DecompressStream(inStream, database, kNameList));
|
RINOK(DecompressStream(inStream, database, kNameList));
|
||||||
/* UInt16 length = */ ReadUInt16();
|
/* UInt16 length = */ ReadUInt16();
|
||||||
UInt16 numSections = ReadUInt16();
|
UInt16 numSections = ReadUInt16();
|
||||||
for (int i = 0; i < numSections; i++)
|
for (unsigned i = 0; i < numSections; i++)
|
||||||
{
|
{
|
||||||
CSectionInfo section;
|
CSectionInfo section;
|
||||||
UInt16 nameLen = ReadUInt16();
|
UInt16 nameLen = ReadUInt16();
|
||||||
@@ -766,10 +766,10 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
|||||||
RINOK(DecompressStream(inStream, database, transformPrefix + kTransformList));
|
RINOK(DecompressStream(inStream, database, transformPrefix + kTransformList));
|
||||||
if ((_chunkSize & 0xF) != 0)
|
if ((_chunkSize & 0xF) != 0)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
int numGuids = (int)(_chunkSize / 0x10);
|
unsigned numGuids = (unsigned)(_chunkSize / 0x10);
|
||||||
if (numGuids < 1)
|
if (numGuids < 1)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
for (int i = 0; i < numGuids; i++)
|
for (unsigned i = 0; i < numGuids; i++)
|
||||||
{
|
{
|
||||||
CMethodInfo method;
|
CMethodInfo method;
|
||||||
ReadGUID(method.Guid);
|
ReadGUID(method.Guid);
|
||||||
@@ -803,14 +803,17 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
|||||||
return S_FALSE;
|
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)
|
if (n < 0 || n > 16)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
li.ResetIntervalBits = n;
|
li.ResetIntervalBits = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int n = GetLog(ReadUInt32());
|
UInt32 val32 = ReadUInt32();
|
||||||
|
int n = GetLog(val32);
|
||||||
if (n < 0 || n > 16)
|
if (n < 0 || n > 16)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
li.WindowSizeBits = n;
|
li.WindowSizeBits = n;
|
||||||
|
|||||||
@@ -177,25 +177,25 @@ class CFilesDatabase: public CDatabase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool LowLevel;
|
bool LowLevel;
|
||||||
CRecordVector<int> Indices;
|
CUIntVector Indices;
|
||||||
CObjectVector<CSectionInfo> Sections;
|
CObjectVector<CSectionInfo> Sections;
|
||||||
|
|
||||||
UInt64 GetFileSize(int fileIndex) const { return Items[Indices[fileIndex]].Size; }
|
UInt64 GetFileSize(unsigned fileIndex) const { return Items[Indices[fileIndex]].Size; }
|
||||||
UInt64 GetFileOffset(int fileIndex) const { return Items[Indices[fileIndex]].Offset; }
|
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 CItem &item = Items[Indices[fileIndex]];
|
||||||
const CSectionInfo §ion = Sections[(int)item.Section];
|
const CSectionInfo §ion = Sections[(unsigned)item.Section];
|
||||||
if (section.IsLzx())
|
if (section.IsLzx())
|
||||||
return section.Methods[0].LzxInfo.GetFolder(item.Offset);
|
return section.Methods[0].LzxInfo.GetFolder(item.Offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt64 GetLastFolder(int fileIndex) const
|
UInt64 GetLastFolder(unsigned fileIndex) const
|
||||||
{
|
{
|
||||||
const CItem &item = Items[Indices[fileIndex]];
|
const CItem &item = Items[Indices[fileIndex]];
|
||||||
const CSectionInfo §ion = Sections[(int)item.Section];
|
const CSectionInfo §ion = Sections[(unsigned)item.Section];
|
||||||
if (section.IsLzx())
|
if (section.IsLzx())
|
||||||
return section.Methods[0].LzxInfo.GetFolder(item.Offset + item.Size - 1);
|
return section.Methods[0].LzxInfo.GetFolder(item.Offset + item.Size - 1);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -433,9 +433,9 @@ HRESULT CDatabase::Open(IInStream *inStream)
|
|||||||
SectorSizeBits = sectorSizeBits;
|
SectorSizeBits = sectorSizeBits;
|
||||||
MiniSectorSizeBits = miniSectorSizeBits;
|
MiniSectorSizeBits = miniSectorSizeBits;
|
||||||
|
|
||||||
if (sectorSizeBits > 28 ||
|
if (sectorSizeBits > 24 ||
|
||||||
sectorSizeBits < 7 ||
|
sectorSizeBits < 7 ||
|
||||||
miniSectorSizeBits > 28 ||
|
miniSectorSizeBits > 24 ||
|
||||||
miniSectorSizeBits < 2 ||
|
miniSectorSizeBits < 2 ||
|
||||||
miniSectorSizeBits > sectorSizeBits)
|
miniSectorSizeBits > sectorSizeBits)
|
||||||
return S_FALSE;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return ParseMethodFromPROPVARIANT(names[i], value);
|
{
|
||||||
|
RINOK(ParseMethodFromPROPVARIANT(names[i], value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ HINSTANCE g_hInstance;
|
|||||||
|
|
||||||
#define NT_CHECK_FAIL_ACTION return FALSE;
|
#define NT_CHECK_FAIL_ACTION return FALSE;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
extern "C"
|
extern "C"
|
||||||
BOOL WINAPI DllMain(
|
BOOL WINAPI DllMain(
|
||||||
#ifdef UNDER_CE
|
#ifdef UNDER_CE
|
||||||
@@ -49,6 +50,7 @@ BOOL WINAPI DllMain(
|
|||||||
*/
|
*/
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
DEFINE_GUID(CLSID_CArchiveHandler,
|
DEFINE_GUID(CLSID_CArchiveHandler,
|
||||||
k_7zip_GUID_Data1,
|
k_7zip_GUID_Data1,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -133,15 +133,23 @@ bool CHeader::Parse(const Byte *p)
|
|||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int s = GetLog(Get16(p + 11));
|
{
|
||||||
if (s < 9 || s > 12)
|
UInt32 val32 = Get16(p + 11);
|
||||||
return false;
|
int s = GetLog(val32);
|
||||||
SectorSizeLog = (Byte)s;
|
if (s < 9 || s > 12)
|
||||||
s = GetLog(p[13]);
|
return false;
|
||||||
if (s < 0)
|
SectorSizeLog = (Byte)s;
|
||||||
return false;
|
}
|
||||||
SectorsPerClusterLog = (Byte)s;
|
{
|
||||||
|
UInt32 val32 = p[13];
|
||||||
|
int s = GetLog(val32);
|
||||||
|
if (s < 0)
|
||||||
|
return false;
|
||||||
|
SectorsPerClusterLog = (Byte)s;
|
||||||
|
}
|
||||||
ClusterSizeLog = (Byte)(SectorSizeLog + SectorsPerClusterLog);
|
ClusterSizeLog = (Byte)(SectorSizeLog + SectorsPerClusterLog);
|
||||||
|
if (ClusterSizeLog > 24)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
NumReservedSectors = Get16(p + 14);
|
NumReservedSectors = Get16(p + 14);
|
||||||
|
|||||||
@@ -156,8 +156,15 @@ class CHandler: public CHandlerCont
|
|||||||
CByteBuffer _buffer;
|
CByteBuffer _buffer;
|
||||||
|
|
||||||
HRESULT Open2(IInStream *stream);
|
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:
|
public:
|
||||||
INTERFACE_IInArchive_Cont(;)
|
INTERFACE_IInArchive_Cont(;)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,7 +28,11 @@ STDMETHODIMP CHandlerCont::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
UInt64 totalSize = 0;
|
UInt64 totalSize = 0;
|
||||||
UInt32 i;
|
UInt32 i;
|
||||||
for (i = 0; i < numItems; 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);
|
extractCallback->SetTotal(totalSize);
|
||||||
|
|
||||||
totalSize = 0;
|
totalSize = 0;
|
||||||
@@ -56,21 +60,31 @@ STDMETHODIMP CHandlerCont::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
Int32 index = allFilesMode ? i : indices[i];
|
Int32 index = allFilesMode ? i : indices[i];
|
||||||
|
|
||||||
RINOK(extractCallback->GetStream(index, &outStream, askMode));
|
RINOK(extractCallback->GetStream(index, &outStream, askMode));
|
||||||
UInt64 size = GetItemSize(index);
|
|
||||||
|
UInt64 pos, size;
|
||||||
|
int opRes = GetItem_ExtractInfo(index, pos, size);
|
||||||
totalSize += size;
|
totalSize += size;
|
||||||
if (!testMode && !outStream)
|
if (!testMode && !outStream)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
RINOK(extractCallback->PrepareOperation(askMode));
|
RINOK(extractCallback->PrepareOperation(askMode));
|
||||||
|
|
||||||
RINOK(_stream->Seek(GetItemPos(index), STREAM_SEEK_SET, NULL));
|
if (opRes == NExtract::NOperationResult::kOK)
|
||||||
streamSpec->Init(size);
|
{
|
||||||
RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
|
RINOK(_stream->Seek(pos, STREAM_SEEK_SET, NULL));
|
||||||
|
streamSpec->Init(size);
|
||||||
|
|
||||||
|
RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
|
||||||
|
|
||||||
|
opRes = NExtract::NOperationResult::kDataError;
|
||||||
|
|
||||||
|
if (copyCoderSpec->TotalSize == size)
|
||||||
|
opRes = NExtract::NOperationResult::kOK;
|
||||||
|
else if (copyCoderSpec->TotalSize < size)
|
||||||
|
opRes = NExtract::NOperationResult::kUnexpectedEnd;
|
||||||
|
}
|
||||||
|
|
||||||
outStream.Release();
|
outStream.Release();
|
||||||
int opRes = NExtract::NOperationResult::kDataError;
|
|
||||||
if (copyCoderSpec->TotalSize == size)
|
|
||||||
opRes = NExtract::NOperationResult::kOK;
|
|
||||||
else if (copyCoderSpec->TotalSize < size)
|
|
||||||
opRes = NExtract::NOperationResult::kUnexpectedEnd;
|
|
||||||
RINOK(extractCallback->SetOperationResult(opRes));
|
RINOK(extractCallback->SetOperationResult(opRes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,13 +95,22 @@ STDMETHODIMP CHandlerCont::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
STDMETHODIMP CHandlerCont::GetStream(UInt32 index, ISequentialInStream **stream)
|
STDMETHODIMP CHandlerCont::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||||
{
|
{
|
||||||
COM_TRY_BEGIN
|
COM_TRY_BEGIN
|
||||||
// const CPartition &item = _items[index];
|
*stream = NULL;
|
||||||
return CreateLimitedInStream(_stream, GetItemPos(index), GetItemSize(index), stream);
|
UInt64 pos, size;
|
||||||
|
if (GetItem_ExtractInfo(index, pos, size) != NExtract::NOperationResult::kOK)
|
||||||
|
return S_FALSE;
|
||||||
|
return CreateLimitedInStream(_stream, pos, size, stream);
|
||||||
COM_TRY_END
|
COM_TRY_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CHandlerImg::CHandlerImg():
|
||||||
|
_imgExt(NULL)
|
||||||
|
{
|
||||||
|
ClearStreamVars();
|
||||||
|
}
|
||||||
|
|
||||||
STDMETHODIMP CHandlerImg::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
STDMETHODIMP CHandlerImg::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
||||||
{
|
{
|
||||||
switch (seekOrigin)
|
switch (seekOrigin)
|
||||||
@@ -190,6 +213,8 @@ STDMETHODIMP CHandlerImg::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
|
|
||||||
int opRes = NExtract::NOperationResult::kDataError;
|
int opRes = NExtract::NOperationResult::kDataError;
|
||||||
|
|
||||||
|
ClearStreamVars();
|
||||||
|
|
||||||
CMyComPtr<ISequentialInStream> inStream;
|
CMyComPtr<ISequentialInStream> inStream;
|
||||||
HRESULT hres = GetStream(0, &inStream);
|
HRESULT hres = GetStream(0, &inStream);
|
||||||
if (hres == S_FALSE)
|
if (hres == S_FALSE)
|
||||||
@@ -205,6 +230,13 @@ STDMETHODIMP CHandlerImg::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
{
|
{
|
||||||
if (copyCoderSpec->TotalSize == _size)
|
if (copyCoderSpec->TotalSize == _size)
|
||||||
opRes = NExtract::NOperationResult::kOK;
|
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)
|
else if (copyCoderSpec->TotalSize < _size)
|
||||||
opRes = NExtract::NOperationResult::kUnexpectedEnd;
|
opRes = NExtract::NOperationResult::kUnexpectedEnd;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class CHandlerCont:
|
|||||||
protected:
|
protected:
|
||||||
CMyComPtr<IInStream> _stream;
|
CMyComPtr<IInStream> _stream;
|
||||||
|
|
||||||
virtual UInt64 GetItemPos(UInt32 index) const = 0;
|
virtual int GetItem_ExtractInfo(UInt32 index, UInt64 &pos, UInt64 &size) const = 0;
|
||||||
virtual UInt64 GetItemSize(UInt32 index) const = 0;
|
|
||||||
public:
|
public:
|
||||||
MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
|
MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
|
||||||
INTERFACE_IInArchive_Cont(PURE)
|
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(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) MY_NO_THROW_DECL_ONLY;
|
||||||
|
|
||||||
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
|
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
|
||||||
|
|
||||||
|
// destructor must be virtual for this class
|
||||||
|
virtual ~CHandlerCont() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +71,22 @@ protected:
|
|||||||
UInt64 _size;
|
UInt64 _size;
|
||||||
CMyComPtr<IInStream> Stream;
|
CMyComPtr<IInStream> Stream;
|
||||||
const char *_imgExt;
|
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 HRESULT Open2(IInStream *stream, IArchiveOpenCallback *openCallback) = 0;
|
||||||
virtual void CloseAtError();
|
virtual void CloseAtError();
|
||||||
@@ -83,6 +102,10 @@ public:
|
|||||||
|
|
||||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) = 0;
|
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) = 0;
|
||||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||||
|
|
||||||
|
CHandlerImg();
|
||||||
|
// destructor must be virtual for this class
|
||||||
|
virtual ~CHandlerImg() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
{
|
{
|
||||||
lps->InSize = lps->OutSize = currentTotalSize + offset;
|
lps->InSize = lps->OutSize = currentTotalSize + offset;
|
||||||
const CDir &item2 = ref.Dir->_subItems[ref.Index + e];
|
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);
|
streamSpec->Init(item2.Size);
|
||||||
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
||||||
if (copyCoderSpec->TotalSize != item2.Size)
|
if (copyCoderSpec->TotalSize != item2.Size)
|
||||||
@@ -336,7 +336,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RINOK(_stream->Seek(blockIndex * _archive.BlockSize, STREAM_SEEK_SET, NULL));
|
RINOK(_stream->Seek((UInt64)blockIndex * kBlockSize, STREAM_SEEK_SET, NULL));
|
||||||
streamSpec->Init(currentItemSize);
|
streamSpec->Init(currentItemSize);
|
||||||
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
||||||
if (copyCoderSpec->TotalSize != currentItemSize)
|
if (copyCoderSpec->TotalSize != currentItemSize)
|
||||||
@@ -379,7 +379,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
|||||||
if (item.Size == 0)
|
if (item.Size == 0)
|
||||||
continue;
|
continue;
|
||||||
CSeekExtent se;
|
CSeekExtent se;
|
||||||
se.Phy = (UInt64)item.ExtentLocation * _archive.BlockSize;
|
se.Phy = (UInt64)item.ExtentLocation * kBlockSize;
|
||||||
se.Virt = virtOffset;
|
se.Virt = virtOffset;
|
||||||
extentStreamSpec->Extents.Add(se);
|
extentStreamSpec->Extents.Add(se);
|
||||||
virtOffset += item.Size;
|
virtOffset += item.Size;
|
||||||
@@ -405,7 +405,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
|||||||
blockIndex = be.LoadRBA;
|
blockIndex = be.LoadRBA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CreateLimitedInStream(_stream, blockIndex * _archive.BlockSize, currentItemSize, stream);
|
return CreateLimitedInStream(_stream, (UInt64)blockIndex * kBlockSize, currentItemSize, stream);
|
||||||
COM_TRY_END
|
COM_TRY_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,15 +88,15 @@ AString CBootInitialEntry::GetName() const
|
|||||||
|
|
||||||
Byte CInArchive::ReadByte()
|
Byte CInArchive::ReadByte()
|
||||||
{
|
{
|
||||||
if (m_BufferPos >= BlockSize)
|
if (m_BufferPos >= kBlockSize)
|
||||||
m_BufferPos = 0;
|
m_BufferPos = 0;
|
||||||
if (m_BufferPos == 0)
|
if (m_BufferPos == 0)
|
||||||
{
|
{
|
||||||
size_t processed = BlockSize;
|
size_t processed = kBlockSize;
|
||||||
HRESULT res = ReadStream(_stream, m_Buffer, &processed);
|
HRESULT res = ReadStream(_stream, m_Buffer, &processed);
|
||||||
if (res != S_OK)
|
if (res != S_OK)
|
||||||
throw CSystemException(res);
|
throw CSystemException(res);
|
||||||
if (processed != BlockSize)
|
if (processed != kBlockSize)
|
||||||
throw CUnexpectedEndException();
|
throw CUnexpectedEndException();
|
||||||
UInt64 end = _position + processed;
|
UInt64 end = _position + processed;
|
||||||
if (PhySize < end)
|
if (PhySize < end)
|
||||||
@@ -294,7 +294,11 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
|
|||||||
d.FileStructureVersion = ReadByte(); // = 1
|
d.FileStructureVersion = ReadByte(); // = 1
|
||||||
SkipZeros(1);
|
SkipZeros(1);
|
||||||
ReadBytes(d.ApplicationUse, sizeof(d.ApplicationUse));
|
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' };
|
static const Byte kSig_CD001[5] = { 'C', 'D', '0', '0', '1' };
|
||||||
@@ -511,7 +515,7 @@ HRESULT CInArchive::Open2()
|
|||||||
|
|
||||||
PhySize = _position;
|
PhySize = _position;
|
||||||
m_BufferPos = 0;
|
m_BufferPos = 0;
|
||||||
BlockSize = kBlockSize;
|
// BlockSize = kBlockSize;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ public:
|
|||||||
CRecordVector<CRef> Refs;
|
CRecordVector<CRef> Refs;
|
||||||
CObjectVector<CVolumeDescriptor> VolDescs;
|
CObjectVector<CVolumeDescriptor> VolDescs;
|
||||||
int MainVolDescIndex;
|
int MainVolDescIndex;
|
||||||
UInt32 BlockSize;
|
// UInt32 BlockSize;
|
||||||
CObjectVector<CBootInitialEntry> BootEntries;
|
CObjectVector<CBootInitialEntry> BootEntries;
|
||||||
|
|
||||||
bool IsArc;
|
bool IsArc;
|
||||||
@@ -297,8 +297,8 @@ public:
|
|||||||
|
|
||||||
void UpdatePhySize(UInt32 blockIndex, UInt64 size)
|
void UpdatePhySize(UInt32 blockIndex, UInt64 size)
|
||||||
{
|
{
|
||||||
UInt64 alignedSize = (size + BlockSize - 1) & ~((UInt64)BlockSize - 1);
|
const UInt64 alignedSize = (size + kBlockSize - 1) & ~((UInt64)kBlockSize - 1);
|
||||||
UInt64 end = blockIndex * BlockSize + alignedSize;
|
const UInt64 end = (UInt64)blockIndex * kBlockSize + alignedSize;
|
||||||
if (PhySize < end)
|
if (PhySize < end)
|
||||||
PhySize = end;
|
PhySize = end;
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ public:
|
|||||||
size = (1440 << 10);
|
size = (1440 << 10);
|
||||||
else if (be.BootMediaType == NBootMediaType::k2d88Floppy)
|
else if (be.BootMediaType == NBootMediaType::k2d88Floppy)
|
||||||
size = (2880 << 10);
|
size = (2880 << 10);
|
||||||
UInt64 startPos = (UInt64)be.LoadRBA * BlockSize;
|
UInt64 startPos = (UInt64)be.LoadRBA * kBlockSize;
|
||||||
if (startPos < _fileSize)
|
if (startPos < _fileSize)
|
||||||
{
|
{
|
||||||
if (_fileSize - startPos < size)
|
if (_fileSize - startPos < size)
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ static const CPartType kPartTypes[] =
|
|||||||
{ 0x1E, kFat, "FAT16-LBA-WIN95-Hidden" },
|
{ 0x1E, kFat, "FAT16-LBA-WIN95-Hidden" },
|
||||||
{ 0x82, 0, "Solaris x86 / Linux swap" },
|
{ 0x82, 0, "Solaris x86 / Linux swap" },
|
||||||
{ 0x83, 0, "Linux" },
|
{ 0x83, 0, "Linux" },
|
||||||
|
{ 0x8E, "lvm", "Linux LVM" },
|
||||||
{ 0xA5, 0, "BSD slice" },
|
{ 0xA5, 0, "BSD slice" },
|
||||||
{ 0xBE, 0, "Solaris 8 boot" },
|
{ 0xBE, 0, "Solaris 8 boot" },
|
||||||
{ 0xBF, 0, "New Solaris x86" },
|
{ 0xBF, 0, "New Solaris x86" },
|
||||||
@@ -189,8 +190,14 @@ class CHandler: public CHandlerCont
|
|||||||
UInt64 _totalSize;
|
UInt64 _totalSize;
|
||||||
CByteBuffer _buffer;
|
CByteBuffer _buffer;
|
||||||
|
|
||||||
virtual UInt64 GetItemPos(UInt32 index) const { return _items[index].Part.GetPos(); }
|
virtual int GetItem_ExtractInfo(UInt32 index, UInt64 &pos, UInt64 &size) const
|
||||||
virtual UInt64 GetItemSize(UInt32 index) const { return _items[index].Size; }
|
{
|
||||||
|
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);
|
HRESULT ReadTables(IInStream *stream, UInt32 baseLba, UInt32 lba, unsigned level);
|
||||||
public:
|
public:
|
||||||
INTERFACE_IInArchive_Cont(;)
|
INTERFACE_IInArchive_Cont(;)
|
||||||
|
|||||||
@@ -56,8 +56,15 @@ class CHandler: public CHandlerCont
|
|||||||
CItem _items[kNumFilesMax];
|
CItem _items[kNumFilesMax];
|
||||||
|
|
||||||
HRESULT Open2(IInStream *stream);
|
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:
|
public:
|
||||||
INTERFACE_IInArchive_Cont(;)
|
INTERFACE_IInArchive_Cont(;)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -576,20 +576,20 @@ class CInStream:
|
|||||||
UInt64 _physPos;
|
UInt64 _physPos;
|
||||||
UInt64 _curRem;
|
UInt64 _curRem;
|
||||||
bool _sparseMode;
|
bool _sparseMode;
|
||||||
size_t _compressedPos;
|
|
||||||
|
|
||||||
UInt64 _tags[kNumCacheChunks];
|
|
||||||
unsigned _chunkSizeLog;
|
unsigned _chunkSizeLog;
|
||||||
|
UInt64 _tags[kNumCacheChunks];
|
||||||
CByteBuffer _inBuf;
|
CByteBuffer _inBuf;
|
||||||
CByteBuffer _outBuf;
|
CByteBuffer _outBuf;
|
||||||
public:
|
public:
|
||||||
CMyComPtr<IInStream> Stream;
|
|
||||||
UInt64 Size;
|
UInt64 Size;
|
||||||
UInt64 InitializedSize;
|
UInt64 InitializedSize;
|
||||||
unsigned BlockSizeLog;
|
unsigned BlockSizeLog;
|
||||||
unsigned CompressionUnit;
|
unsigned CompressionUnit;
|
||||||
bool InUse;
|
|
||||||
CRecordVector<CExtent> Extents;
|
CRecordVector<CExtent> Extents;
|
||||||
|
bool InUse;
|
||||||
|
CMyComPtr<IInStream> Stream;
|
||||||
|
|
||||||
HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
|
HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
|
||||||
|
|
||||||
@@ -597,11 +597,11 @@ public:
|
|||||||
HRESULT InitAndSeek(unsigned compressionUnit)
|
HRESULT InitAndSeek(unsigned compressionUnit)
|
||||||
{
|
{
|
||||||
CompressionUnit = compressionUnit;
|
CompressionUnit = compressionUnit;
|
||||||
|
_chunkSizeLog = BlockSizeLog + CompressionUnit;
|
||||||
if (compressionUnit != 0)
|
if (compressionUnit != 0)
|
||||||
{
|
{
|
||||||
UInt32 cuSize = GetCuSize();
|
UInt32 cuSize = GetCuSize();
|
||||||
_inBuf.Alloc(cuSize);
|
_inBuf.Alloc(cuSize);
|
||||||
_chunkSizeLog = BlockSizeLog + CompressionUnit;
|
|
||||||
_outBuf.Alloc(kNumCacheChunks << _chunkSizeLog);
|
_outBuf.Alloc(kNumCacheChunks << _chunkSizeLog);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < kNumCacheChunks; i++)
|
for (size_t i = 0; i < kNumCacheChunks; i++)
|
||||||
|
|||||||
@@ -1292,6 +1292,18 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case kpidError:
|
||||||
|
{
|
||||||
|
if (/* &_missingVol || */ !_missingVolName.IsEmpty())
|
||||||
|
{
|
||||||
|
UString s;
|
||||||
|
s.SetFromAscii("Missing volume : ");
|
||||||
|
s += _missingVolName;
|
||||||
|
prop = s;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case kpidErrorFlags:
|
case kpidErrorFlags:
|
||||||
{
|
{
|
||||||
UInt32 v = _errorFlags;
|
UInt32 v = _errorFlags;
|
||||||
@@ -1813,6 +1825,8 @@ HRESULT CHandler::Open2(IInStream *stream,
|
|||||||
int prevSplitFile = -1;
|
int prevSplitFile = -1;
|
||||||
int prevMainFile = -1;
|
int prevMainFile = -1;
|
||||||
|
|
||||||
|
bool nextVol_is_Required = false;
|
||||||
|
|
||||||
CInArchive arch;
|
CInArchive arch;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
@@ -1840,13 +1854,19 @@ HRESULT CHandler::Open2(IInStream *stream,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT result = openVolumeCallback->GetStream(seqName.GetNextName(), &inStream);
|
const UString volName = seqName.GetNextName();
|
||||||
if (result == S_FALSE)
|
|
||||||
break;
|
HRESULT result = openVolumeCallback->GetStream(volName, &inStream);
|
||||||
if (result != S_OK)
|
|
||||||
|
if (result != S_OK && result != S_FALSE)
|
||||||
return result;
|
return result;
|
||||||
if (!inStream)
|
|
||||||
|
if (!inStream || result != S_OK)
|
||||||
|
{
|
||||||
|
if (nextVol_is_Required)
|
||||||
|
_missingVolName = volName;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt64 endPos = 0;
|
UInt64 endPos = 0;
|
||||||
@@ -2094,11 +2114,18 @@ HRESULT CHandler::Open2(IInStream *stream,
|
|||||||
}
|
}
|
||||||
|
|
||||||
curBytes += endPos;
|
curBytes += endPos;
|
||||||
|
|
||||||
|
nextVol_is_Required = false;
|
||||||
|
|
||||||
if (!arcInfo.IsVolume())
|
if (!arcInfo.IsVolume())
|
||||||
break;
|
break;
|
||||||
if (arcInfo.EndOfArchive_was_Read
|
|
||||||
&& !arcInfo.AreMoreVolumes())
|
if (arcInfo.EndOfArchive_was_Read)
|
||||||
break;
|
{
|
||||||
|
if (!arcInfo.AreMoreVolumes())
|
||||||
|
break;
|
||||||
|
nextVol_is_Required = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FillLinks();
|
FillLinks();
|
||||||
@@ -2120,6 +2147,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
|||||||
STDMETHODIMP CHandler::Close()
|
STDMETHODIMP CHandler::Close()
|
||||||
{
|
{
|
||||||
COM_TRY_BEGIN
|
COM_TRY_BEGIN
|
||||||
|
_missingVolName.Empty();
|
||||||
_errorFlags = 0;
|
_errorFlags = 0;
|
||||||
// _warningFlags = 0;
|
// _warningFlags = 0;
|
||||||
_isArc = false;
|
_isArc = false;
|
||||||
|
|||||||
@@ -381,6 +381,7 @@ private:
|
|||||||
// UInt32 _warningFlags;
|
// UInt32 _warningFlags;
|
||||||
bool _isArc;
|
bool _isArc;
|
||||||
CByteBuffer _comment;
|
CByteBuffer _comment;
|
||||||
|
UString _missingVolName;
|
||||||
|
|
||||||
DECL_EXTERNAL_CODECS_VARS
|
DECL_EXTERNAL_CODECS_VARS
|
||||||
|
|
||||||
|
|||||||
@@ -640,6 +640,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
|
|||||||
{
|
{
|
||||||
ArcInfo.EndFlags = m_BlockHeader.Flags;
|
ArcInfo.EndFlags = m_BlockHeader.Flags;
|
||||||
UInt32 offset = 7;
|
UInt32 offset = 7;
|
||||||
|
|
||||||
if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_DataCRC)
|
if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_DataCRC)
|
||||||
{
|
{
|
||||||
if (processed < offset + 4)
|
if (processed < offset + 4)
|
||||||
@@ -648,6 +649,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
|
|||||||
ArcInfo.DataCRC = Get32(m_FileHeaderData + offset);
|
ArcInfo.DataCRC = Get32(m_FileHeaderData + offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_VolNumber)
|
if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_VolNumber)
|
||||||
{
|
{
|
||||||
if (processed < offset + 2)
|
if (processed < offset + 2)
|
||||||
@@ -657,6 +659,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
|
|||||||
|
|
||||||
ArcInfo.EndOfArchive_was_Read = true;
|
ArcInfo.EndOfArchive_was_Read = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Position += processed;
|
m_Position += processed;
|
||||||
FinishCryptoBlock();
|
FinishCryptoBlock();
|
||||||
ArcInfo.EndPos = m_Position;
|
ArcInfo.EndPos = m_Position;
|
||||||
@@ -699,11 +702,13 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
|
|||||||
continue;
|
continue;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 10))
|
if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 10))
|
||||||
{
|
{
|
||||||
error = k_ErrorType_DecryptionError;
|
error = k_ErrorType_DecryptionError;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_BlockHeader.Flags & NHeader::NBlock::kLongBlock) != 0)
|
if ((m_BlockHeader.Flags & NHeader::NBlock::kLongBlock) != 0)
|
||||||
{
|
{
|
||||||
if (m_FileHeaderData.Size() < 7 + 4)
|
if (m_FileHeaderData.Size() < 7 + 4)
|
||||||
@@ -855,8 +860,21 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
break;
|
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:
|
case kpidErrorFlags:
|
||||||
{
|
{
|
||||||
UInt32 v = _errorFlags;
|
UInt32 v = _errorFlags;
|
||||||
@@ -1019,7 +1037,10 @@ HRESULT CHandler::Open2(IInStream *stream,
|
|||||||
openCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getTextPassword);
|
openCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getTextPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nextVol_is_Required = false;
|
||||||
|
|
||||||
CInArchive archive;
|
CInArchive archive;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
CMyComPtr<IInStream> inStream;
|
CMyComPtr<IInStream> inStream;
|
||||||
@@ -1050,14 +1071,19 @@ HRESULT CHandler::Open2(IInStream *stream,
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
UString fullName = seqName.GetNextName();
|
const UString volName = seqName.GetNextName();
|
||||||
HRESULT result = openVolumeCallback->GetStream(fullName, &inStream);
|
|
||||||
if (result == S_FALSE)
|
HRESULT result = openVolumeCallback->GetStream(volName, &inStream);
|
||||||
break;
|
|
||||||
if (result != S_OK)
|
if (result != S_OK && result != S_FALSE)
|
||||||
return result;
|
return result;
|
||||||
if (!inStream)
|
|
||||||
|
if (!inStream || result != S_OK)
|
||||||
|
{
|
||||||
|
if (nextVol_is_Required)
|
||||||
|
_missingVolName = volName;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
inStream = stream;
|
inStream = stream;
|
||||||
@@ -1174,6 +1200,18 @@ HRESULT CHandler::Open2(IInStream *stream,
|
|||||||
arc.PhySize = archive.ArcInfo.GetPhySize();
|
arc.PhySize = archive.ArcInfo.GetPhySize();
|
||||||
arc.Stream = inStream;
|
arc.Stream = inStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nextVol_is_Required = false;
|
||||||
|
|
||||||
|
if (!archive.ArcInfo.IsVolume())
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (archive.ArcInfo.EndOfArchive_was_Read)
|
||||||
|
{
|
||||||
|
if (!archive.ArcInfo.AreMoreVolumes())
|
||||||
|
break;
|
||||||
|
nextVol_is_Required = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1216,6 +1254,7 @@ STDMETHODIMP CHandler::Close()
|
|||||||
{
|
{
|
||||||
COM_TRY_BEGIN
|
COM_TRY_BEGIN
|
||||||
// _errorMessage.Empty();
|
// _errorMessage.Empty();
|
||||||
|
_missingVolName.Empty();
|
||||||
_errorFlags = 0;
|
_errorFlags = 0;
|
||||||
_warningFlags = 0;
|
_warningFlags = 0;
|
||||||
_isArc = false;
|
_isArc = false;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ struct CInArcInfo
|
|||||||
|
|
||||||
bool IsEncryptOld() const { return (!IsThereEncryptVer() || EncryptVersion < 36); }
|
bool IsEncryptOld() const { return (!IsThereEncryptVer() || EncryptVersion < 36); }
|
||||||
|
|
||||||
|
bool AreMoreVolumes() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_NextVol) != 0; }
|
||||||
bool Is_VolNumber_Defined() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_VolNumber) != 0; }
|
bool Is_VolNumber_Defined() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_VolNumber) != 0; }
|
||||||
bool Is_DataCRC_Defined() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_DataCRC) != 0; }
|
bool Is_DataCRC_Defined() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_DataCRC) != 0; }
|
||||||
};
|
};
|
||||||
@@ -79,6 +80,7 @@ class CHandler:
|
|||||||
UInt32 _errorFlags;
|
UInt32 _errorFlags;
|
||||||
UInt32 _warningFlags;
|
UInt32 _warningFlags;
|
||||||
bool _isArc;
|
bool _isArc;
|
||||||
|
UString _missingVolName;
|
||||||
|
|
||||||
DECL_EXTERNAL_CODECS_VARS
|
DECL_EXTERNAL_CODECS_VARS
|
||||||
|
|
||||||
|
|||||||
@@ -226,8 +226,13 @@ class CHandler: public CHandlerCont
|
|||||||
HRESULT ReadHeader(ISequentialInStream *stream, bool isMainHeader);
|
HRESULT ReadHeader(ISequentialInStream *stream, bool isMainHeader);
|
||||||
HRESULT Open2(ISequentialInStream *stream);
|
HRESULT Open2(ISequentialInStream *stream);
|
||||||
|
|
||||||
virtual UInt64 GetItemPos(UInt32) const { return _headersSize; }
|
virtual int GetItem_ExtractInfo(UInt32 /* index */, UInt64 &pos, UInt64 &size) const
|
||||||
virtual UInt64 GetItemSize(UInt32) const { return _size; }
|
{
|
||||||
|
pos = _headersSize;
|
||||||
|
size = _size;
|
||||||
|
return NExtract::NOperationResult::kOK;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
INTERFACE_IInArchive_Cont(;)
|
INTERFACE_IInArchive_Cont(;)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
if (!_archive.IsArc) v |= kpv_ErrorFlags_IsNotArc;
|
if (!_archive.IsArc) v |= kpv_ErrorFlags_IsNotArc;
|
||||||
if (_archive.Unsupported) v |= kpv_ErrorFlags_UnsupportedFeature;
|
if (_archive.Unsupported) v |= kpv_ErrorFlags_UnsupportedFeature;
|
||||||
if (_archive.UnexpectedEnd) v |= kpv_ErrorFlags_UnexpectedEnd;
|
if (_archive.UnexpectedEnd) v |= kpv_ErrorFlags_UnexpectedEnd;
|
||||||
|
if (_archive.NoEndAnchor) v |= kpv_ErrorFlags_HeadersError;
|
||||||
prop = v;
|
prop = v;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -564,7 +564,7 @@ HRESULT CInArchive::ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &la
|
|||||||
return S_OK;
|
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)
|
if ((_numRefs & 0xFFF) == 0)
|
||||||
{
|
{
|
||||||
@@ -610,6 +610,7 @@ API_FUNC_IsArc IsArc_Udf(const Byte *p, size_t size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT CInArchive::Open2()
|
HRESULT CInArchive::Open2()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
@@ -644,8 +645,10 @@ HRESULT CInArchive::Open2()
|
|||||||
CExtent extentVDS;
|
CExtent extentVDS;
|
||||||
extentVDS.Parse(buf + i + 16);
|
extentVDS.Parse(buf + i + 16);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const size_t kBufSize = 1 << 11;
|
const size_t kBufSize = 1 << 11;
|
||||||
Byte buf[kBufSize];
|
Byte buf[kBufSize];
|
||||||
|
|
||||||
for (SecLogSize = 11;; SecLogSize -= 3)
|
for (SecLogSize = 11;; SecLogSize -= 3)
|
||||||
{
|
{
|
||||||
if (SecLogSize < 8)
|
if (SecLogSize < 8)
|
||||||
@@ -665,6 +668,7 @@ HRESULT CInArchive::Open2()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PhySize = (UInt32)(256 + 1) << SecLogSize;
|
PhySize = (UInt32)(256 + 1) << SecLogSize;
|
||||||
IsArc = true;
|
IsArc = true;
|
||||||
|
|
||||||
@@ -946,28 +950,63 @@ HRESULT CInArchive::Open2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
UInt32 secMask = ((UInt32)1 << SecLogSize) - 1;
|
const UInt32 secMask = ((UInt32)1 << SecLogSize) - 1;
|
||||||
PhySize = (PhySize + secMask) & ~(UInt64)secMask;
|
PhySize = (PhySize + secMask) & ~(UInt64)secMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NoEndAnchor = true;
|
||||||
|
|
||||||
if (PhySize < fileSize)
|
if (PhySize < fileSize)
|
||||||
{
|
{
|
||||||
|
UInt64 rem = fileSize - PhySize;
|
||||||
|
const size_t secSize = (size_t)1 << SecLogSize;
|
||||||
|
|
||||||
RINOK(_stream->Seek(PhySize, STREAM_SEEK_SET, NULL));
|
RINOK(_stream->Seek(PhySize, STREAM_SEEK_SET, NULL));
|
||||||
size_t bufSize = (UInt32)1 << SecLogSize;
|
|
||||||
size_t readSize = bufSize;
|
// some UDF images contain ZEROs before "Anchor Volume Descriptor Pointer" at the end
|
||||||
RINOK(ReadStream(_stream, buf, &readSize));
|
|
||||||
if (readSize == bufSize)
|
for (unsigned sec = 0; sec < 1024; sec++)
|
||||||
{
|
{
|
||||||
CTag tag;
|
if (rem == 0)
|
||||||
if (tag.Parse(buf, readSize) == S_OK)
|
break;
|
||||||
if (tag.Id == DESC_TYPE_AnchorVolPtr)
|
|
||||||
|
size_t readSize = secSize;
|
||||||
|
if (readSize > rem)
|
||||||
|
readSize = (size_t)rem;
|
||||||
|
|
||||||
|
RINOK(ReadStream(_stream, buf, &readSize));
|
||||||
|
|
||||||
|
if (readSize == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (readSize == secSize && NoEndAnchor)
|
||||||
|
{
|
||||||
|
CTag tag;
|
||||||
|
if (tag.Parse(buf, readSize) == S_OK &&
|
||||||
|
tag.Id == DESC_TYPE_AnchorVolPtr)
|
||||||
{
|
{
|
||||||
PhySize += bufSize;
|
NoEndAnchor = false;
|
||||||
|
rem -= readSize;
|
||||||
|
PhySize = fileSize - rem;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < readSize && buf[i] == 0; i++);
|
||||||
|
if (i != readSize)
|
||||||
|
break;
|
||||||
|
rem -= readSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rem == 0)
|
||||||
|
PhySize = fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT CInArchive::Open(IInStream *inStream, CProgressVirt *progress)
|
HRESULT CInArchive::Open(IInStream *inStream, CProgressVirt *progress)
|
||||||
{
|
{
|
||||||
_progress = progress;
|
_progress = progress;
|
||||||
@@ -1000,6 +1039,7 @@ void CInArchive::Clear()
|
|||||||
IsArc = false;
|
IsArc = false;
|
||||||
Unsupported = false;
|
Unsupported = false;
|
||||||
UnexpectedEnd = false;
|
UnexpectedEnd = false;
|
||||||
|
NoEndAnchor = false;
|
||||||
|
|
||||||
PhySize = 0;
|
PhySize = 0;
|
||||||
FileSize = 0;
|
FileSize = 0;
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ struct CItem
|
|||||||
bool IsInline;
|
bool IsInline;
|
||||||
CByteBuffer InlineData;
|
CByteBuffer InlineData;
|
||||||
CRecordVector<CMyExtent> Extents;
|
CRecordVector<CMyExtent> Extents;
|
||||||
CRecordVector<int> SubFiles;
|
CUIntVector SubFiles;
|
||||||
|
|
||||||
void Parse(const Byte *buf);
|
void Parse(const Byte *buf);
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ struct CItem
|
|||||||
struct CRef
|
struct CRef
|
||||||
{
|
{
|
||||||
int Parent;
|
int Parent;
|
||||||
int FileIndex;
|
unsigned FileIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ class CInArchive
|
|||||||
HRESULT ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed);
|
HRESULT ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed);
|
||||||
|
|
||||||
HRESULT Open2();
|
HRESULT Open2();
|
||||||
HRESULT FillRefs(CFileSet &fs, int fileIndex, int parent, int numRecurseAllowed);
|
HRESULT FillRefs(CFileSet &fs, unsigned fileIndex, int parent, int numRecurseAllowed);
|
||||||
|
|
||||||
UInt64 _processedProgressBytes;
|
UInt64 _processedProgressBytes;
|
||||||
|
|
||||||
@@ -370,6 +370,7 @@ public:
|
|||||||
bool IsArc;
|
bool IsArc;
|
||||||
bool Unsupported;
|
bool Unsupported;
|
||||||
bool UnexpectedEnd;
|
bool UnexpectedEnd;
|
||||||
|
bool NoEndAnchor;
|
||||||
|
|
||||||
void UpdatePhySize(UInt64 val)
|
void UpdatePhySize(UInt64 val)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -682,9 +682,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
{
|
{
|
||||||
s += " -> ";
|
s += " -> ";
|
||||||
const CHandler *p = this;
|
const CHandler *p = this;
|
||||||
while (p != 0 && p->NeedParent())
|
while (p && p->NeedParent())
|
||||||
p = p->Parent;
|
p = p->Parent;
|
||||||
if (p == 0)
|
if (!p)
|
||||||
s += '?';
|
s += '?';
|
||||||
else
|
else
|
||||||
s += p->Footer.GetTypeString();
|
s += p->Footer.GetTypeString();
|
||||||
@@ -750,26 +750,24 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
COM_TRY_END
|
COM_TRY_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback *openArchiveCallback, unsigned level)
|
HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback *openArchiveCallback, unsigned level)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
Stream = stream;
|
Stream = stream;
|
||||||
if (level > (1 << 12)) // Maybe we need to increase that limit
|
if (level > (1 << 12)) // Maybe we need to increase that limit
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
RINOK(Open3());
|
RINOK(Open3());
|
||||||
|
|
||||||
if (child && memcmp(child->Dyn.ParentId, Footer.Id, 16) != 0)
|
if (child && memcmp(child->Dyn.ParentId, Footer.Id, 16) != 0)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
if (Footer.Type != kDiskType_Diff)
|
if (Footer.Type != kDiskType_Diff)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
|
|
||||||
if (openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback) != S_OK)
|
|
||||||
{
|
|
||||||
// return S_FALSE;
|
|
||||||
}
|
|
||||||
CMyComPtr<IInStream> nextStream;
|
|
||||||
|
|
||||||
bool useRelative;
|
bool useRelative;
|
||||||
UString name;
|
UString name;
|
||||||
|
|
||||||
if (!Dyn.RelativeParentNameFromLocator.IsEmpty())
|
if (!Dyn.RelativeParentNameFromLocator.IsEmpty())
|
||||||
{
|
{
|
||||||
useRelative = true;
|
useRelative = true;
|
||||||
@@ -780,11 +778,17 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
|||||||
useRelative = false;
|
useRelative = false;
|
||||||
name = Dyn.ParentName;
|
name = Dyn.ParentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dyn.RelativeNameWasUsed = useRelative;
|
Dyn.RelativeNameWasUsed = useRelative;
|
||||||
|
|
||||||
|
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
|
||||||
|
openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
|
||||||
|
|
||||||
if (openVolumeCallback)
|
if (openVolumeCallback)
|
||||||
{
|
{
|
||||||
|
CMyComPtr<IInStream> nextStream;
|
||||||
HRESULT res = openVolumeCallback->GetStream(name, &nextStream);
|
HRESULT res = openVolumeCallback->GetStream(name, &nextStream);
|
||||||
|
|
||||||
if (res == S_FALSE)
|
if (res == S_FALSE)
|
||||||
{
|
{
|
||||||
if (useRelative && Dyn.ParentName != Dyn.RelativeParentNameFromLocator)
|
if (useRelative && Dyn.ParentName != Dyn.RelativeParentNameFromLocator)
|
||||||
@@ -793,19 +797,35 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
|||||||
if (res == S_OK)
|
if (res == S_OK)
|
||||||
Dyn.RelativeNameWasUsed = false;
|
Dyn.RelativeNameWasUsed = false;
|
||||||
}
|
}
|
||||||
if (res == S_FALSE)
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
RINOK(res);
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
Parent = new CHandler;
|
Parent = new CHandler;
|
||||||
ParentStream = Parent;
|
ParentStream = Parent;
|
||||||
|
|
||||||
res = Parent->Open2(nextStream, this, openArchiveCallback, level + 1);
|
res = Parent->Open2(nextStream, this, openArchiveCallback, level + 1);
|
||||||
if (res == S_FALSE)
|
|
||||||
|
if (res != S_OK)
|
||||||
{
|
{
|
||||||
Parent = NULL;
|
Parent = NULL;
|
||||||
ParentStream.Release();
|
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())
|
while (p->NeedParent())
|
||||||
{
|
{
|
||||||
p = p->Parent;
|
p = p->Parent;
|
||||||
if (p == 0)
|
if (!p)
|
||||||
{
|
{
|
||||||
AddErrorMessage(L"Can't open parent VHD file:");
|
AddErrorMessage(L"Can't open parent VHD file:");
|
||||||
AddErrorMessage(Dyn.ParentName);
|
AddErrorMessage(Dyn.ParentName);
|
||||||
@@ -824,12 +844,13 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CHandler::CloseAtError()
|
void CHandler::CloseAtError()
|
||||||
{
|
{
|
||||||
_phySize = 0;
|
_phySize = 0;
|
||||||
Bat.Clear();
|
Bat.Clear();
|
||||||
NumUsedBlocks = 0;
|
NumUsedBlocks = 0;
|
||||||
Parent = 0;
|
Parent = NULL;
|
||||||
Stream.Release();
|
Stream.Release();
|
||||||
ParentStream.Release();
|
ParentStream.Release();
|
||||||
Dyn.Clear();
|
Dyn.Clear();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1028,6 +1028,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCal
|
|||||||
COM_TRY_END
|
COM_TRY_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP CHandler::Close()
|
STDMETHODIMP CHandler::Close()
|
||||||
{
|
{
|
||||||
_firstVolumeIndex = -1;
|
_firstVolumeIndex = -1;
|
||||||
@@ -1093,7 +1094,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
CMyComPtr<ICompressProgressInfo> progress = lps;
|
CMyComPtr<ICompressProgressInfo> progress = lps;
|
||||||
lps->Init(extractCallback, false);
|
lps->Init(extractCallback, false);
|
||||||
|
|
||||||
for (i = 0; i < numItems;
|
for (i = 0;; i++,
|
||||||
currentTotalUnPacked += currentItemUnPacked)
|
currentTotalUnPacked += currentItemUnPacked)
|
||||||
{
|
{
|
||||||
currentItemUnPacked = 0;
|
currentItemUnPacked = 0;
|
||||||
@@ -1102,14 +1103,18 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
lps->OutSize = currentTotalUnPacked;
|
lps->OutSize = currentTotalUnPacked;
|
||||||
|
|
||||||
RINOK(lps->SetCur());
|
RINOK(lps->SetCur());
|
||||||
|
|
||||||
|
if (i >= numItems)
|
||||||
|
break;
|
||||||
|
|
||||||
UInt32 index = allFilesMode ? i : indices[i];
|
UInt32 index = allFilesMode ? i : indices[i];
|
||||||
i++;
|
|
||||||
Int32 askMode = testMode ?
|
Int32 askMode = testMode ?
|
||||||
NExtract::NAskMode::kTest :
|
NExtract::NAskMode::kTest :
|
||||||
NExtract::NAskMode::kExtract;
|
NExtract::NAskMode::kExtract;
|
||||||
|
|
||||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||||
|
|
||||||
if (index >= _db.SortedItems.Size())
|
if (index >= _db.SortedItems.Size())
|
||||||
{
|
{
|
||||||
if (!testMode && !realOutStream)
|
if (!testMode && !realOutStream)
|
||||||
@@ -1153,13 +1158,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
continue;
|
continue;
|
||||||
RINOK(extractCallback->PrepareOperation(askMode));
|
RINOK(extractCallback->PrepareOperation(askMode));
|
||||||
Int32 opRes = NExtract::NOperationResult::kOK;
|
Int32 opRes = NExtract::NOperationResult::kOK;
|
||||||
|
|
||||||
if (streamIndex != prevSuccessStreamIndex || realOutStream)
|
if (streamIndex != prevSuccessStreamIndex || realOutStream)
|
||||||
{
|
{
|
||||||
Byte digest[kHashSize];
|
Byte digest[kHashSize];
|
||||||
const CVolume &vol = _volumes[si.PartNumber];
|
const CVolume &vol = _volumes[si.PartNumber];
|
||||||
bool needDigest = !si.IsEmptyHash();
|
bool needDigest = !si.IsEmptyHash();
|
||||||
|
|
||||||
HRESULT res = unpacker.Unpack(vol.Stream, si.Resource, vol.Header, &_db,
|
HRESULT res = unpacker.Unpack(vol.Stream, si.Resource, vol.Header, &_db,
|
||||||
realOutStream, progress, needDigest ? digest : NULL);
|
realOutStream, progress, needDigest ? digest : NULL);
|
||||||
|
|
||||||
if (res == S_OK)
|
if (res == S_OK)
|
||||||
{
|
{
|
||||||
if (!needDigest || memcmp(digest, si.Hash, kHashSize) == 0)
|
if (!needDigest || memcmp(digest, si.Hash, kHashSize) == 0)
|
||||||
@@ -1174,13 +1182,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
else
|
else
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
realOutStream.Release();
|
realOutStream.Release();
|
||||||
RINOK(extractCallback->SetOperationResult(opRes));
|
RINOK(extractCallback->SetOperationResult(opRes));
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
COM_TRY_END
|
COM_TRY_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||||
{
|
{
|
||||||
*numItems = _db.SortedItems.Size() +
|
*numItems = _db.SortedItems.Size() +
|
||||||
|
|||||||
@@ -255,7 +255,12 @@ HRESULT CUnpacker::Unpack2(
|
|||||||
|
|
||||||
_solidIndex = resource.SolidIndex;
|
_solidIndex = resource.SolidIndex;
|
||||||
_unpackedChunkIndex = chunkIndex;
|
_unpackedChunkIndex = chunkIndex;
|
||||||
|
|
||||||
|
if (cur < offsetInChunk)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
cur -= offsetInChunk;
|
||||||
|
|
||||||
if (cur > rem)
|
if (cur > rem)
|
||||||
cur = (size_t)rem;
|
cur = (size_t)rem;
|
||||||
|
|
||||||
|
|||||||
@@ -188,9 +188,9 @@ API_FUNC_IsArc IsArc_Zip(const Byte *p, size_t size)
|
|||||||
// Crc = Get32(p + 10);
|
// Crc = Get32(p + 10);
|
||||||
// PackSize = Get32(p + 14);
|
// PackSize = Get32(p + 14);
|
||||||
// Size = Get32(p + 18);
|
// Size = Get32(p + 18);
|
||||||
unsigned nameSize = Get16(p + 22);
|
const unsigned nameSize = Get16(p + 22);
|
||||||
unsigned extraSize = Get16(p + 24);
|
unsigned extraSize = Get16(p + 24);
|
||||||
UInt32 extraOffset = kLocalHeaderSize + (UInt32)nameSize;
|
const UInt32 extraOffset = kLocalHeaderSize + (UInt32)nameSize;
|
||||||
if (extraOffset + extraSize > (1 << 16))
|
if (extraOffset + extraSize > (1 << 16))
|
||||||
return k_IsArc_Res_NO;
|
return k_IsArc_Res_NO;
|
||||||
|
|
||||||
@@ -562,13 +562,21 @@ bool CInArchive::ReadLocalItem(CItemEx &item)
|
|||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckDosTime(item.Time))
|
if (!CheckDosTime(item.Time))
|
||||||
{
|
{
|
||||||
HeadersWarning = true;
|
HeadersWarning = true;
|
||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Name.Len() != nameSize)
|
if (item.Name.Len() != nameSize)
|
||||||
return false;
|
{
|
||||||
|
// we support "bad" archives with null-terminated name.
|
||||||
|
if (item.Name.Len() + 1 != nameSize)
|
||||||
|
return false;
|
||||||
|
HeadersWarning = true;
|
||||||
|
}
|
||||||
|
|
||||||
return item.LocalFullHeaderSize <= ((UInt32)1 << 16);
|
return item.LocalFullHeaderSize <= ((UInt32)1 << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -782,9 +790,9 @@ HRESULT CInArchive::ReadCdItem(CItemEx &item)
|
|||||||
item.Crc = Get32(p + 12);
|
item.Crc = Get32(p + 12);
|
||||||
item.PackSize = Get32(p + 16);
|
item.PackSize = Get32(p + 16);
|
||||||
item.Size = Get32(p + 20);
|
item.Size = Get32(p + 20);
|
||||||
unsigned nameSize = Get16(p + 24);
|
const unsigned nameSize = Get16(p + 24);
|
||||||
UInt16 extraSize = Get16(p + 26);
|
const unsigned extraSize = Get16(p + 26);
|
||||||
UInt16 commentSize = Get16(p + 28);
|
const unsigned commentSize = Get16(p + 28);
|
||||||
UInt32 diskNumberStart = Get16(p + 30);
|
UInt32 diskNumberStart = Get16(p + 30);
|
||||||
item.InternalAttrib = Get16(p + 32);
|
item.InternalAttrib = Get16(p + 32);
|
||||||
item.ExternalAttrib = Get32(p + 34);
|
item.ExternalAttrib = Get32(p + 34);
|
||||||
@@ -961,7 +969,7 @@ HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UI
|
|||||||
CItemEx cdItem;
|
CItemEx cdItem;
|
||||||
RINOK(ReadCdItem(cdItem));
|
RINOK(ReadCdItem(cdItem));
|
||||||
items.Add(cdItem);
|
items.Add(cdItem);
|
||||||
if (progress && items.Size() % 1 == 0)
|
if (progress && (items.Size() & 0xFFF) == 0)
|
||||||
RINOK(progress->SetCompletedCD(items.Size()));
|
RINOK(progress->SetCompletedCD(items.Size()));
|
||||||
}
|
}
|
||||||
return (m_Position - cdOffset == cdSize) ? S_OK : S_FALSE;
|
return (m_Position - cdOffset == cdSize) ? S_OK : S_FALSE;
|
||||||
@@ -1009,6 +1017,7 @@ bool IsStrangeItem(const CItem &item)
|
|||||||
return item.Name.Len() > (1 << 14) || item.Method > (1 << 8);
|
return item.Name.Len() > (1 << 14) || item.Method > (1 << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT CInArchive::ReadLocals(
|
HRESULT CInArchive::ReadLocals(
|
||||||
CObjectVector<CItemEx> &items, CProgressVirt *progress)
|
CObjectVector<CItemEx> &items, CProgressVirt *progress)
|
||||||
{
|
{
|
||||||
@@ -1037,7 +1046,8 @@ HRESULT CInArchive::ReadLocals(
|
|||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
if (progress && items.Size() % 1 == 0)
|
|
||||||
|
if (progress && (items.Size() & 0xFF) == 0)
|
||||||
RINOK(progress->SetCompletedLocal(items.Size(), item.LocalHeaderPos));
|
RINOK(progress->SetCompletedLocal(items.Size(), item.LocalHeaderPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1154,15 +1164,17 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
|||||||
HeadersError = true;
|
HeadersError = true;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
_inBufMode = true;
|
_inBufMode = true;
|
||||||
_inBuffer.Init();
|
_inBuffer.Init();
|
||||||
cdAbsOffset = m_Position - 4;
|
cdAbsOffset = m_Position - 4;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
CItemEx cdItem;
|
CItemEx cdItem;
|
||||||
RINOK(ReadCdItem(cdItem));
|
RINOK(ReadCdItem(cdItem));
|
||||||
cdItems.Add(cdItem);
|
cdItems.Add(cdItem);
|
||||||
if (progress && cdItems.Size() % 1 == 0)
|
if (progress && (cdItems.Size() & 0xFFF) == 0)
|
||||||
RINOK(progress->SetCompletedCD(items.Size()));
|
RINOK(progress->SetCompletedCD(items.Size()));
|
||||||
m_Signature = ReadUInt32();
|
m_Signature = ReadUInt32();
|
||||||
if (m_Signature != NSignature::kCentralFileHeader)
|
if (m_Signature != NSignature::kCentralFileHeader)
|
||||||
@@ -1183,6 +1195,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
|||||||
CEcd64 ecd64;
|
CEcd64 ecd64;
|
||||||
bool isZip64 = false;
|
bool isZip64 = false;
|
||||||
UInt64 ecd64AbsOffset = m_Position - 4;
|
UInt64 ecd64AbsOffset = m_Position - 4;
|
||||||
|
|
||||||
if (m_Signature == NSignature::kEcd64)
|
if (m_Signature == NSignature::kEcd64)
|
||||||
{
|
{
|
||||||
IsZip64 = isZip64 = true;
|
IsZip64 = isZip64 = true;
|
||||||
@@ -1213,6 +1226,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
|||||||
(!items.IsEmpty())))
|
(!items.IsEmpty())))
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Signature == NSignature::kEcd64Locator)
|
if (m_Signature == NSignature::kEcd64Locator)
|
||||||
{
|
{
|
||||||
if (!isZip64)
|
if (!isZip64)
|
||||||
@@ -1224,6 +1238,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
|||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
m_Signature = ReadUInt32();
|
m_Signature = ReadUInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Signature != NSignature::kEcd)
|
if (m_Signature != NSignature::kEcd)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
@@ -1323,6 +1338,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress)
|
HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress)
|
||||||
{
|
{
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
|
|||||||
@@ -723,7 +723,7 @@ static HRESULT Update2(
|
|||||||
|
|
||||||
CThreads threads;
|
CThreads threads;
|
||||||
CRecordVector<HANDLE> compressingCompletedEvents;
|
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)));
|
RINOK(memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize)));
|
||||||
@@ -759,7 +759,7 @@ static HRESULT Update2(
|
|||||||
|
|
||||||
while (itemIndex < updateItems.Size())
|
while (itemIndex < updateItems.Size())
|
||||||
{
|
{
|
||||||
if ((UInt32)threadIndices.Size() < numThreads && mtItemIndex < updateItems.Size())
|
if (threadIndices.Size() < numThreads && mtItemIndex < updateItems.Size())
|
||||||
{
|
{
|
||||||
CUpdateItem &ui = updateItems[mtItemIndex++];
|
CUpdateItem &ui = updateItems[mtItemIndex++];
|
||||||
if (!ui.NewData)
|
if (!ui.NewData)
|
||||||
|
|||||||
@@ -554,14 +554,6 @@ SOURCE=..\..\Common\CreateCoder.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Common\CWrappers.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -1285,14 +1277,6 @@ SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ AR_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\DummyOutStream.obj \
|
$O\DummyOutStream.obj \
|
||||||
$O\FindSignature.obj \
|
$O\FindSignature.obj \
|
||||||
$O\HandlerOut.obj \
|
$O\HandlerOut.obj \
|
||||||
@@ -94,7 +93,6 @@ AR_COMMON_OBJS = \
|
|||||||
$O\7zEncode.obj \
|
$O\7zEncode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderInStream.obj \
|
$O\7zFolderInStream.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zHandlerOut.obj \
|
$O\7zHandlerOut.obj \
|
||||||
$O\7zHeader.obj \
|
$O\7zHeader.obj \
|
||||||
|
|||||||
@@ -546,14 +546,6 @@ SOURCE=..\..\Common\CreateCoder.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Common\CWrappers.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -812,14 +804,6 @@ SOURCE=..\..\Compress\LzmaEncoder.h
|
|||||||
|
|
||||||
SOURCE=..\..\Compress\LzmaRegister.cpp
|
SOURCE=..\..\Compress\LzmaRegister.cpp
|
||||||
# End Source File
|
# 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
|
# End Group
|
||||||
# Begin Group "Archive"
|
# Begin Group "Archive"
|
||||||
|
|
||||||
@@ -865,14 +849,6 @@ SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ AR_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\DummyOutStream.obj \
|
$O\DummyOutStream.obj \
|
||||||
$O\HandlerOut.obj \
|
$O\HandlerOut.obj \
|
||||||
$O\InStreamWithCRC.obj \
|
$O\InStreamWithCRC.obj \
|
||||||
@@ -83,7 +82,6 @@ AR_COMMON_OBJS = \
|
|||||||
$O\7zEncode.obj \
|
$O\7zEncode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderInStream.obj \
|
$O\7zFolderInStream.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zHandlerOut.obj \
|
$O\7zHandlerOut.obj \
|
||||||
$O\7zHeader.obj \
|
$O\7zHeader.obj \
|
||||||
|
|||||||
@@ -211,122 +211,6 @@ SOURCE=..\..\UI\FileManager\Test.bmp
|
|||||||
# Begin Group "Archive"
|
# Begin Group "Archive"
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
# 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"
|
# Begin Group "Archive Common"
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
# PROP Default_Filter ""
|
||||||
@@ -403,6 +287,114 @@ SOURCE=..\..\Archive\Common\ParseProperties.cpp
|
|||||||
SOURCE=..\..\Archive\Common\ParseProperties.h
|
SOURCE=..\..\Archive\Common\ParseProperties.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# End Group
|
# 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
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Archive\IArchive.h
|
SOURCE=..\..\Archive\IArchive.h
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ AR_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\HandlerOut.obj \
|
$O\HandlerOut.obj \
|
||||||
$O\InStreamWithCRC.obj \
|
$O\InStreamWithCRC.obj \
|
||||||
$O\ItemNameUtils.obj \
|
$O\ItemNameUtils.obj \
|
||||||
@@ -63,7 +62,6 @@ AR_COMMON_OBJS = \
|
|||||||
$O\7zEncode.obj \
|
$O\7zEncode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderInStream.obj \
|
$O\7zFolderInStream.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zHandlerOut.obj \
|
$O\7zHandlerOut.obj \
|
||||||
$O\7zHeader.obj \
|
$O\7zHeader.obj \
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ COMMON_OBJS = \
|
|||||||
$O\CRC.obj \
|
$O\CRC.obj \
|
||||||
$O\CrcReg.obj \
|
$O\CrcReg.obj \
|
||||||
$O\IntToString.obj \
|
$O\IntToString.obj \
|
||||||
$O\NewHandler.obj \
|
|
||||||
$O\MyString.obj \
|
$O\MyString.obj \
|
||||||
|
$O\MyVector.obj \
|
||||||
|
$O\NewHandler.obj \
|
||||||
$O\Sha256Reg.obj \
|
$O\Sha256Reg.obj \
|
||||||
$O\StringConvert.obj \
|
$O\StringConvert.obj \
|
||||||
$O\StringToInt.obj \
|
$O\StringToInt.obj \
|
||||||
$O\MyVector.obj \
|
|
||||||
$O\Wildcard.obj \
|
$O\Wildcard.obj \
|
||||||
|
|
||||||
WIN_OBJS = \
|
WIN_OBJS = \
|
||||||
@@ -42,7 +42,6 @@ AR_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\ItemNameUtils.obj \
|
$O\ItemNameUtils.obj \
|
||||||
$O\OutStreamWithCRC.obj \
|
$O\OutStreamWithCRC.obj \
|
||||||
$O\ParseProperties.obj \
|
$O\ParseProperties.obj \
|
||||||
@@ -51,7 +50,6 @@ AR_COMMON_OBJS = \
|
|||||||
$O\7zCompressionMode.obj \
|
$O\7zCompressionMode.obj \
|
||||||
$O\7zDecode.obj \
|
$O\7zDecode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zHeader.obj \
|
$O\7zHeader.obj \
|
||||||
$O\7zIn.obj \
|
$O\7zIn.obj \
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ AR_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\HandlerOut.obj \
|
$O\HandlerOut.obj \
|
||||||
$O\ItemNameUtils.obj \
|
$O\ItemNameUtils.obj \
|
||||||
$O\OutStreamWithCRC.obj \
|
$O\OutStreamWithCRC.obj \
|
||||||
@@ -53,7 +52,6 @@ AR_COMMON_OBJS = \
|
|||||||
$O\7zCompressionMode.obj \
|
$O\7zCompressionMode.obj \
|
||||||
$O\7zDecode.obj \
|
$O\7zDecode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zHeader.obj \
|
$O\7zHeader.obj \
|
||||||
$O\7zIn.obj \
|
$O\7zIn.obj \
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ AR_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\DummyOutStream.obj \
|
$O\DummyOutStream.obj \
|
||||||
$O\FindSignature.obj \
|
$O\FindSignature.obj \
|
||||||
$O\InStreamWithCRC.obj \
|
$O\InStreamWithCRC.obj \
|
||||||
@@ -111,7 +110,6 @@ AR_COMMON_OBJS = \
|
|||||||
$O\7zEncode.obj \
|
$O\7zEncode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderInStream.obj \
|
$O\7zFolderInStream.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zHandlerOut.obj \
|
$O\7zHandlerOut.obj \
|
||||||
$O\7zHeader.obj \
|
$O\7zHeader.obj \
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ AR_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\HandlerOut.obj \
|
$O\HandlerOut.obj \
|
||||||
$O\InStreamWithCRC.obj \
|
$O\InStreamWithCRC.obj \
|
||||||
$O\ItemNameUtils.obj \
|
$O\ItemNameUtils.obj \
|
||||||
@@ -61,7 +60,6 @@ AR_COMMON_OBJS = \
|
|||||||
$O\7zEncode.obj \
|
$O\7zEncode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderInStream.obj \
|
$O\7zFolderInStream.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zHandlerOut.obj \
|
$O\7zHandlerOut.obj \
|
||||||
$O\7zHeader.obj \
|
$O\7zHeader.obj \
|
||||||
|
|||||||
@@ -513,10 +513,11 @@ static int main2(int numArgs, const char *args[])
|
|||||||
if (parser[NKey::kEOS].ThereIs || stdInMode)
|
if (parser[NKey::kEOS].ThereIs || stdInMode)
|
||||||
throw "Can not use stdin in this mode";
|
throw "Can not use stdin in this mode";
|
||||||
|
|
||||||
if (fileSize > 0xF0000000)
|
|
||||||
throw "File is too big";
|
|
||||||
|
|
||||||
size_t inSize = (size_t)fileSize;
|
size_t inSize = (size_t)fileSize;
|
||||||
|
|
||||||
|
if (inSize != fileSize)
|
||||||
|
throw "File is too big";
|
||||||
|
|
||||||
Byte *inBuffer = NULL;
|
Byte *inBuffer = NULL;
|
||||||
|
|
||||||
if (inSize != 0)
|
if (inSize != 0)
|
||||||
@@ -535,7 +536,13 @@ static int main2(int numArgs, const char *args[])
|
|||||||
if (encodeMode)
|
if (encodeMode)
|
||||||
{
|
{
|
||||||
// we allocate 105% of original size for output buffer
|
// 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)
|
if (outSize != 0)
|
||||||
{
|
{
|
||||||
outBuffer = (Byte *)MyAlloc((size_t)outSize);
|
outBuffer = (Byte *)MyAlloc((size_t)outSize);
|
||||||
@@ -561,7 +568,7 @@ static int main2(int numArgs, const char *args[])
|
|||||||
|
|
||||||
outSize = (size_t)outSize64;
|
outSize = (size_t)outSize64;
|
||||||
if (outSize != outSize64)
|
if (outSize != outSize64)
|
||||||
throw "too big";
|
throw "Unpack size is too big";
|
||||||
if (outSize != 0)
|
if (outSize != 0)
|
||||||
{
|
{
|
||||||
outBuffer = (Byte *)MyAlloc(outSize);
|
outBuffer = (Byte *)MyAlloc(outSize);
|
||||||
|
|||||||
@@ -366,6 +366,10 @@ SOURCE=..\..\..\..\C\7zCrcOpt.c
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\..\C\7zTypes.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\Alloc.c
|
SOURCE=..\..\..\..\C\Alloc.c
|
||||||
# SUBTRACT CPP /YX /Yc /Yu
|
# SUBTRACT CPP /YX /Yc /Yu
|
||||||
# End Source File
|
# End Source File
|
||||||
@@ -464,10 +468,6 @@ SOURCE=..\..\..\..\C\Threads.c
|
|||||||
|
|
||||||
SOURCE=..\..\..\..\C\Threads.h
|
SOURCE=..\..\..\..\C\Threads.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\Types.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
# End Group
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ FILE_IO =FileIO
|
|||||||
FILE_IO_2 =Windows/$(FILE_IO)
|
FILE_IO_2 =Windows/$(FILE_IO)
|
||||||
|
|
||||||
MT_FILES = \
|
MT_FILES = \
|
||||||
System.o \
|
|
||||||
LzFindMt.o \
|
LzFindMt.o \
|
||||||
Threads.o \
|
Threads.o \
|
||||||
|
|
||||||
@@ -60,6 +59,7 @@ OBJS = \
|
|||||||
StringConvert.o \
|
StringConvert.o \
|
||||||
StringToInt.o \
|
StringToInt.o \
|
||||||
PropVariant.o \
|
PropVariant.o \
|
||||||
|
System.o \
|
||||||
7zCrc.o \
|
7zCrc.o \
|
||||||
7zCrcOpt.o \
|
7zCrcOpt.o \
|
||||||
Alloc.o \
|
Alloc.o \
|
||||||
@@ -150,10 +150,8 @@ StringToInt.o: ../../../Common/StringToInt.cpp
|
|||||||
PropVariant.o: ../../../Windows/PropVariant.cpp
|
PropVariant.o: ../../../Windows/PropVariant.cpp
|
||||||
$(CXX) $(CFLAGS) ../../../Windows/PropVariant.cpp
|
$(CXX) $(CFLAGS) ../../../Windows/PropVariant.cpp
|
||||||
|
|
||||||
ifdef MT_FILES
|
|
||||||
System.o: ../../../Windows/System.cpp
|
System.o: ../../../Windows/System.cpp
|
||||||
$(CXX) $(CFLAGS) ../../../Windows/System.cpp
|
$(CXX) $(CFLAGS) ../../../Windows/System.cpp
|
||||||
endif
|
|
||||||
|
|
||||||
7zCrc.o: ../../../../C/7zCrc.c
|
7zCrc.o: ../../../../C/7zCrc.c
|
||||||
$(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
|
$(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
|
||||||
@@ -195,4 +193,3 @@ Lzma86Enc.o: ../../../../C/Lzma86Enc.c
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
-$(RM) $(PROG) $(OBJS)
|
-$(RM) $(PROG) $(OBJS)
|
||||||
|
|
||||||
|
|||||||
@@ -117,14 +117,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -221,14 +213,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ AR_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\ItemNameUtils.obj \
|
$O\ItemNameUtils.obj \
|
||||||
$O\MultiStream.obj \
|
$O\MultiStream.obj \
|
||||||
$O\OutStreamWithCRC.obj \
|
$O\OutStreamWithCRC.obj \
|
||||||
@@ -81,7 +80,6 @@ AR_COMMON_OBJS = \
|
|||||||
7Z_OBJS = \
|
7Z_OBJS = \
|
||||||
$O\7zDecode.obj \
|
$O\7zDecode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zIn.obj \
|
$O\7zIn.obj \
|
||||||
$O\7zRegister.obj \
|
$O\7zRegister.obj \
|
||||||
|
|||||||
@@ -157,14 +157,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -205,14 +197,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -67,14 +67,12 @@ FM_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\ItemNameUtils.obj \
|
$O\ItemNameUtils.obj \
|
||||||
$O\OutStreamWithCRC.obj \
|
$O\OutStreamWithCRC.obj \
|
||||||
|
|
||||||
7Z_OBJS = \
|
7Z_OBJS = \
|
||||||
$O\7zDecode.obj \
|
$O\7zDecode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zIn.obj \
|
$O\7zIn.obj \
|
||||||
$O\7zRegister.obj \
|
$O\7zRegister.obj \
|
||||||
|
|||||||
@@ -149,14 +149,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -197,14 +189,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ AR_OBJS = \
|
|||||||
|
|
||||||
AR_COMMON_OBJS = \
|
AR_COMMON_OBJS = \
|
||||||
$O\CoderMixer2.obj \
|
$O\CoderMixer2.obj \
|
||||||
$O\CrossThreadProgress.obj \
|
|
||||||
$O\ItemNameUtils.obj \
|
$O\ItemNameUtils.obj \
|
||||||
$O\MultiStream.obj \
|
$O\MultiStream.obj \
|
||||||
$O\OutStreamWithCRC.obj \
|
$O\OutStreamWithCRC.obj \
|
||||||
@@ -100,7 +99,6 @@ AR_COMMON_OBJS = \
|
|||||||
7Z_OBJS = \
|
7Z_OBJS = \
|
||||||
$O\7zDecode.obj \
|
$O\7zDecode.obj \
|
||||||
$O\7zExtract.obj \
|
$O\7zExtract.obj \
|
||||||
$O\7zFolderOutStream.obj \
|
|
||||||
$O\7zHandler.obj \
|
$O\7zHandler.obj \
|
||||||
$O\7zIn.obj \
|
$O\7zIn.obj \
|
||||||
$O\7zRegister.obj \
|
$O\7zRegister.obj \
|
||||||
|
|||||||
@@ -86,26 +86,34 @@ STDMETHODIMP CClusterInStream::Read(void *data, UInt32 size, UInt32 *processedSi
|
|||||||
*processedSize = 0;
|
*processedSize = 0;
|
||||||
if (_virtPos >= Size)
|
if (_virtPos >= Size)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
{
|
||||||
|
UInt64 rem = Size - _virtPos;
|
||||||
|
if (size > rem)
|
||||||
|
size = (UInt32)rem;
|
||||||
|
}
|
||||||
|
if (size == 0)
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
if (_curRem == 0)
|
if (_curRem == 0)
|
||||||
{
|
{
|
||||||
UInt32 blockSize = (UInt32)1 << BlockSizeLog;
|
const UInt32 blockSize = (UInt32)1 << BlockSizeLog;
|
||||||
UInt32 virtBlock = (UInt32)(_virtPos >> BlockSizeLog);
|
const UInt32 virtBlock = (UInt32)(_virtPos >> BlockSizeLog);
|
||||||
UInt32 offsetInBlock = (UInt32)_virtPos & (blockSize - 1);
|
const UInt32 offsetInBlock = (UInt32)_virtPos & (blockSize - 1);
|
||||||
UInt32 phyBlock = Vector[virtBlock];
|
const UInt32 phyBlock = Vector[virtBlock];
|
||||||
|
|
||||||
UInt64 newPos = StartOffset + ((UInt64)phyBlock << BlockSizeLog) + offsetInBlock;
|
UInt64 newPos = StartOffset + ((UInt64)phyBlock << BlockSizeLog) + offsetInBlock;
|
||||||
if (newPos != _physPos)
|
if (newPos != _physPos)
|
||||||
{
|
{
|
||||||
_physPos = newPos;
|
_physPos = newPos;
|
||||||
RINOK(SeekToPhys());
|
RINOK(SeekToPhys());
|
||||||
}
|
}
|
||||||
|
|
||||||
_curRem = blockSize - offsetInBlock;
|
_curRem = blockSize - offsetInBlock;
|
||||||
|
|
||||||
for (int i = 1; i < 64 && (virtBlock + i) < (UInt32)Vector.Size() && phyBlock + i == Vector[virtBlock + i]; i++)
|
for (int i = 1; i < 64 && (virtBlock + i) < (UInt32)Vector.Size() && phyBlock + i == Vector[virtBlock + i]; i++)
|
||||||
_curRem += (UInt32)1 << BlockSizeLog;
|
_curRem += (UInt32)1 << BlockSizeLog;
|
||||||
UInt64 rem = Size - _virtPos;
|
|
||||||
if (_curRem > rem)
|
|
||||||
_curRem = (UInt32)rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > _curRem)
|
if (size > _curRem)
|
||||||
size = _curRem;
|
size = _curRem;
|
||||||
HRESULT res = Stream->Read(data, size, &size);
|
HRESULT res = Stream->Read(data, size, &size);
|
||||||
|
|||||||
@@ -73,11 +73,11 @@ class CClusterInStream:
|
|||||||
UInt64 _physPos;
|
UInt64 _physPos;
|
||||||
UInt32 _curRem;
|
UInt32 _curRem;
|
||||||
public:
|
public:
|
||||||
CMyComPtr<IInStream> Stream;
|
|
||||||
UInt64 StartOffset;
|
|
||||||
UInt64 Size;
|
|
||||||
unsigned BlockSizeLog;
|
unsigned BlockSizeLog;
|
||||||
|
UInt64 Size;
|
||||||
|
CMyComPtr<IInStream> Stream;
|
||||||
CRecordVector<UInt32> Vector;
|
CRecordVector<UInt32> Vector;
|
||||||
|
UInt64 StartOffset;
|
||||||
|
|
||||||
HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
|
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);
|
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;
|
const wchar_t *end;
|
||||||
UInt32 number = ConvertStringToUInt32(s, &end);
|
UInt32 number = ConvertStringToUInt32(s, &end);
|
||||||
unsigned numDigits = (unsigned)(end - s);
|
unsigned numDigits = (unsigned)(end - s);
|
||||||
if (numDigits == 0 || s.Len() > numDigits + 1)
|
if (numDigits == 0 || s.Len() > numDigits + 1)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
const unsigned kLogDictSizeLimit = 32;
|
|
||||||
if (s.Len() == numDigits)
|
if (s.Len() == numDigits)
|
||||||
{
|
{
|
||||||
if (number >= kLogDictSizeLimit)
|
if (number >= 64)
|
||||||
return E_INVALIDARG;
|
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;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned numBits;
|
unsigned numBits;
|
||||||
|
|
||||||
switch (MyCharLower_Ascii(s[numDigits]))
|
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 'k': numBits = 10; break;
|
||||||
case 'm': numBits = 20; break;
|
case 'm': numBits = 20; break;
|
||||||
case 'g': numBits = 30; break;
|
case 'g': numBits = 30; break;
|
||||||
default: return E_INVALIDARG;
|
default: return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
if (number >= ((UInt32)1 << (kLogDictSizeLimit - numBits)))
|
|
||||||
return E_INVALIDARG;
|
if (number < ((UInt32)1 << (32 - numBits)))
|
||||||
dicSize = number << numBits;
|
destProp = (UInt32)(number << numBits);
|
||||||
|
else
|
||||||
|
destProp = (UInt64)((UInt64)number << numBits);
|
||||||
|
|
||||||
return S_OK;
|
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)
|
if (prop.vt == VT_UI4)
|
||||||
{
|
{
|
||||||
UInt32 v = prop.ulVal;
|
UInt32 v = prop.ulVal;
|
||||||
if (v >= 32)
|
if (v >= 64)
|
||||||
return E_INVALIDARG;
|
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;
|
return S_OK;
|
||||||
}
|
}
|
||||||
if (prop.vt == VT_BSTR)
|
if (prop.vt == VT_BSTR)
|
||||||
return StringToDictSize(prop.bstrVal, resValue);
|
return StringToDictSize(prop.bstrVal, destProp);
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CProps::AddProp32(PROPID propid, UInt32 level)
|
void CProps::AddProp32(PROPID propid, UInt32 level)
|
||||||
{
|
{
|
||||||
CProp &prop = Props.AddNew();
|
CProp &prop = Props.AddNew();
|
||||||
@@ -275,10 +289,10 @@ static void SplitParams(const UString &srcString, UStringVector &subStrings)
|
|||||||
{
|
{
|
||||||
subStrings.Clear();
|
subStrings.Clear();
|
||||||
UString s;
|
UString s;
|
||||||
int len = srcString.Len();
|
unsigned len = srcString.Len();
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return;
|
return;
|
||||||
for (int i = 0; i < len; i++)
|
for (unsigned i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
wchar_t c = srcString[i];
|
wchar_t c = srcString[i];
|
||||||
if (c == L':')
|
if (c == L':')
|
||||||
@@ -336,9 +350,7 @@ HRESULT CMethodProps::SetParam(const UString &name, const UString &value)
|
|||||||
|
|
||||||
if (IsLogSizeProp(prop.Id))
|
if (IsLogSizeProp(prop.Id))
|
||||||
{
|
{
|
||||||
UInt32 dicSize;
|
RINOK(StringToDictSize(value, prop.Value));
|
||||||
RINOK(StringToDictSize(value, dicSize));
|
|
||||||
prop.Value = dicSize;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -406,9 +418,7 @@ HRESULT CMethodProps::ParseParamsFromPROPVARIANT(const UString &realName, const
|
|||||||
|
|
||||||
if (IsLogSizeProp(prop.Id))
|
if (IsLogSizeProp(prop.Id))
|
||||||
{
|
{
|
||||||
UInt32 dicSize;
|
RINOK(PROPVARIANT_to_DictSize(value, prop.Value));
|
||||||
RINOK(PROPVARIANT_to_DictSize(value, dicSize));
|
|
||||||
prop.Value = dicSize;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,20 @@ HRESULT SetLzma2Prop(PROPID propID, const PROPVARIANT &prop, CLzma2EncProps &lzm
|
|||||||
switch (propID)
|
switch (propID)
|
||||||
{
|
{
|
||||||
case NCoderPropID::kBlockSize:
|
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:
|
case NCoderPropID::kNumThreads:
|
||||||
if (prop.vt != VT_UI4) return E_INVALIDARG; lzma2Props.numTotalThreads = (int)(prop.ulVal); break;
|
if (prop.vt != VT_UI4) return E_INVALIDARG; lzma2Props.numTotalThreads = (int)(prop.ulVal); break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -9,4 +9,4 @@
|
|||||||
REGISTER_FILTER_E(7zAES,
|
REGISTER_FILTER_E(7zAES,
|
||||||
NCrypto::N7z::CDecoder(),
|
NCrypto::N7z::CDecoder(),
|
||||||
NCrypto::N7z::CEncoder(),
|
NCrypto::N7z::CEncoder(),
|
||||||
0x6F10701, "7zAES")
|
0x6F10701, "7zAES")
|
||||||
|
|||||||
@@ -9,4 +9,4 @@
|
|||||||
REGISTER_FILTER_E(AES256CBC,
|
REGISTER_FILTER_E(AES256CBC,
|
||||||
NCrypto::CAesCbcDecoder(32),
|
NCrypto::CAesCbcDecoder(32),
|
||||||
NCrypto::CAesCbcEncoder(32),
|
NCrypto::CAesCbcEncoder(32),
|
||||||
0x6F00181, "AES256CBC")
|
0x6F00181, "AES256CBC")
|
||||||
|
|||||||
@@ -73,8 +73,10 @@ void CRandomGenerator::Init()
|
|||||||
HASH_UPD(v2);
|
HASH_UPD(v2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
DWORD tickCount = ::GetTickCount();
|
DWORD tickCount = ::GetTickCount();
|
||||||
HASH_UPD(tickCount);
|
HASH_UPD(tickCount);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (unsigned j = 0; j < 100; j++)
|
for (unsigned j = 0; j < 100; j++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -248,7 +248,8 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
|
|||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
bool isPtrName = false;
|
bool isPtrName = false;
|
||||||
|
|
||||||
#ifdef MY_CPU_LE
|
#if defined(MY_CPU_LE) && defined(_WIN32)
|
||||||
|
// it works only if (sizeof(wchar_t) == 2)
|
||||||
if (arc.GetRawProps)
|
if (arc.GetRawProps)
|
||||||
{
|
{
|
||||||
const void *p;
|
const void *p;
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_outFileStream != NULL)
|
if (_outFileStream)
|
||||||
{
|
{
|
||||||
if (_processedFileInfo.MTimeDefined)
|
if (_processedFileInfo.MTimeDefined)
|
||||||
_outFileStreamSpec->SetMTime(&_processedFileInfo.MTime);
|
_outFileStreamSpec->SetMTime(&_processedFileInfo.MTime);
|
||||||
@@ -499,7 +499,6 @@ public:
|
|||||||
STDMETHOD(SetCompleted)(const UInt64 *completeValue);
|
STDMETHOD(SetCompleted)(const UInt64 *completeValue);
|
||||||
|
|
||||||
// IUpdateCallback2
|
// IUpdateCallback2
|
||||||
STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator);
|
|
||||||
STDMETHOD(GetUpdateItemInfo)(UInt32 index,
|
STDMETHOD(GetUpdateItemInfo)(UInt32 index,
|
||||||
Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive);
|
Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive);
|
||||||
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||||
@@ -551,20 +550,14 @@ STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const UInt64 * /* completeValu
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG ** /* enumerator */)
|
|
||||||
{
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
|
STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
|
||||||
Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive)
|
Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive)
|
||||||
{
|
{
|
||||||
if (newData != NULL)
|
if (newData)
|
||||||
*newData = BoolToInt(true);
|
*newData = BoolToInt(true);
|
||||||
if (newProperties != NULL)
|
if (newProperties)
|
||||||
*newProperties = BoolToInt(true);
|
*newProperties = BoolToInt(true);
|
||||||
if (indexInArchive != NULL)
|
if (indexInArchive)
|
||||||
*indexInArchive = (UInt32)(Int32)-1;
|
*indexInArchive = (UInt32)(Int32)-1;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@@ -700,7 +693,7 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef
|
|||||||
return StringToBstr(Password, password);
|
return StringToBstr(Password, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Main function
|
// Main function
|
||||||
|
|
||||||
#define NT_CHECK_FAIL_ACTION PrintError("Unsupported Windows version"); return 1;
|
#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);
|
PrintStringLn(kHelpString);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
NDLL::CLibrary lib;
|
NDLL::CLibrary lib;
|
||||||
if (!lib.Load(NDLL::GetModuleDirPrefix() + FTEXT(kDllName)))
|
if (!lib.Load(NDLL::GetModuleDirPrefix() + FTEXT(kDllName)))
|
||||||
{
|
{
|
||||||
PrintError("Can not load 7-zip library");
|
PrintError("Can not load 7-zip library");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Func_CreateObject createObjectFunc = (Func_CreateObject)lib.GetProc("CreateObject");
|
Func_CreateObject createObjectFunc = (Func_CreateObject)lib.GetProc("CreateObject");
|
||||||
if (!createObjectFunc)
|
if (!createObjectFunc)
|
||||||
{
|
{
|
||||||
@@ -739,7 +734,9 @@ int MY_CDECL main(int numArgs, const char *args[])
|
|||||||
}
|
}
|
||||||
c = (char)MyCharLower_Ascii(command[0]);
|
c = (char)MyCharLower_Ascii(command[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
FString archiveName = CmdStringToFString(args[2]);
|
FString archiveName = CmdStringToFString(args[2]);
|
||||||
|
|
||||||
if (c == 'a')
|
if (c == 'a')
|
||||||
{
|
{
|
||||||
// create archive command
|
// create archive command
|
||||||
@@ -773,6 +770,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
|||||||
dirItems.Add(di);
|
dirItems.Add(di);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
COutFileStream *outFileStreamSpec = new COutFileStream;
|
COutFileStream *outFileStreamSpec = new COutFileStream;
|
||||||
CMyComPtr<IOutStream> outFileStream = outFileStreamSpec;
|
CMyComPtr<IOutStream> outFileStream = outFileStreamSpec;
|
||||||
if (!outFileStreamSpec->Create(archiveName, false))
|
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);
|
HRESULT result = outArchive->UpdateItems(outFileStream, dirItems.Size(), updateCallback);
|
||||||
|
|
||||||
updateCallbackSpec->Finilize();
|
updateCallbackSpec->Finilize();
|
||||||
|
|
||||||
if (result != S_OK)
|
if (result != S_OK)
|
||||||
{
|
{
|
||||||
PrintError("Update Error");
|
PrintError("Update Error");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_VECTOR (i, updateCallbackSpec->FailedFiles)
|
FOR_VECTOR (i, updateCallbackSpec->FailedFiles)
|
||||||
{
|
{
|
||||||
PrintNewLine();
|
PrintNewLine();
|
||||||
PrintError("Error for file", updateCallbackSpec->FailedFiles[i]);
|
PrintError("Error for file", updateCallbackSpec->FailedFiles[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateCallbackSpec->FailedFiles.Size() != 0)
|
if (updateCallbackSpec->FailedFiles.Size() != 0)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -842,6 +844,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool listCommand;
|
bool listCommand;
|
||||||
|
|
||||||
if (c == 'l')
|
if (c == 'l')
|
||||||
listCommand = true;
|
listCommand = true;
|
||||||
else if (c == 'x')
|
else if (c == 'x')
|
||||||
@@ -920,7 +923,27 @@ int MY_CDECL main(int numArgs, const char *args[])
|
|||||||
extractCallbackSpec->PasswordIsDefined = false;
|
extractCallbackSpec->PasswordIsDefined = false;
|
||||||
// extractCallbackSpec->PasswordIsDefined = true;
|
// extractCallbackSpec->PasswordIsDefined = true;
|
||||||
// extractCallbackSpec->Password = L"1";
|
// 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);
|
HRESULT result = archive->Extract(NULL, (UInt32)(Int32)(-1), false, extractCallback);
|
||||||
|
|
||||||
if (result != S_OK)
|
if (result != S_OK)
|
||||||
{
|
{
|
||||||
PrintError("Extract Error");
|
PrintError("Extract Error");
|
||||||
@@ -928,5 +951,6 @@ int MY_CDECL main(int numArgs, const char *args[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ static const unsigned kCommandIndex = 0;
|
|||||||
static const char *kCannotFindListFile = "Cannot find listfile";
|
static const char *kCannotFindListFile = "Cannot find listfile";
|
||||||
static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
|
static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
|
||||||
static const char *kTerminalOutError = "I won't write compressed data to a terminal";
|
static const char *kTerminalOutError = "I won't write compressed data to a terminal";
|
||||||
static const char *kSameTerminalError = "I won't write data and program's messages to same terminal";
|
static const char *kSameTerminalError = "I won't write data and program's messages to same stream";
|
||||||
static const char *kEmptyFilePath = "Empty file path";
|
static const char *kEmptyFilePath = "Empty file path";
|
||||||
static const char *kCannotFindArchive = "Cannot find archive";
|
static const char *kCannotFindArchive = "Cannot find archive";
|
||||||
|
|
||||||
@@ -1219,8 +1219,26 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
|
|||||||
|
|
||||||
if (isExtractGroupCommand)
|
if (isExtractGroupCommand)
|
||||||
{
|
{
|
||||||
if (options.StdOutMode && options.IsStdOutTerminal && options.IsStdErrTerminal)
|
if (options.StdOutMode)
|
||||||
throw CArcCmdLineException(kSameTerminalError);
|
{
|
||||||
|
if (
|
||||||
|
options.Number_for_Percents == k_OutStream_stdout
|
||||||
|
// || options.Number_for_Out == k_OutStream_stdout
|
||||||
|
// || options.Number_for_Errors == k_OutStream_stdout
|
||||||
|
||
|
||||||
|
(
|
||||||
|
(options.IsStdOutTerminal && options.IsStdErrTerminal)
|
||||||
|
&&
|
||||||
|
(
|
||||||
|
options.Number_for_Percents != k_OutStream_disabled
|
||||||
|
// || options.Number_for_Out != k_OutStream_disabled
|
||||||
|
// || options.Number_for_Errors != k_OutStream_disabled
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
throw CArcCmdLineException(kSameTerminalError);
|
||||||
|
}
|
||||||
|
|
||||||
if (parser[NKey::kOutputDir].ThereIs)
|
if (parser[NKey::kOutputDir].ThereIs)
|
||||||
{
|
{
|
||||||
eo.OutputDir = us2fs(parser[NKey::kOutputDir].PostStrings[0]);
|
eo.OutputDir = us2fs(parser[NKey::kOutputDir].PostStrings[0]);
|
||||||
@@ -1293,8 +1311,18 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
|
|||||||
|
|
||||||
if (updateOptions.StdOutMode && updateOptions.EMailMode)
|
if (updateOptions.StdOutMode && updateOptions.EMailMode)
|
||||||
throw CArcCmdLineException("stdout mode and email mode cannot be combined");
|
throw CArcCmdLineException("stdout mode and email mode cannot be combined");
|
||||||
if (updateOptions.StdOutMode && options.IsStdOutTerminal)
|
|
||||||
throw CArcCmdLineException(kTerminalOutError);
|
if (updateOptions.StdOutMode)
|
||||||
|
{
|
||||||
|
if (options.IsStdOutTerminal)
|
||||||
|
throw CArcCmdLineException(kTerminalOutError);
|
||||||
|
|
||||||
|
if (options.Number_for_Percents == k_OutStream_stdout
|
||||||
|
|| options.Number_for_Out == k_OutStream_stdout
|
||||||
|
|| options.Number_for_Errors == k_OutStream_stdout)
|
||||||
|
throw CArcCmdLineException(kSameTerminalError);
|
||||||
|
}
|
||||||
|
|
||||||
if (updateOptions.StdInMode)
|
if (updateOptions.StdInMode)
|
||||||
updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();
|
updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();
|
||||||
|
|
||||||
|
|||||||
@@ -451,32 +451,42 @@ static UString GetDirPrefixOf(const UString &src)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsSafePath(const UString &path)
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
bool IsSafePath(const UString &path)
|
||||||
{
|
{
|
||||||
|
if (NName::IsAbsolutePath(path))
|
||||||
|
return false;
|
||||||
|
|
||||||
UStringVector parts;
|
UStringVector parts;
|
||||||
SplitPathToParts(path, parts);
|
SplitPathToParts(path, parts);
|
||||||
int level = 0;
|
unsigned level = 0;
|
||||||
FOR_VECTOR(i, parts)
|
|
||||||
|
FOR_VECTOR (i, parts)
|
||||||
{
|
{
|
||||||
const UString &s = parts[i];
|
const UString &s = parts[i];
|
||||||
if (s.IsEmpty())
|
if (s.IsEmpty())
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
return false;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (s == L".")
|
if (s == L".")
|
||||||
continue;
|
continue;
|
||||||
if (s == L"..")
|
if (s == L"..")
|
||||||
{
|
{
|
||||||
if (level <= 0)
|
if (level == 0)
|
||||||
return false;
|
return false;
|
||||||
level--;
|
level--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return level > 0;
|
return level > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
bool CensorNode_CheckPath2(const NWildcard::CCensorNode &node, const CReadArcItem &item, bool &include)
|
bool CensorNode_CheckPath2(const NWildcard::CCensorNode &node, const CReadArcItem &item, bool &include)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,18 +73,40 @@ struct CInFileStreamVol: public CInFileStream
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// from ArchiveExtractCallback.cpp
|
||||||
|
bool IsSafePath(const UString &path);
|
||||||
|
|
||||||
STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStream)
|
STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStream)
|
||||||
{
|
{
|
||||||
COM_TRY_BEGIN
|
COM_TRY_BEGIN
|
||||||
*inStream = NULL;
|
*inStream = NULL;
|
||||||
|
|
||||||
if (_subArchiveMode)
|
if (_subArchiveMode)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
if (Callback)
|
if (Callback)
|
||||||
{
|
{
|
||||||
RINOK(Callback->Open_CheckBreak());
|
RINOK(Callback->Open_CheckBreak());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UString name2 = name;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _SFX
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
name2.Replace(L'/', WCHAR_PATH_SEPARATOR);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// if (!allowAbsVolPaths)
|
||||||
|
if (!IsSafePath(name2))
|
||||||
|
return S_FALSE;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
FString fullPath;
|
FString fullPath;
|
||||||
if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name), fullPath))
|
if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name2), fullPath))
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
if (!_fileInfo.Find(fullPath))
|
if (!_fileInfo.Find(fullPath))
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
@@ -93,10 +115,15 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre
|
|||||||
CInFileStreamVol *inFile = new CInFileStreamVol;
|
CInFileStreamVol *inFile = new CInFileStreamVol;
|
||||||
CMyComPtr<IInStream> inStreamTemp = inFile;
|
CMyComPtr<IInStream> inStreamTemp = inFile;
|
||||||
if (!inFile->Open(fullPath))
|
if (!inFile->Open(fullPath))
|
||||||
return ::GetLastError();
|
{
|
||||||
|
DWORD lastError = ::GetLastError();
|
||||||
|
if (lastError == 0)
|
||||||
|
return E_FAIL;
|
||||||
|
return HRESULT_FROM_WIN32(lastError);
|
||||||
|
}
|
||||||
|
|
||||||
FileSizes.Add(_fileInfo.Size);
|
FileSizes.Add(_fileInfo.Size);
|
||||||
FileNames.Add(name);
|
FileNames.Add(name2);
|
||||||
inFile->FileNameIndex = FileNames_WasUsed.Add(true);
|
inFile->FileNameIndex = FileNames_WasUsed.Add(true);
|
||||||
inFile->OpenCallbackImp = this;
|
inFile->OpenCallbackImp = this;
|
||||||
inFile->OpenCallbackRef = this;
|
inFile->OpenCallbackRef = this;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -32,9 +32,9 @@ struct IBenchCallback
|
|||||||
UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
|
UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
|
||||||
UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt64 numIterations);
|
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
|
struct IBenchPrintCallback
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -142,14 +142,16 @@ void ConvertPropertyToShortString(char *dest, const PROPVARIANT &prop, PROPID pr
|
|||||||
case kpidVa:
|
case kpidVa:
|
||||||
{
|
{
|
||||||
UInt64 v = 0;
|
UInt64 v = 0;
|
||||||
if (ConvertPropVariantToUInt64(prop, v))
|
if (prop.vt == VT_UI4)
|
||||||
{
|
v = prop.ulVal;
|
||||||
dest[0] = '0';
|
else if (prop.vt == VT_UI8)
|
||||||
dest[1] = 'x';
|
v = (UInt64)prop.uhVal.QuadPart;
|
||||||
ConvertUInt64ToHex(prop.ulVal, dest + 2);
|
else
|
||||||
return;
|
break;
|
||||||
}
|
dest[0] = '0';
|
||||||
break;
|
dest[1] = 'x';
|
||||||
|
ConvertUInt64ToHex(v, dest + 2);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ static int CompareStrings(const unsigned *p1, const unsigned *p2, void *param)
|
|||||||
|
|
||||||
void SortFileNames(const UStringVector &strings, CUIntVector &indices)
|
void SortFileNames(const UStringVector &strings, CUIntVector &indices)
|
||||||
{
|
{
|
||||||
unsigned numItems = strings.Size();
|
const unsigned numItems = strings.Size();
|
||||||
indices.ClearAndSetSize(numItems);
|
indices.ClearAndSetSize(numItems);
|
||||||
|
if (numItems == 0)
|
||||||
|
return;
|
||||||
unsigned *vals = &indices[0];
|
unsigned *vals = &indices[0];
|
||||||
for (unsigned i = 0; i < numItems; i++)
|
for (unsigned i = 0; i < numItems; i++)
|
||||||
vals[i] = i;
|
vals[i] = i;
|
||||||
|
|||||||
@@ -17,5 +17,3 @@ void CTempFiles::Clear()
|
|||||||
Paths.DeleteBack();
|
Paths.DeleteBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user