mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-17 16:11:52 -06:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5de23c1deb | ||
|
|
e24f7fba53 | ||
|
|
7c8a265a15 |
80
C/7z.h
80
C/7z.h
@@ -1,5 +1,5 @@
|
||||
/* 7z.h -- 7z interface
|
||||
2014-02-08 : Igor Pavlov : Public domain */
|
||||
2015-11-18 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_H
|
||||
#define __7Z_H
|
||||
@@ -48,21 +48,10 @@ typedef struct
|
||||
UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX];
|
||||
CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX];
|
||||
CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX];
|
||||
UInt64 CodersUnpackSizes[SZ_NUM_CODERS_IN_FOLDER_MAX];
|
||||
} CSzFolder;
|
||||
|
||||
/*
|
||||
typedef struct
|
||||
{
|
||||
size_t CodersDataOffset;
|
||||
size_t UnpackSizeDataOffset;
|
||||
// UInt32 StartCoderUnpackSizesIndex;
|
||||
UInt32 StartPackStreamIndex;
|
||||
// UInt32 IndexOfMainOutStream;
|
||||
} CSzFolder2;
|
||||
*/
|
||||
|
||||
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd, CSzData *sdSizes);
|
||||
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -93,46 +82,24 @@ typedef struct
|
||||
UInt32 NumFolders;
|
||||
|
||||
UInt64 *PackPositions; // NumPackStreams + 1
|
||||
CSzBitUi32s FolderCRCs;
|
||||
CSzBitUi32s FolderCRCs; // NumFolders
|
||||
|
||||
size_t *FoCodersOffsets;
|
||||
size_t *FoSizesOffsets;
|
||||
// UInt32 StartCoderUnpackSizesIndex;
|
||||
UInt32 *FoStartPackStreamIndex;
|
||||
size_t *FoCodersOffsets; // NumFolders + 1
|
||||
UInt32 *FoStartPackStreamIndex; // NumFolders + 1
|
||||
UInt32 *FoToCoderUnpackSizes; // NumFolders + 1
|
||||
Byte *FoToMainUnpackSizeIndex; // NumFolders
|
||||
UInt64 *CoderUnpackSizes; // for all coders in all folders
|
||||
|
||||
// CSzFolder2 *Folders; // +1 item for sum values
|
||||
Byte *CodersData;
|
||||
Byte *UnpackSizesData;
|
||||
size_t UnpackSizesDataSize;
|
||||
// UInt64 *CoderUnpackSizes;
|
||||
} CSzAr;
|
||||
|
||||
UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex);
|
||||
|
||||
SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
|
||||
ILookInStream *stream, UInt64 startPos,
|
||||
Byte *outBuffer, size_t outSize,
|
||||
ISzAlloc *allocMain);
|
||||
|
||||
/*
|
||||
SzExtract extracts file from archive
|
||||
|
||||
*outBuffer must be 0 before first call for each new archive.
|
||||
|
||||
Extracting cache:
|
||||
If you need to decompress more than one file, you can send
|
||||
these values from previous call:
|
||||
*blockIndex,
|
||||
*outBuffer,
|
||||
*outBufferSize
|
||||
You can consider "*outBuffer" as cache of solid block. If your archive is solid,
|
||||
it will increase decompression speed.
|
||||
|
||||
If you use external function, you can declare these 3 cache variables
|
||||
(blockIndex, outBuffer, outBufferSize) as static in that external function.
|
||||
|
||||
Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CSzAr db;
|
||||
@@ -142,7 +109,7 @@ typedef struct
|
||||
|
||||
UInt32 NumFiles;
|
||||
|
||||
UInt64 *UnpackPositions;
|
||||
UInt64 *UnpackPositions; // NumFiles + 1
|
||||
// Byte *IsEmptyFiles;
|
||||
Byte *IsDirs;
|
||||
CSzBitUi32s CRCs;
|
||||
@@ -152,9 +119,8 @@ typedef struct
|
||||
CSzBitUi64s MTime;
|
||||
CSzBitUi64s CTime;
|
||||
|
||||
// UInt32 *FolderStartPackStreamIndex;
|
||||
UInt32 *FolderStartFileIndex; // + 1
|
||||
UInt32 *FileIndexToFolderIndexMap;
|
||||
UInt32 *FolderToFile; // NumFolders + 1
|
||||
UInt32 *FileToFolder; // NumFiles
|
||||
|
||||
size_t *FileNameOffsets; /* in 2-byte steps */
|
||||
Byte *FileNames; /* UTF-16-LE */
|
||||
@@ -182,6 +148,28 @@ size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex);
|
||||
UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
SzArEx_Extract extracts file from archive
|
||||
|
||||
*outBuffer must be 0 before first call for each new archive.
|
||||
|
||||
Extracting cache:
|
||||
If you need to decompress more than one file, you can send
|
||||
these values from previous call:
|
||||
*blockIndex,
|
||||
*outBuffer,
|
||||
*outBufferSize
|
||||
You can consider "*outBuffer" as cache of solid block. If your archive is solid,
|
||||
it will increase decompression speed.
|
||||
|
||||
If you use external function, you can declare these 3 cache variables
|
||||
(blockIndex, outBuffer, outBufferSize) as static in that external function.
|
||||
|
||||
Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
|
||||
*/
|
||||
|
||||
SRes SzArEx_Extract(
|
||||
const CSzArEx *db,
|
||||
ILookInStream *inStream,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* 7zAlloc.c -- Allocation functions
|
||||
2015-02-21 : Igor Pavlov : Public domain */
|
||||
2015-11-09 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -26,7 +26,7 @@ void *SzAlloc(void *p, size_t size)
|
||||
if (size == 0)
|
||||
return 0;
|
||||
#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++;
|
||||
#endif
|
||||
return malloc(size);
|
||||
@@ -51,7 +51,7 @@ void *SzAllocTemp(void *p, size_t size)
|
||||
if (size == 0)
|
||||
return 0;
|
||||
#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++;
|
||||
#ifdef _WIN32
|
||||
return HeapAlloc(GetProcessHeap(), 0, size);
|
||||
|
||||
521
C/7zArcIn.c
521
C/7zArcIn.c
@@ -1,5 +1,5 @@
|
||||
/* 7zArcIn.c -- 7z Input functions
|
||||
2015-09-28 : Igor Pavlov : Public domain */
|
||||
2015-11-18 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
#include "CpuArch.h"
|
||||
|
||||
#define MY_ALLOC(T, p, size, alloc) { \
|
||||
if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == 0) return SZ_ERROR_MEM; }
|
||||
if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == NULL) return SZ_ERROR_MEM; }
|
||||
|
||||
#define MY_ALLOC_ZE(T, p, size, alloc) { if ((size) == 0) p = 0; else MY_ALLOC(T, p, size, alloc) }
|
||||
#define MY_ALLOC_ZE(T, p, size, alloc) { if ((size) == 0) p = NULL; else MY_ALLOC(T, p, size, alloc) }
|
||||
|
||||
#define MY_ALLOC_AND_CPY(to, size, from, alloc) \
|
||||
{ MY_ALLOC(Byte, to, size, alloc); memcpy(to, from, size); }
|
||||
|
||||
#define MY_ALLOC_ZE_AND_CPY(to, size, from, alloc) \
|
||||
{ if ((size) == 0) p = 0; else { MY_ALLOC_AND_CPY(to, size, from, alloc) } }
|
||||
{ if ((size) == 0) p = NULL; else { MY_ALLOC_AND_CPY(to, size, from, alloc) } }
|
||||
|
||||
#define k7zMajorVersion 0
|
||||
|
||||
@@ -58,26 +58,14 @@ enum EIdEnum
|
||||
|
||||
const Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
||||
|
||||
|
||||
/*
|
||||
static int SzFolder_FindBondForInStream(const CSzFolder *p, UInt32 inStreamIndex)
|
||||
{
|
||||
UInt32 i;
|
||||
for (i = 0; i < p->NumBonds; i++)
|
||||
if (p->Bonds[i].InIndex == inStreamIndex)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
#define SzBitUi32s_Init(p) { (p)->Defs = 0; (p)->Vals = 0; }
|
||||
#define SzBitUi32s_Init(p) { (p)->Defs = NULL; (p)->Vals = NULL; }
|
||||
|
||||
static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAlloc *alloc)
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
p->Defs = 0;
|
||||
p->Vals = 0;
|
||||
p->Defs = NULL;
|
||||
p->Vals = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -89,49 +77,49 @@ static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAlloc *alloc)
|
||||
|
||||
void SzBitUi32s_Free(CSzBitUi32s *p, ISzAlloc *alloc)
|
||||
{
|
||||
IAlloc_Free(alloc, p->Defs); p->Defs = 0;
|
||||
IAlloc_Free(alloc, p->Vals); p->Vals = 0;
|
||||
IAlloc_Free(alloc, p->Defs); p->Defs = NULL;
|
||||
IAlloc_Free(alloc, p->Vals); p->Vals = NULL;
|
||||
}
|
||||
|
||||
#define SzBitUi64s_Init(p) { (p)->Defs = 0; (p)->Vals = 0; }
|
||||
#define SzBitUi64s_Init(p) { (p)->Defs = NULL; (p)->Vals = NULL; }
|
||||
|
||||
void SzBitUi64s_Free(CSzBitUi64s *p, ISzAlloc *alloc)
|
||||
{
|
||||
IAlloc_Free(alloc, p->Defs); p->Defs = 0;
|
||||
IAlloc_Free(alloc, p->Vals); p->Vals = 0;
|
||||
IAlloc_Free(alloc, p->Defs); p->Defs = NULL;
|
||||
IAlloc_Free(alloc, p->Vals); p->Vals = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void SzAr_Init(CSzAr *p)
|
||||
{
|
||||
p->NumPackStreams = 0;
|
||||
p->NumFolders = 0;
|
||||
p->PackPositions = 0;
|
||||
SzBitUi32s_Init(&p->FolderCRCs);
|
||||
// p->Folders = 0;
|
||||
p->FoCodersOffsets = 0;
|
||||
p->FoSizesOffsets = 0;
|
||||
p->FoStartPackStreamIndex = 0;
|
||||
|
||||
p->CodersData = 0;
|
||||
// p->CoderUnpackSizes = 0;
|
||||
p->UnpackSizesData = 0;
|
||||
p->PackPositions = NULL;
|
||||
SzBitUi32s_Init(&p->FolderCRCs);
|
||||
|
||||
p->FoCodersOffsets = NULL;
|
||||
p->FoStartPackStreamIndex = NULL;
|
||||
p->FoToCoderUnpackSizes = NULL;
|
||||
p->FoToMainUnpackSizeIndex = NULL;
|
||||
p->CoderUnpackSizes = NULL;
|
||||
|
||||
p->CodersData = NULL;
|
||||
}
|
||||
|
||||
static void SzAr_Free(CSzAr *p, ISzAlloc *alloc)
|
||||
{
|
||||
IAlloc_Free(alloc, p->UnpackSizesData);
|
||||
IAlloc_Free(alloc, p->CodersData);
|
||||
// IAlloc_Free(alloc, p->CoderUnpackSizes);
|
||||
|
||||
IAlloc_Free(alloc, p->PackPositions);
|
||||
|
||||
// IAlloc_Free(alloc, p->Folders);
|
||||
IAlloc_Free(alloc, p->FoCodersOffsets);
|
||||
IAlloc_Free(alloc, p->FoSizesOffsets);
|
||||
IAlloc_Free(alloc, p->FoStartPackStreamIndex);
|
||||
|
||||
SzBitUi32s_Free(&p->FolderCRCs, alloc);
|
||||
|
||||
IAlloc_Free(alloc, p->FoCodersOffsets);
|
||||
IAlloc_Free(alloc, p->FoStartPackStreamIndex);
|
||||
IAlloc_Free(alloc, p->FoToCoderUnpackSizes);
|
||||
IAlloc_Free(alloc, p->FoToMainUnpackSizeIndex);
|
||||
IAlloc_Free(alloc, p->CoderUnpackSizes);
|
||||
|
||||
IAlloc_Free(alloc, p->CodersData);
|
||||
|
||||
SzAr_Init(p);
|
||||
}
|
||||
|
||||
@@ -139,18 +127,19 @@ static void SzAr_Free(CSzAr *p, ISzAlloc *alloc)
|
||||
void SzArEx_Init(CSzArEx *p)
|
||||
{
|
||||
SzAr_Init(&p->db);
|
||||
|
||||
p->NumFiles = 0;
|
||||
p->dataPos = 0;
|
||||
// p->Files = 0;
|
||||
p->UnpackPositions = 0;
|
||||
// p->IsEmptyFiles = 0;
|
||||
p->IsDirs = 0;
|
||||
// p->FolderStartPackStreamIndex = 0;
|
||||
// p->PackStreamStartPositions = 0;
|
||||
p->FolderStartFileIndex = 0;
|
||||
p->FileIndexToFolderIndexMap = 0;
|
||||
p->FileNameOffsets = 0;
|
||||
p->FileNames = 0;
|
||||
|
||||
p->UnpackPositions = NULL;
|
||||
p->IsDirs = NULL;
|
||||
|
||||
p->FolderToFile = NULL;
|
||||
p->FileToFolder = NULL;
|
||||
|
||||
p->FileNameOffsets = NULL;
|
||||
p->FileNames = NULL;
|
||||
|
||||
SzBitUi32s_Init(&p->CRCs);
|
||||
SzBitUi32s_Init(&p->Attribs);
|
||||
// SzBitUi32s_Init(&p->Parents);
|
||||
@@ -160,29 +149,27 @@ void SzArEx_Init(CSzArEx *p)
|
||||
|
||||
void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc)
|
||||
{
|
||||
// IAlloc_Free(alloc, p->FolderStartPackStreamIndex);
|
||||
// IAlloc_Free(alloc, p->PackStreamStartPositions);
|
||||
IAlloc_Free(alloc, p->FolderStartFileIndex);
|
||||
IAlloc_Free(alloc, p->FileIndexToFolderIndexMap);
|
||||
IAlloc_Free(alloc, p->UnpackPositions);
|
||||
IAlloc_Free(alloc, p->IsDirs);
|
||||
|
||||
IAlloc_Free(alloc, p->FolderToFile);
|
||||
IAlloc_Free(alloc, p->FileToFolder);
|
||||
|
||||
IAlloc_Free(alloc, p->FileNameOffsets);
|
||||
IAlloc_Free(alloc, p->FileNames);
|
||||
|
||||
SzBitUi64s_Free(&p->CTime, alloc);
|
||||
SzBitUi64s_Free(&p->MTime, alloc);
|
||||
SzBitUi32s_Free(&p->CRCs, alloc);
|
||||
// SzBitUi32s_Free(&p->Parents, alloc);
|
||||
SzBitUi32s_Free(&p->Attribs, alloc);
|
||||
IAlloc_Free(alloc, p->IsDirs);
|
||||
// IAlloc_Free(alloc, p->IsEmptyFiles);
|
||||
IAlloc_Free(alloc, p->UnpackPositions);
|
||||
// IAlloc_Free(alloc, p->Files);
|
||||
// SzBitUi32s_Free(&p->Parents, alloc);
|
||||
SzBitUi64s_Free(&p->MTime, alloc);
|
||||
SzBitUi64s_Free(&p->CTime, alloc);
|
||||
|
||||
SzAr_Free(&p->db, alloc);
|
||||
SzArEx_Init(p);
|
||||
}
|
||||
|
||||
static int TestSignatureCandidate(Byte *testBytes)
|
||||
|
||||
static int TestSignatureCandidate(const Byte *testBytes)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < k7zSignatureSize; i++)
|
||||
@@ -191,16 +178,7 @@ static int TestSignatureCandidate(Byte *testBytes)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define SzData_Clear(p) { (p)->Data = 0; (p)->Size = 0; }
|
||||
|
||||
static SRes SzReadByte(CSzData *sd, Byte *b)
|
||||
{
|
||||
if (sd->Size == 0)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
sd->Size--;
|
||||
*b = *sd->Data++;
|
||||
return SZ_OK;
|
||||
}
|
||||
#define SzData_Clear(p) { (p)->Data = NULL; (p)->Size = 0; }
|
||||
|
||||
#define SZ_READ_BYTE_SD(_sd_, dest) if ((_sd_)->Size == 0) return SZ_ERROR_ARCHIVE; (_sd_)->Size--; dest = *(_sd_)->Data++;
|
||||
#define SZ_READ_BYTE(dest) SZ_READ_BYTE_SD(sd, dest)
|
||||
@@ -249,57 +227,6 @@ static MY_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value)
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
static MY_NO_INLINE const Byte *SzReadNumbers(const Byte *data, const Byte *dataLim, UInt64 *values, UInt32 num)
|
||||
{
|
||||
for (; num != 0; num--)
|
||||
{
|
||||
Byte firstByte;
|
||||
Byte mask;
|
||||
|
||||
unsigned i;
|
||||
UInt32 v;
|
||||
UInt64 value;
|
||||
|
||||
if (data == dataLim)
|
||||
return NULL;
|
||||
firstByte = *data++;
|
||||
|
||||
if ((firstByte & 0x80) == 0)
|
||||
{
|
||||
*values++ = firstByte;
|
||||
continue;
|
||||
}
|
||||
if (data == dataLim)
|
||||
return NULL;
|
||||
v = *data++;
|
||||
if ((firstByte & 0x40) == 0)
|
||||
{
|
||||
*values++ = (((UInt32)firstByte & 0x3F) << 8) | v;
|
||||
continue;
|
||||
}
|
||||
if (data == dataLim)
|
||||
return NULL;
|
||||
value = v | ((UInt32)*data++ << 8);
|
||||
mask = 0x20;
|
||||
for (i = 2; i < 8; i++)
|
||||
{
|
||||
if ((firstByte & mask) == 0)
|
||||
{
|
||||
UInt64 highPart = firstByte & (mask - 1);
|
||||
value |= (highPart << (8 * i));
|
||||
break;
|
||||
}
|
||||
if (data == dataLim)
|
||||
return NULL;
|
||||
value |= ((UInt64)*data++ << (8 * i));
|
||||
mask >>= 1;
|
||||
}
|
||||
*values++ = value;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
*/
|
||||
|
||||
static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value)
|
||||
{
|
||||
@@ -336,7 +263,7 @@ static SRes SkipData(CSzData *sd)
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
static SRes WaitId(CSzData *sd, UInt64 id)
|
||||
static SRes WaitId(CSzData *sd, UInt32 id)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -384,7 +311,7 @@ static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, UInt32 numItems, Byte **v, I
|
||||
Byte *v2;
|
||||
UInt32 numBytes = (numItems + 7) >> 3;
|
||||
*v = NULL;
|
||||
RINOK(SzReadByte(sd, &allAreDefined));
|
||||
SZ_READ_BYTE(allAreDefined);
|
||||
if (numBytes == 0)
|
||||
return SZ_OK;
|
||||
if (allAreDefined == 0)
|
||||
@@ -438,7 +365,7 @@ static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems)
|
||||
{
|
||||
Byte allAreDefined;
|
||||
UInt32 numDefined = numItems;
|
||||
RINOK(SzReadByte(sd, &allAreDefined));
|
||||
SZ_READ_BYTE(allAreDefined);
|
||||
if (!allAreDefined)
|
||||
{
|
||||
size_t numBytes = (numItems + 7) >> 3;
|
||||
@@ -502,7 +429,7 @@ static SRes SzReadSwitch(CSzData *sd)
|
||||
|
||||
#define k_NumCodersStreams_in_Folder_MAX (SZ_NUM_BONDS_IN_FOLDER_MAX + SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX)
|
||||
|
||||
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd, CSzData *sdSizes)
|
||||
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
|
||||
{
|
||||
UInt32 numCoders, i;
|
||||
UInt32 numInStreams = 0;
|
||||
@@ -524,7 +451,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd, CSzData *sdSizes)
|
||||
unsigned idSize, j;
|
||||
UInt64 id;
|
||||
|
||||
RINOK(SzReadByte(sd, &mainByte));
|
||||
SZ_READ_BYTE(mainByte);
|
||||
if ((mainByte & 0xC0) != 0)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
|
||||
@@ -663,16 +590,12 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd, CSzData *sdSizes)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < numCoders; i++)
|
||||
{
|
||||
RINOK(ReadNumber(sdSizes, f->CodersUnpackSizes + i));
|
||||
}
|
||||
|
||||
f->NumCoders = numCoders;
|
||||
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
|
||||
static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num)
|
||||
{
|
||||
CSzData sd;
|
||||
@@ -703,9 +626,11 @@ static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num)
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
|
||||
#define k_Scan_NumCoders_MAX 64
|
||||
#define k_Scan_NumCodersStreams_in_Folder_MAX 64
|
||||
|
||||
|
||||
static SRes ReadUnpackInfo(CSzAr *p,
|
||||
CSzData *sd2,
|
||||
UInt32 numFoldersMax,
|
||||
@@ -739,8 +664,9 @@ static SRes ReadUnpackInfo(CSzAr *p,
|
||||
}
|
||||
|
||||
MY_ALLOC(size_t, p->FoCodersOffsets, (size_t)numFolders + 1, alloc);
|
||||
MY_ALLOC(size_t, p->FoSizesOffsets, (size_t)numFolders + 1, alloc);
|
||||
MY_ALLOC(UInt32, p->FoStartPackStreamIndex, (size_t)numFolders + 1, alloc);
|
||||
MY_ALLOC(UInt32, p->FoToCoderUnpackSizes, (size_t)numFolders + 1, alloc);
|
||||
MY_ALLOC(Byte, p->FoToMainUnpackSizeIndex, (size_t)numFolders, alloc);
|
||||
|
||||
startBufPtr = sd.Data;
|
||||
|
||||
@@ -857,7 +783,8 @@ static SRes ReadUnpackInfo(CSzAr *p,
|
||||
}
|
||||
|
||||
p->FoStartPackStreamIndex[fo] = packStreamIndex;
|
||||
p->FoSizesOffsets[fo] = (numCoders << 8) | indexOfMainStream;
|
||||
p->FoToCoderUnpackSizes[fo] = numCodersOutStreams;
|
||||
p->FoToMainUnpackSizeIndex[fo] = (Byte)indexOfMainStream;
|
||||
numCodersOutStreams += numCoders;
|
||||
if (numCodersOutStreams < numCoders)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
@@ -871,6 +798,8 @@ static SRes ReadUnpackInfo(CSzAr *p,
|
||||
}
|
||||
}
|
||||
|
||||
p->FoToCoderUnpackSizes[fo] = numCodersOutStreams;
|
||||
|
||||
{
|
||||
size_t dataSize = sd.Data - startBufPtr;
|
||||
p->FoStartPackStreamIndex[fo] = packStreamIndex;
|
||||
@@ -887,27 +816,13 @@ static SRes ReadUnpackInfo(CSzAr *p,
|
||||
|
||||
RINOK(WaitId(&sd, k7zIdCodersUnpackSize));
|
||||
|
||||
// MY_ALLOC_ZE(UInt64, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc);
|
||||
MY_ALLOC_ZE(UInt64, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc);
|
||||
{
|
||||
size_t dataSize = sd.Size;
|
||||
/*
|
||||
UInt32 i;
|
||||
for (i = 0; i < numCodersOutStreams; i++)
|
||||
{
|
||||
RINOK(ReadNumber(&sd, p->CoderUnpackSizes + i));
|
||||
}
|
||||
*/
|
||||
RINOK(SkipNumbers(&sd, numCodersOutStreams));
|
||||
dataSize -= sd.Size;
|
||||
MY_ALLOC_ZE_AND_CPY(p->UnpackSizesData, dataSize, sd.Data - dataSize, alloc);
|
||||
p->UnpackSizesDataSize = dataSize;
|
||||
/*
|
||||
const Byte *data = SzReadNumbers(sd.Data, sd.Data + sd.Size, p->CoderUnpackSizes, numCodersOutStreams);
|
||||
if (data == NULL)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
sd.Size = sd.Data + sd.Size - data;
|
||||
sd.Data = data;
|
||||
*/
|
||||
}
|
||||
|
||||
for (;;)
|
||||
@@ -928,6 +843,13 @@ static SRes ReadUnpackInfo(CSzAr *p,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex)
|
||||
{
|
||||
return p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex] + p->FoToMainUnpackSizeIndex[folderIndex]];
|
||||
}
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UInt32 NumTotalSubStreams;
|
||||
@@ -937,12 +859,10 @@ typedef struct
|
||||
CSzData sdCRCs;
|
||||
} CSubStreamInfo;
|
||||
|
||||
#define SzUi32IndexMax (((UInt32)1 << 31) - 2)
|
||||
|
||||
static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
|
||||
{
|
||||
UInt64 type = 0;
|
||||
UInt32 i;
|
||||
UInt32 numSubDigests = 0;
|
||||
UInt32 numFolders = p->NumFolders;
|
||||
UInt32 numUnpackStreams = numFolders;
|
||||
@@ -953,6 +873,7 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
|
||||
RINOK(ReadID(sd, &type));
|
||||
if (type == k7zIdNumUnpackStream)
|
||||
{
|
||||
UInt32 i;
|
||||
ssi->sdNumSubStreams.Data = sd->Data;
|
||||
numUnpackStreams = 0;
|
||||
numSubDigests = 0;
|
||||
@@ -1064,7 +985,6 @@ static SRes SzReadAndDecodePackedStreams(
|
||||
UInt64 dataStartPos;
|
||||
UInt32 fo;
|
||||
CSubStreamInfo ssi;
|
||||
CSzData sdCodersUnpSizes;
|
||||
|
||||
RINOK(SzReadStreamsInfo(p, sd, numFoldersMax, NULL, 0, &dataStartPos, &ssi, allocTemp));
|
||||
|
||||
@@ -1072,51 +992,24 @@ static SRes SzReadAndDecodePackedStreams(
|
||||
if (p->NumFolders == 0)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
|
||||
sdCodersUnpSizes.Data = p->UnpackSizesData;
|
||||
sdCodersUnpSizes.Size = p->UnpackSizesDataSize;
|
||||
|
||||
for (fo = 0; fo < p->NumFolders; fo++)
|
||||
Buf_Init(tempBufs + fo);
|
||||
|
||||
for (fo = 0; fo < p->NumFolders; fo++)
|
||||
{
|
||||
CBuf *tempBuf = tempBufs + fo;
|
||||
// folder = p->Folders;
|
||||
// unpackSize = SzAr_GetFolderUnpackSize(p, 0);
|
||||
UInt32 mix = (UInt32)p->FoSizesOffsets[fo];
|
||||
UInt32 mainIndex = mix & 0xFF;
|
||||
UInt32 numOutStreams = mix >> 8;
|
||||
UInt32 si;
|
||||
UInt64 unpackSize = 0;
|
||||
p->FoSizesOffsets[fo] = sdCodersUnpSizes.Data - p->UnpackSizesData;
|
||||
for (si = 0; si < numOutStreams; si++)
|
||||
{
|
||||
UInt64 curSize;
|
||||
RINOK(ReadNumber(&sdCodersUnpSizes, &curSize));
|
||||
if (si == mainIndex)
|
||||
{
|
||||
unpackSize = curSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (si == numOutStreams)
|
||||
return SZ_ERROR_FAIL;
|
||||
UInt64 unpackSize = SzAr_GetFolderUnpackSize(p, fo);
|
||||
if ((size_t)unpackSize != unpackSize)
|
||||
return SZ_ERROR_MEM;
|
||||
if (!Buf_Create(tempBuf, (size_t)unpackSize, allocTemp))
|
||||
return SZ_ERROR_MEM;
|
||||
}
|
||||
|
||||
p->FoSizesOffsets[fo] = sdCodersUnpSizes.Data - p->UnpackSizesData;
|
||||
|
||||
for (fo = 0; fo < p->NumFolders; fo++)
|
||||
{
|
||||
const CBuf *tempBuf = tempBufs + fo;
|
||||
RINOK(LookInStream_SeekTo(inStream, dataStartPos));
|
||||
RINOK(SzAr_DecodeFolder(p, fo, inStream, dataStartPos, tempBuf->data, tempBuf->size, allocTemp));
|
||||
if (SzBitWithVals_Check(&p->FolderCRCs, fo))
|
||||
if (CrcCalc(tempBuf->data, tempBuf->size) != p->FolderCRCs.Vals[fo])
|
||||
return SZ_ERROR_CRC;
|
||||
}
|
||||
|
||||
return SZ_OK;
|
||||
@@ -1164,7 +1057,7 @@ static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, UInt32 num,
|
||||
|
||||
RINOK(ReadBitVector(sd2, num, &p->Defs, alloc));
|
||||
|
||||
RINOK(SzReadByte(sd2, &external));
|
||||
SZ_READ_BYTE_SD(sd2, external);
|
||||
if (external == 0)
|
||||
sd = *sd2;
|
||||
else
|
||||
@@ -1198,14 +1091,13 @@ static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, UInt32 num,
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
|
||||
#define NUM_ADDITIONAL_STREAMS_MAX 8
|
||||
|
||||
|
||||
static SRes SzReadHeader2(
|
||||
CSzArEx *p, /* allocMain */
|
||||
CSzData *sd,
|
||||
// Byte **emptyStreamVector, /* allocTemp */
|
||||
// Byte **emptyFileVector, /* allocTemp */
|
||||
// Byte **lwtVector, /* allocTemp */
|
||||
ILookInStream *inStream,
|
||||
CBuf *tempBufs, UInt32 *numTempBufs,
|
||||
ISzAlloc *allocMain,
|
||||
@@ -1215,10 +1107,9 @@ static SRes SzReadHeader2(
|
||||
UInt64 type;
|
||||
UInt32 numFiles = 0;
|
||||
UInt32 numEmptyStreams = 0;
|
||||
UInt32 i;
|
||||
CSubStreamInfo ssi;
|
||||
const Byte *emptyStreams = 0;
|
||||
const Byte *emptyFiles = 0;
|
||||
const Byte *emptyStreams = NULL;
|
||||
const Byte *emptyFiles = NULL;
|
||||
|
||||
SzData_Clear(&ssi.sdSizes);
|
||||
SzData_Clear(&ssi.sdCRCs);
|
||||
@@ -1242,22 +1133,19 @@ static SRes SzReadHeader2(
|
||||
RINOK(ReadID(sd, &type));
|
||||
}
|
||||
|
||||
// if (type == k7zIdAdditionalStreamsInfo) return SZ_ERROR_UNSUPPORTED;
|
||||
|
||||
if (type == k7zIdAdditionalStreamsInfo)
|
||||
{
|
||||
CSzAr tempAr;
|
||||
SRes res;
|
||||
UInt32 numTempFolders;
|
||||
|
||||
SzAr_Init(&tempAr);
|
||||
res = SzReadAndDecodePackedStreams(inStream, sd, tempBufs, NUM_ADDITIONAL_STREAMS_MAX,
|
||||
p->startPosAfterHeader, &tempAr, allocTemp);
|
||||
numTempFolders = tempAr.NumFolders;
|
||||
*numTempBufs = tempAr.NumFolders;
|
||||
SzAr_Free(&tempAr, allocTemp);
|
||||
|
||||
if (res != SZ_OK)
|
||||
return res;
|
||||
*numTempBufs = numTempFolders;
|
||||
RINOK(ReadID(sd, &type));
|
||||
}
|
||||
|
||||
@@ -1271,9 +1159,9 @@ static SRes SzReadHeader2(
|
||||
|
||||
if (type == k7zIdEnd)
|
||||
{
|
||||
// *sd2 = sd;
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
if (type != k7zIdFilesInfo)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
|
||||
@@ -1334,6 +1222,7 @@ static SRes SzReadHeader2(
|
||||
{
|
||||
RINOK(RememberBitVector(sd, numFiles, &emptyStreams));
|
||||
numEmptyStreams = CountDefinedBits(emptyStreams, numFiles);
|
||||
emptyFiles = NULL;
|
||||
break;
|
||||
}
|
||||
case k7zIdEmptyFile:
|
||||
@@ -1397,27 +1286,23 @@ static SRes SzReadHeader2(
|
||||
}
|
||||
|
||||
{
|
||||
UInt32 i;
|
||||
UInt32 emptyFileIndex = 0;
|
||||
|
||||
UInt32 folderIndex = 0;
|
||||
UInt32 indexInFolder = 0;
|
||||
UInt32 remSubStreams = 0;
|
||||
UInt32 numSubStreams = 0;
|
||||
UInt64 unpackPos = 0;
|
||||
const Byte *digestsDefs = 0;
|
||||
const Byte *digestsVals = 0;
|
||||
const Byte *digestsDefs = NULL;
|
||||
const Byte *digestsVals = NULL;
|
||||
UInt32 digestsValsIndex = 0;
|
||||
UInt32 digestIndex;
|
||||
Byte allDigestsDefined = 0;
|
||||
UInt32 curNumSubStreams = (UInt32)(Int32)-1;
|
||||
Byte isDirMask = 0;
|
||||
Byte crcMask = 0;
|
||||
Byte mask = 0x80;
|
||||
// size_t unpSizesOffset = 0;
|
||||
CSzData sdCodersUnpSizes;
|
||||
sdCodersUnpSizes.Data = p->db.UnpackSizesData;
|
||||
sdCodersUnpSizes.Size = p->db.UnpackSizesDataSize;
|
||||
|
||||
MY_ALLOC(UInt32, p->FolderStartFileIndex, p->db.NumFolders + 1, allocMain);
|
||||
MY_ALLOC_ZE(UInt32, p->FileIndexToFolderIndexMap, p->NumFiles, allocMain);
|
||||
MY_ALLOC(UInt32, p->FolderToFile, p->db.NumFolders + 1, allocMain);
|
||||
MY_ALLOC_ZE(UInt32, p->FileToFolder, p->NumFiles, allocMain);
|
||||
MY_ALLOC(UInt64, p->UnpackPositions, p->NumFiles + 1, allocMain);
|
||||
MY_ALLOC_ZE(Byte, p->IsDirs, (p->NumFiles + 7) >> 3, allocMain);
|
||||
|
||||
@@ -1425,7 +1310,7 @@ static SRes SzReadHeader2(
|
||||
|
||||
if (ssi.sdCRCs.Size != 0)
|
||||
{
|
||||
RINOK(SzReadByte(&ssi.sdCRCs, &allDigestsDefined));
|
||||
SZ_READ_BYTE_SD(&ssi.sdCRCs, allDigestsDefined);
|
||||
if (allDigestsDefined)
|
||||
digestsVals = ssi.sdCRCs.Data;
|
||||
else
|
||||
@@ -1437,6 +1322,7 @@ static SRes SzReadHeader2(
|
||||
}
|
||||
|
||||
digestIndex = 0;
|
||||
|
||||
for (i = 0; i < numFiles; i++, mask >>= 1)
|
||||
{
|
||||
if (mask == 0)
|
||||
@@ -1451,79 +1337,66 @@ static SRes SzReadHeader2(
|
||||
|
||||
p->UnpackPositions[i] = unpackPos;
|
||||
p->CRCs.Vals[i] = 0;
|
||||
// p->CRCs.Defs[i] = 0;
|
||||
|
||||
if (emptyStreams && SzBitArray_Check(emptyStreams, i))
|
||||
{
|
||||
if (!emptyFiles || !SzBitArray_Check(emptyFiles, emptyFileIndex))
|
||||
if (emptyFiles)
|
||||
{
|
||||
if (!SzBitArray_Check(emptyFiles, emptyFileIndex))
|
||||
isDirMask |= mask;
|
||||
emptyFileIndex++;
|
||||
if (indexInFolder == 0)
|
||||
}
|
||||
else
|
||||
isDirMask |= mask;
|
||||
if (remSubStreams == 0)
|
||||
{
|
||||
p->FileIndexToFolderIndexMap[i] = (UInt32)-1;
|
||||
p->FileToFolder[i] = (UInt32)-1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (indexInFolder == 0)
|
||||
|
||||
if (remSubStreams == 0)
|
||||
{
|
||||
/*
|
||||
v3.13 incorrectly worked with empty folders
|
||||
v4.07: Loop for skipping empty folders
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
if (folderIndex >= p->db.NumFolders)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
p->FolderStartFileIndex[folderIndex] = i;
|
||||
if (curNumSubStreams == (UInt32)(Int32)-1);
|
||||
p->FolderToFile[folderIndex] = i;
|
||||
numSubStreams = 1;
|
||||
if (ssi.sdNumSubStreams.Data)
|
||||
{
|
||||
curNumSubStreams = 1;
|
||||
if (ssi.sdNumSubStreams.Data != 0)
|
||||
{
|
||||
RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &curNumSubStreams));
|
||||
RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams));
|
||||
}
|
||||
}
|
||||
if (curNumSubStreams != 0)
|
||||
remSubStreams = numSubStreams;
|
||||
if (numSubStreams != 0)
|
||||
break;
|
||||
curNumSubStreams = (UInt32)(Int32)-1;
|
||||
folderIndex++; // check it
|
||||
{
|
||||
UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
|
||||
unpackPos += folderUnpackSize;
|
||||
if (unpackPos < folderUnpackSize)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
}
|
||||
|
||||
folderIndex++;
|
||||
}
|
||||
}
|
||||
p->FileIndexToFolderIndexMap[i] = folderIndex;
|
||||
|
||||
p->FileToFolder[i] = folderIndex;
|
||||
|
||||
if (emptyStreams && SzBitArray_Check(emptyStreams, i))
|
||||
continue;
|
||||
|
||||
indexInFolder++;
|
||||
if (indexInFolder >= curNumSubStreams)
|
||||
if (--remSubStreams == 0)
|
||||
{
|
||||
UInt64 folderUnpackSize = 0;
|
||||
UInt64 startFolderUnpackPos;
|
||||
{
|
||||
UInt32 mix = (UInt32)p->db.FoSizesOffsets[folderIndex];
|
||||
UInt32 mainIndex = mix & 0xFF;
|
||||
UInt32 numOutStreams = mix >> 8;
|
||||
UInt32 si;
|
||||
p->db.FoSizesOffsets[folderIndex] = sdCodersUnpSizes.Data - p->db.UnpackSizesData;
|
||||
for (si = 0; si < numOutStreams; si++)
|
||||
{
|
||||
UInt64 curSize;
|
||||
RINOK(ReadNumber(&sdCodersUnpSizes, &curSize));
|
||||
if (si == mainIndex)
|
||||
{
|
||||
folderUnpackSize = curSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (si == numOutStreams)
|
||||
return SZ_ERROR_FAIL;
|
||||
}
|
||||
|
||||
// UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
|
||||
startFolderUnpackPos = p->UnpackPositions[p->FolderStartFileIndex[folderIndex]];
|
||||
UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
|
||||
UInt64 startFolderUnpackPos = p->UnpackPositions[p->FolderToFile[folderIndex]];
|
||||
if (folderUnpackSize < unpackPos - startFolderUnpackPos)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
unpackPos = startFolderUnpackPos + folderUnpackSize;
|
||||
if (unpackPos < folderUnpackSize)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
|
||||
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];
|
||||
crcMask |= mask;
|
||||
@@ -1534,14 +1407,16 @@ static SRes SzReadHeader2(
|
||||
digestsValsIndex++;
|
||||
crcMask |= mask;
|
||||
}
|
||||
|
||||
folderIndex++;
|
||||
indexInFolder = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt64 v;
|
||||
RINOK(ReadNumber(&ssi.sdSizes, &v));
|
||||
unpackPos += v;
|
||||
if (unpackPos < v)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex)))
|
||||
{
|
||||
p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4);
|
||||
@@ -1550,30 +1425,55 @@ static SRes SzReadHeader2(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mask != 0x80)
|
||||
{
|
||||
UInt32 byteIndex = (i - 1) >> 3;
|
||||
p->IsDirs[byteIndex] = isDirMask;
|
||||
p->CRCs.Defs[byteIndex] = crcMask;
|
||||
}
|
||||
|
||||
p->UnpackPositions[i] = unpackPos;
|
||||
p->FolderStartFileIndex[folderIndex] = i;
|
||||
p->db.FoSizesOffsets[folderIndex] = sdCodersUnpSizes.Data - p->db.UnpackSizesData;
|
||||
|
||||
if (remSubStreams != 0)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
p->FolderToFile[folderIndex] = i;
|
||||
if (folderIndex >= p->db.NumFolders)
|
||||
break;
|
||||
if (!ssi.sdNumSubStreams.Data)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams));
|
||||
if (numSubStreams != 0)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
/*
|
||||
{
|
||||
UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
|
||||
unpackPos += folderUnpackSize;
|
||||
if (unpackPos < folderUnpackSize)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
}
|
||||
*/
|
||||
folderIndex++;
|
||||
}
|
||||
|
||||
if (ssi.sdNumSubStreams.Data && ssi.sdNumSubStreams.Size != 0)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
}
|
||||
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
|
||||
static SRes SzReadHeader(
|
||||
CSzArEx *p,
|
||||
CSzData *sd,
|
||||
ILookInStream *inStream,
|
||||
ISzAlloc *allocMain
|
||||
,ISzAlloc *allocTemp
|
||||
)
|
||||
ISzAlloc *allocMain,
|
||||
ISzAlloc *allocTemp)
|
||||
{
|
||||
// Byte *emptyStreamVector = 0;
|
||||
// Byte *emptyFileVector = 0;
|
||||
// Byte *lwtVector = 0;
|
||||
UInt32 i;
|
||||
UInt32 numTempBufs = 0;
|
||||
SRes res;
|
||||
@@ -1581,55 +1481,22 @@ static SRes SzReadHeader(
|
||||
|
||||
for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++)
|
||||
Buf_Init(tempBufs + i);
|
||||
// SzBitUi32s_Init(&digests);
|
||||
|
||||
res = SzReadHeader2(p, sd,
|
||||
// &emptyStreamVector,
|
||||
// &emptyFileVector,
|
||||
// &lwtVector,
|
||||
inStream,
|
||||
res = SzReadHeader2(p, sd, inStream,
|
||||
tempBufs, &numTempBufs,
|
||||
allocMain, allocTemp
|
||||
);
|
||||
allocMain, allocTemp);
|
||||
|
||||
for (i = 0; i < numTempBufs; i++)
|
||||
for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++)
|
||||
Buf_Free(tempBufs + i, allocTemp);
|
||||
|
||||
// IAlloc_Free(allocTemp, emptyStreamVector);
|
||||
// IAlloc_Free(allocTemp, emptyFileVector);
|
||||
// IAlloc_Free(allocTemp, lwtVector);
|
||||
|
||||
RINOK(res);
|
||||
{
|
||||
|
||||
if (sd->Size != 0)
|
||||
return SZ_ERROR_FAIL;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
static UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex)
|
||||
{
|
||||
const CSzFolder2 *f = p->Folders + folderIndex;
|
||||
|
||||
// return p->CoderUnpackSizes[f->StartCoderUnpackSizesIndex + f->IndexOfMainOutStream];
|
||||
|
||||
UInt32 si;
|
||||
CSzData sdCodersUnpSizes;
|
||||
sdCodersUnpSizes.Data = p->UnpackSizesData + f->UnpackSizeDataOffset;
|
||||
sdCodersUnpSizes.Size = p->UnpackSizesDataSize - f->UnpackSizeDataOffset;
|
||||
for (si = 0; si < numOutStreams; si++)
|
||||
{
|
||||
UInt64 curSize;
|
||||
ReadNumber(&sdCodersUnpSizes, &curSize);
|
||||
if (si == mainIndex)
|
||||
return curSize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
static SRes SzArEx_Open2(
|
||||
CSzArEx *p,
|
||||
ILookInStream *inStream,
|
||||
@@ -1687,6 +1554,7 @@ static SRes SzArEx_Open2(
|
||||
return SZ_ERROR_MEM;
|
||||
|
||||
res = LookInStream_Read(inStream, buf.data, nextHeaderSizeT);
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
res = SZ_ERROR_ARCHIVE;
|
||||
@@ -1696,7 +1564,9 @@ static SRes SzArEx_Open2(
|
||||
UInt64 type;
|
||||
sd.Data = buf.data;
|
||||
sd.Size = buf.size;
|
||||
|
||||
res = ReadID(&sd, &type);
|
||||
|
||||
if (res == SZ_OK && type == k7zIdEncodedHeader)
|
||||
{
|
||||
CSzAr tempAr;
|
||||
@@ -1721,6 +1591,7 @@ static SRes SzArEx_Open2(
|
||||
res = ReadID(&sd, &type);
|
||||
}
|
||||
}
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
if (type == k7zIdHeader)
|
||||
@@ -1744,11 +1615,11 @@ static SRes SzArEx_Open2(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Buf_Free(&buf, allocTemp);
|
||||
return res;
|
||||
}
|
||||
|
||||
// #include <stdio.h>
|
||||
|
||||
SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream,
|
||||
ISzAlloc *allocMain, ISzAlloc *allocTemp)
|
||||
@@ -1756,10 +1627,10 @@ SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream,
|
||||
SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp);
|
||||
if (res != SZ_OK)
|
||||
SzArEx_Free(p, allocMain);
|
||||
// printf ("\nrrr=%d\n", rrr);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
SRes SzArEx_Extract(
|
||||
const CSzArEx *p,
|
||||
ILookInStream *inStream,
|
||||
@@ -1772,34 +1643,36 @@ SRes SzArEx_Extract(
|
||||
ISzAlloc *allocMain,
|
||||
ISzAlloc *allocTemp)
|
||||
{
|
||||
UInt32 folderIndex = p->FileIndexToFolderIndexMap[fileIndex];
|
||||
UInt32 folderIndex = p->FileToFolder[fileIndex];
|
||||
SRes res = SZ_OK;
|
||||
|
||||
*offset = 0;
|
||||
*outSizeProcessed = 0;
|
||||
|
||||
if (folderIndex == (UInt32)-1)
|
||||
{
|
||||
IAlloc_Free(allocMain, *tempBuf);
|
||||
*blockIndex = folderIndex;
|
||||
*tempBuf = 0;
|
||||
*tempBuf = NULL;
|
||||
*outBufferSize = 0;
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
if (*tempBuf == 0 || *blockIndex != folderIndex)
|
||||
if (*tempBuf == NULL || *blockIndex != folderIndex)
|
||||
{
|
||||
// UInt64 unpackSizeSpec = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
|
||||
UInt64 unpackSizeSpec = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
|
||||
/*
|
||||
UInt64 unpackSizeSpec =
|
||||
p->UnpackPositions[p->FolderStartFileIndex[folderIndex + 1]] -
|
||||
p->UnpackPositions[p->FolderStartFileIndex[folderIndex]];
|
||||
p->UnpackPositions[p->FolderToFile[folderIndex + 1]] -
|
||||
p->UnpackPositions[p->FolderToFile[folderIndex]];
|
||||
*/
|
||||
size_t unpackSize = (size_t)unpackSizeSpec;
|
||||
|
||||
if (unpackSize != unpackSizeSpec)
|
||||
return SZ_ERROR_MEM;
|
||||
*blockIndex = folderIndex;
|
||||
IAlloc_Free(allocMain, *tempBuf);
|
||||
*tempBuf = 0;
|
||||
|
||||
// RINOK(LookInStream_SeekTo(inStream, startOffset));
|
||||
*tempBuf = NULL;
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
@@ -1807,36 +1680,30 @@ SRes SzArEx_Extract(
|
||||
if (unpackSize != 0)
|
||||
{
|
||||
*tempBuf = (Byte *)IAlloc_Alloc(allocMain, unpackSize);
|
||||
if (*tempBuf == 0)
|
||||
if (*tempBuf == NULL)
|
||||
res = SZ_ERROR_MEM;
|
||||
}
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
res = SzAr_DecodeFolder(&p->db, folderIndex,
|
||||
inStream,
|
||||
p->dataPos,
|
||||
*tempBuf, unpackSize, allocTemp);
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
if (SzBitWithVals_Check(&p->db.FolderCRCs, folderIndex))
|
||||
{
|
||||
if (CrcCalc(*tempBuf, unpackSize) != p->db.FolderCRCs.Vals[folderIndex])
|
||||
res = SZ_ERROR_CRC;
|
||||
}
|
||||
}
|
||||
inStream, p->dataPos, *tempBuf, unpackSize, allocTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
UInt64 unpackPos = p->UnpackPositions[fileIndex];
|
||||
*offset = (size_t)(unpackPos - p->UnpackPositions[p->FolderStartFileIndex[folderIndex]]);
|
||||
*offset = (size_t)(unpackPos - p->UnpackPositions[p->FolderToFile[folderIndex]]);
|
||||
*outSizeProcessed = (size_t)(p->UnpackPositions[fileIndex + 1] - unpackPos);
|
||||
if (*offset + *outSizeProcessed > *outBufferSize)
|
||||
return SZ_ERROR_FAIL;
|
||||
if (SzBitWithVals_Check(&p->CRCs, fileIndex) && CrcCalc(*tempBuf + *offset, *outSizeProcessed) != p->CRCs.Vals[fileIndex])
|
||||
if (SzBitWithVals_Check(&p->CRCs, fileIndex))
|
||||
if (CrcCalc(*tempBuf + *offset, *outSizeProcessed) != p->CRCs.Vals[fileIndex])
|
||||
res = SZ_ERROR_CRC;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
56
C/7zDec.c
56
C/7zDec.c
@@ -1,5 +1,5 @@
|
||||
/* 7zDec.c -- Decoding from 7z folder
|
||||
2015-08-01 : Igor Pavlov : Public domain */
|
||||
2015-11-18 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
/* #define _7ZIP_PPMD_SUPPPORT */
|
||||
|
||||
#include "7z.h"
|
||||
#include "7zCrc.h"
|
||||
|
||||
#include "Bcj2.h"
|
||||
#include "Bra.h"
|
||||
@@ -160,14 +161,23 @@ static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, I
|
||||
inSize -= inProcessed;
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
if (state.dicPos == state.dicBufSize || (inProcessed == 0 && dicPos == state.dicPos))
|
||||
|
||||
if (status == LZMA_STATUS_FINISHED_WITH_MARK)
|
||||
{
|
||||
if (state.dicBufSize != outSize || lookahead != 0 ||
|
||||
(status != LZMA_STATUS_FINISHED_WITH_MARK &&
|
||||
status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK))
|
||||
if (outSize != state.dicPos || inSize != 0)
|
||||
res = SZ_ERROR_DATA;
|
||||
break;
|
||||
}
|
||||
|
||||
if (outSize == state.dicPos && inSize == 0 && status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)
|
||||
break;
|
||||
|
||||
if (inProcessed == 0 && dicPos == state.dicPos)
|
||||
{
|
||||
res = SZ_ERROR_DATA;
|
||||
break;
|
||||
}
|
||||
|
||||
res = inStream->Skip((void *)inStream, inProcessed);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
@@ -213,13 +223,20 @@ static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize,
|
||||
inSize -= inProcessed;
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
if (state.decoder.dicPos == state.decoder.dicBufSize || (inProcessed == 0 && dicPos == state.decoder.dicPos))
|
||||
|
||||
if (status == LZMA_STATUS_FINISHED_WITH_MARK)
|
||||
{
|
||||
if (state.decoder.dicBufSize != outSize || lookahead != 0 ||
|
||||
(status != LZMA_STATUS_FINISHED_WITH_MARK))
|
||||
if (outSize != state.decoder.dicPos || inSize != 0)
|
||||
res = SZ_ERROR_DATA;
|
||||
break;
|
||||
}
|
||||
|
||||
if (inProcessed == 0 && dicPos == state.decoder.dicPos)
|
||||
{
|
||||
res = SZ_ERROR_DATA;
|
||||
break;
|
||||
}
|
||||
|
||||
res = inStream->Skip((void *)inStream, inProcessed);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
@@ -537,33 +554,38 @@ SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
|
||||
SRes res;
|
||||
CSzFolder folder;
|
||||
CSzData sd;
|
||||
CSzData sdSizes;
|
||||
|
||||
const Byte *data = p->CodersData + p->FoCodersOffsets[folderIndex];
|
||||
sd.Data = data;
|
||||
sd.Size = p->FoCodersOffsets[folderIndex + 1] - p->FoCodersOffsets[folderIndex];
|
||||
|
||||
sdSizes.Data = p->UnpackSizesData + p->FoSizesOffsets[folderIndex];
|
||||
sdSizes.Size =
|
||||
p->FoSizesOffsets[folderIndex + 1] -
|
||||
p->FoSizesOffsets[folderIndex];
|
||||
|
||||
res = SzGetNextFolderItem(&folder, &sd, &sdSizes);
|
||||
res = SzGetNextFolderItem(&folder, &sd);
|
||||
|
||||
if (res != SZ_OK)
|
||||
return res;
|
||||
|
||||
if (sd.Size != 0 || outSize != folder.CodersUnpackSizes[folder.UnpackStream])
|
||||
if (sd.Size != 0
|
||||
|| folder.UnpackStream != p->FoToMainUnpackSizeIndex[folderIndex]
|
||||
|| outSize != SzAr_GetFolderUnpackSize(p, folderIndex))
|
||||
return SZ_ERROR_FAIL;
|
||||
{
|
||||
unsigned i;
|
||||
Byte *tempBuf[3] = { 0, 0, 0};
|
||||
res = SzFolder_Decode2(&folder, data, folder.CodersUnpackSizes,
|
||||
|
||||
res = SzFolder_Decode2(&folder, data,
|
||||
&p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex]],
|
||||
p->PackPositions + p->FoStartPackStreamIndex[folderIndex],
|
||||
inStream, startPos,
|
||||
outBuffer, (SizeT)outSize, allocMain, tempBuf);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
IAlloc_Free(allocMain, tempBuf[i]);
|
||||
|
||||
if (res == SZ_OK)
|
||||
if (SzBitWithVals_Check(&p->FolderCRCs, folderIndex))
|
||||
if (CrcCalc(outBuffer, outSize) != p->FolderCRCs.Vals[folderIndex])
|
||||
res = SZ_ERROR_CRC;
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#define MY_VER_MAJOR 15
|
||||
#define MY_VER_MINOR 9
|
||||
#define MY_VER_MINOR 12
|
||||
#define MY_VER_BUILD 0
|
||||
#define MY_VERSION_NUMBERS "15.09"
|
||||
#define MY_VERSION "15.09 beta"
|
||||
#define MY_DATE "2015-10-16"
|
||||
#define MY_VERSION_NUMBERS "15.12"
|
||||
#define MY_VERSION "15.12"
|
||||
#define MY_DATE "2015-11-19"
|
||||
#undef MY_COPYRIGHT
|
||||
#undef MY_VERSION_COPYRIGHT_DATE
|
||||
#define MY_AUTHOR_NAME "Igor Pavlov"
|
||||
|
||||
@@ -513,4 +513,3 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
|
||||
#endif
|
||||
return Groups[0];
|
||||
}
|
||||
|
||||
|
||||
40
C/CpuArch.h
40
C/CpuArch.h
@@ -1,5 +1,5 @@
|
||||
/* CpuArch.h -- CPU specific code
|
||||
2015-08-02: Igor Pavlov : Public domain */
|
||||
2015-10-31: Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __CPU_ARCH_H
|
||||
#define __CPU_ARCH_H
|
||||
@@ -10,13 +10,17 @@ EXTERN_C_BEGIN
|
||||
|
||||
/*
|
||||
MY_CPU_LE means that CPU is LITTLE ENDIAN.
|
||||
If MY_CPU_LE is not defined, we don't know about that property of platform (it can be LITTLE ENDIAN).
|
||||
MY_CPU_BE means that CPU is BIG ENDIAN.
|
||||
If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of platform.
|
||||
|
||||
MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.
|
||||
If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform.
|
||||
*/
|
||||
|
||||
#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__)
|
||||
#if defined(_M_X64) \
|
||||
|| defined(_M_AMD64) \
|
||||
|| defined(__x86_64__) \
|
||||
|| defined(__AMD64__) \
|
||||
|| defined(__amd64__)
|
||||
#define MY_CPU_AMD64
|
||||
#endif
|
||||
|
||||
@@ -52,10 +56,6 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
||||
#define MY_CPU_IA64_LE
|
||||
#endif
|
||||
|
||||
#if defined(MY_CPU_X86_OR_AMD64)
|
||||
#define MY_CPU_LE_UNALIGN
|
||||
#endif
|
||||
|
||||
#if defined(MY_CPU_X86_OR_AMD64) \
|
||||
|| defined(MY_CPU_ARM_LE) \
|
||||
|| defined(MY_CPU_IA64_LE) \
|
||||
@@ -65,7 +65,8 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
||||
|| defined(__AARCH64EL__) \
|
||||
|| defined(__MIPSEL__) \
|
||||
|| defined(__MIPSEL) \
|
||||
|| defined(_MIPSEL)
|
||||
|| defined(_MIPSEL) \
|
||||
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
||||
#define MY_CPU_LE
|
||||
#endif
|
||||
|
||||
@@ -76,7 +77,9 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
||||
|| defined(__MIPSEB__) \
|
||||
|| defined(__MIPSEB) \
|
||||
|| defined(_MIPSEB) \
|
||||
|| defined(__m68k__)
|
||||
|| defined(__m68k__) \
|
||||
|| defined(__s390x__) \
|
||||
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
|
||||
#define MY_CPU_BE
|
||||
#endif
|
||||
|
||||
@@ -85,6 +88,14 @@ Stop_Compiling_Bad_Endian
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MY_CPU_LE
|
||||
#if defined(MY_CPU_X86_OR_AMD64) \
|
||||
/* || defined(__AARCH64EL__) */
|
||||
#define MY_CPU_LE_UNALIGN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MY_CPU_LE_UNALIGN
|
||||
|
||||
#define GetUi16(p) (*(const UInt16 *)(const void *)(p))
|
||||
@@ -128,6 +139,8 @@ Stop_Compiling_Bad_Endian
|
||||
|
||||
#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)
|
||||
|
||||
/* Note: we use bswap instruction, that is unsupported in 386 cpu */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#pragma intrinsic(_byteswap_ulong)
|
||||
@@ -137,6 +150,13 @@ Stop_Compiling_Bad_Endian
|
||||
|
||||
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
|
||||
|
||||
#elif defined(MY_CPU_LE_UNALIGN) && defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||
|
||||
#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))
|
||||
#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))
|
||||
|
||||
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v)
|
||||
|
||||
#else
|
||||
|
||||
#define GetBe32(p) ( \
|
||||
|
||||
10
C/Lzma2Dec.c
10
C/Lzma2Dec.c
@@ -1,5 +1,5 @@
|
||||
/* Lzma2Dec.c -- LZMA2 Decoder
|
||||
2014-10-29 : Igor Pavlov : Public domain */
|
||||
2015-11-09 : Igor Pavlov : Public domain */
|
||||
|
||||
/* #define SHOW_DEBUG_INFO */
|
||||
|
||||
@@ -103,8 +103,8 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
||||
{
|
||||
case LZMA2_STATE_CONTROL:
|
||||
p->control = b;
|
||||
PRF(printf("\n %4X ", p->decoder.dicPos));
|
||||
PRF(printf(" %2X", b));
|
||||
PRF(printf("\n %4X ", (unsigned)p->decoder.dicPos));
|
||||
PRF(printf(" %2X", (unsigned)b));
|
||||
if (p->control == 0)
|
||||
return LZMA2_STATE_FINISHED;
|
||||
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
|
||||
@@ -124,7 +124,7 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
||||
case LZMA2_STATE_UNPACK1:
|
||||
p->unpackSize |= (UInt32)b;
|
||||
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;
|
||||
|
||||
case LZMA2_STATE_PACK0:
|
||||
@@ -134,7 +134,7 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
||||
case LZMA2_STATE_PACK1:
|
||||
p->packSize |= (UInt32)b;
|
||||
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:
|
||||
(p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/* 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"
|
||||
|
||||
@@ -7,8 +9,8 @@
|
||||
#include "Bra.h"
|
||||
#include "LzmaDec.h"
|
||||
|
||||
static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
|
||||
static void SzFree(void *p, void *address) { p = p; MyFree(address); }
|
||||
static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
|
||||
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
|
||||
|
||||
SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/* 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>
|
||||
|
||||
@@ -11,8 +13,8 @@
|
||||
|
||||
#define SZE_OUT_OVERFLOW SZE_DATA_ERROR
|
||||
|
||||
static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
|
||||
static void SzFree(void *p, void *address) { p = p; MyFree(address); }
|
||||
static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
|
||||
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 level, UInt32 dictSize, int filterMode)
|
||||
|
||||
18
C/LzmaEnc.c
18
C/LzmaEnc.c
@@ -1,5 +1,5 @@
|
||||
/* LzmaEnc.c -- LZMA Encoder
|
||||
2015-10-15 Igor Pavlov : Public domain */
|
||||
2015-11-08 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -854,7 +854,7 @@ static void MovePos(CLzmaEnc *p, UInt32 num)
|
||||
{
|
||||
#ifdef SHOW_STAT
|
||||
g_STAT_OFFSET += num;
|
||||
printf("\n MovePos %d", num);
|
||||
printf("\n MovePos %u", num);
|
||||
#endif
|
||||
|
||||
if (num != 0)
|
||||
@@ -871,12 +871,12 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
|
||||
numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);
|
||||
|
||||
#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++;
|
||||
{
|
||||
UInt32 i;
|
||||
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
|
||||
|
||||
@@ -1167,12 +1167,12 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
cur = 0;
|
||||
|
||||
#ifdef SHOW_STAT2
|
||||
if (position >= 0)
|
||||
/* if (position >= 0) */
|
||||
{
|
||||
unsigned i;
|
||||
printf("\n pos = %4X", position);
|
||||
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
|
||||
|
||||
@@ -1397,13 +1397,13 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
{
|
||||
UInt32 lenTest2 = lenTest + 1;
|
||||
UInt32 limit = lenTest2 + p->numFastBytes;
|
||||
UInt32 nextRepMatchPrice;
|
||||
if (limit > numAvailFull)
|
||||
limit = numAvailFull;
|
||||
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
|
||||
lenTest2 -= lenTest + 1;
|
||||
if (lenTest2 >= 2)
|
||||
{
|
||||
UInt32 nextRepMatchPrice;
|
||||
UInt32 state2 = kRepNextStates[state];
|
||||
UInt32 posStateNext = (position + lenTest) & p->pbMask;
|
||||
UInt32 curAndLenCharPrice =
|
||||
@@ -1487,13 +1487,13 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
const Byte *data2 = data - curBack - 1;
|
||||
UInt32 lenTest2 = lenTest + 1;
|
||||
UInt32 limit = lenTest2 + p->numFastBytes;
|
||||
UInt32 nextRepMatchPrice;
|
||||
if (limit > numAvailFull)
|
||||
limit = numAvailFull;
|
||||
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
|
||||
lenTest2 -= lenTest + 1;
|
||||
if (lenTest2 >= 2)
|
||||
{
|
||||
UInt32 nextRepMatchPrice;
|
||||
UInt32 state2 = kMatchNextStates[state];
|
||||
UInt32 posStateNext = (position + lenTest) & p->pbMask;
|
||||
UInt32 curAndLenCharPrice = curAndLenPrice +
|
||||
@@ -1829,7 +1829,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
|
||||
len = GetOptimum(p, nowPos32, &pos);
|
||||
|
||||
#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
|
||||
|
||||
posState = nowPos32 & p->pbMask;
|
||||
|
||||
37
C/Sha256.c
37
C/Sha256.c
@@ -1,5 +1,5 @@
|
||||
/* 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. */
|
||||
|
||||
#include "Precomp.h"
|
||||
@@ -113,10 +113,26 @@ static void Sha256_WriteByteBlock(CSha256 *p)
|
||||
{
|
||||
UInt32 W[16];
|
||||
unsigned j;
|
||||
UInt32 *state = p->state;
|
||||
UInt32 *state;
|
||||
|
||||
#ifdef _SHA256_UNROLL2
|
||||
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];
|
||||
b = state[1];
|
||||
c = state[2];
|
||||
@@ -126,17 +142,10 @@ static void Sha256_WriteByteBlock(CSha256 *p)
|
||||
g = state[6];
|
||||
h = state[7];
|
||||
#else
|
||||
UInt32 T[8];
|
||||
for (j = 0; j < 8; j++)
|
||||
T[j] = state[j];
|
||||
#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)
|
||||
{
|
||||
RX_16
|
||||
@@ -226,11 +235,13 @@ void Sha256_Final(CSha256 *p, Byte *digest)
|
||||
|
||||
Sha256_WriteByteBlock(p);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
for (i = 0; i < 8; i += 2)
|
||||
{
|
||||
UInt32 v = p->state[i];
|
||||
SetBe32(digest, v);
|
||||
digest += 4;
|
||||
UInt32 v0 = p->state[i];
|
||||
UInt32 v1 = p->state[i + 1];
|
||||
SetBe32(digest , v0);
|
||||
SetBe32(digest + 4, v1);
|
||||
digest += 8;
|
||||
}
|
||||
|
||||
Sha256_Init(p);
|
||||
|
||||
@@ -73,4 +73,3 @@ Ppmd7Dec.o: ../../Ppmd7Dec.c
|
||||
|
||||
clean:
|
||||
-$(RM) $(PROG) $(OBJS)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* 7zipInstall.c - 7-Zip Installer
|
||||
2015-09-28 : Igor Pavlov : Public domain */
|
||||
2015-11-08 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -261,7 +261,7 @@ static LONG MyRegistry_CreateKeyAndVal(HKEY parentKey, LPCWSTR keyName, LPCWSTR
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
res = MyRegistry_SetString(destKey, valName, val);
|
||||
res = RegCloseKey(destKey);
|
||||
/* res = */ RegCloseKey(destKey);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ static LONG MyRegistry_CreateKeyAndVal_32(HKEY parentKey, LPCWSTR keyName, LPCWS
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
res = MyRegistry_SetString(destKey, valName, val);
|
||||
res = RegCloseKey(destKey);
|
||||
/* res = */ RegCloseKey(destKey);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -322,7 +322,7 @@ static Bool FindSignature(CSzFile *stream, UInt64 *resPos)
|
||||
processed -= k7zStartHeaderSize;
|
||||
for (pos = 0; pos <= processed; pos++)
|
||||
{
|
||||
for (; buf[pos] != '7' && pos <= processed; pos++);
|
||||
for (; pos <= processed && buf[pos] != '7'; pos++);
|
||||
if (pos > processed)
|
||||
break;
|
||||
if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0)
|
||||
@@ -598,8 +598,8 @@ static LONG SetRegKey_Path2(HKEY parentKey)
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
res = MyRegistry_SetString(destKey, k_Reg_Path32, path);
|
||||
res = MyRegistry_SetString(destKey, k_Reg_Path, path);
|
||||
res = RegCloseKey(destKey);
|
||||
/* res = */ MyRegistry_SetString(destKey, k_Reg_Path, path);
|
||||
/* res = */ RegCloseKey(destKey);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -718,10 +718,10 @@ static void WriteCLSID()
|
||||
WCHAR destPath[MAX_PATH + 10];
|
||||
wcscpy(destPath, path);
|
||||
wcscat(destPath, L"7-zip32.dll");
|
||||
res = MyRegistry_SetString(destKey, NULL, destPath);
|
||||
res = MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
|
||||
/* res = */ MyRegistry_SetString(destKey, NULL, destPath);
|
||||
/* res = */ MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
|
||||
// DeleteRegValue(destKey, L"InprocServer32");
|
||||
res = RegCloseKey(destKey);
|
||||
/* res = */ RegCloseKey(destKey);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -737,10 +737,10 @@ static void WriteCLSID()
|
||||
WCHAR destPath[MAX_PATH + 10];
|
||||
wcscpy(destPath, path);
|
||||
wcscat(destPath, L"7-zip.dll");
|
||||
res = MyRegistry_SetString(destKey, NULL, destPath);
|
||||
res = MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
|
||||
/* res = */ MyRegistry_SetString(destKey, NULL, destPath);
|
||||
/* res = */ MyRegistry_SetString(destKey, L"ThreadingModel", L"Apartment");
|
||||
// DeleteRegValue(destKey, L"InprocServer32");
|
||||
res = RegCloseKey(destKey);
|
||||
/* res = */ RegCloseKey(destKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1083,7 +1083,6 @@ static int Install()
|
||||
WCHAR sfxPath[MAX_PATH + 2];
|
||||
|
||||
Bool needReboot = False;
|
||||
size_t pathLen;
|
||||
|
||||
allocImp.Alloc = SzAlloc;
|
||||
allocImp.Free = SzFree;
|
||||
@@ -1116,6 +1115,7 @@ static int Install()
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
size_t pathLen;
|
||||
if (!g_SilentMode)
|
||||
{
|
||||
GetDlgItemTextW(g_HWND, IDE_EXTRACT_PATH, path, MAX_PATH);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* 7zipUninstall.c - 7-Zip Uninstaller
|
||||
2015-08-09 : Igor Pavlov : Public domain */
|
||||
2015-11-08 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -384,7 +384,7 @@ static void WriteCLSID()
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
RegDeleteValueW(destKey, k_7zip_CLSID);
|
||||
res = RegCloseKey(destKey);
|
||||
/* res = */ RegCloseKey(destKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -419,7 +419,7 @@ static void WriteCLSID()
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
RegDeleteValueW(destKey, k_7zip_CLSID);
|
||||
res = RegCloseKey(destKey);
|
||||
/* res = */ RegCloseKey(destKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* LzmaUtil.c -- Test application for LZMA compression
|
||||
2015-06-13 : Igor Pavlov : Public domain */
|
||||
2015-11-08 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "../../Precomp.h"
|
||||
|
||||
@@ -133,7 +133,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
|
||||
SRes res;
|
||||
CLzmaEncProps props;
|
||||
|
||||
rs = rs;
|
||||
UNUSED_VAR(rs);
|
||||
|
||||
enc = LzmaEnc_Create(&g_Alloc);
|
||||
if (enc == 0)
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
/* 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>
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
hInstance = hInstance;
|
||||
dwReason = dwReason;
|
||||
lpReserved = lpReserved;
|
||||
UNUSED_VAR(hInstance);
|
||||
UNUSED_VAR(dwReason);
|
||||
UNUSED_VAR(lpReserved);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SfxSetup.c - 7z SFX Setup
|
||||
2015-03-25 : Igor Pavlov : Public domain */
|
||||
2015-11-08 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -88,7 +88,7 @@ static unsigned FindItem(const char * const *items, unsigned num, const wchar_t
|
||||
#ifdef _CONSOLE
|
||||
static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
|
||||
{
|
||||
ctrlType = ctrlType;
|
||||
UNUSED_VAR(ctrlType);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
@@ -144,7 +144,7 @@ static Bool FindSignature(CSzFile *stream, UInt64 *resPos)
|
||||
processed -= k7zStartHeaderSize;
|
||||
for (pos = 0; pos <= processed; pos++)
|
||||
{
|
||||
for (; buf[pos] != '7' && pos <= processed; pos++);
|
||||
for (; pos <= processed && buf[pos] != '7'; pos++);
|
||||
if (pos > processed)
|
||||
break;
|
||||
if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0)
|
||||
@@ -257,10 +257,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
#ifdef _CONSOLE
|
||||
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
|
||||
#else
|
||||
hInstance = hInstance;
|
||||
hPrevInstance = hPrevInstance;
|
||||
lpCmdLine = lpCmdLine;
|
||||
nCmdShow = nCmdShow;
|
||||
UNUSED_VAR(hInstance);
|
||||
UNUSED_VAR(hPrevInstance);
|
||||
UNUSED_VAR(lpCmdLine);
|
||||
UNUSED_VAR(nCmdShow);
|
||||
#endif
|
||||
|
||||
CrcGenerateTable();
|
||||
|
||||
16
C/XzDec.c
16
C/XzDec.c
@@ -1,5 +1,5 @@
|
||||
/* XzDec.c -- Xz Decode
|
||||
2015-05-01 : Igor Pavlov : Public domain */
|
||||
2015-11-09 : Igor Pavlov : Public domain */
|
||||
|
||||
#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)
|
||||
{
|
||||
CBraState *p = ((CBraState *)pp);
|
||||
alloc = alloc;
|
||||
UNUSED_VAR(alloc);
|
||||
p->ip = 0;
|
||||
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);
|
||||
SizeT destLenOrig = *destLen;
|
||||
SizeT srcLenOrig = *srcLen;
|
||||
UNUSED_VAR(finishMode);
|
||||
*destLen = 0;
|
||||
*srcLen = 0;
|
||||
finishMode = finishMode;
|
||||
*wasFinished = 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)
|
||||
{
|
||||
UNUSED_VAR(pp);
|
||||
props = props;
|
||||
alloc = alloc;
|
||||
UNUSED_VAR(props);
|
||||
UNUSED_VAR(alloc);
|
||||
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;
|
||||
SRes res;
|
||||
srcWasFinished = srcWasFinished;
|
||||
UNUSED_VAR(srcWasFinished);
|
||||
p->dest = dest;
|
||||
p->destLen = *destLen;
|
||||
p->src = src;
|
||||
@@ -308,7 +308,7 @@ static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *sr
|
||||
ELzmaStatus status;
|
||||
/* 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);
|
||||
srcWasFinished = srcWasFinished;
|
||||
UNUSED_VAR(srcWasFinished);
|
||||
*wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
|
||||
return res;
|
||||
}
|
||||
@@ -555,7 +555,7 @@ SRes XzBlock_Parse(CXzBlock *p, const Byte *header)
|
||||
pos += (unsigned)size;
|
||||
|
||||
#ifdef XZ_DUMP
|
||||
printf("\nf[%d] = %2X: ", i, filter->id);
|
||||
printf("\nf[%u] = %2X: ", i, (unsigned)filter->id);
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < size; i++)
|
||||
|
||||
5
C/XzIn.c
5
C/XzIn.c
@@ -1,5 +1,5 @@
|
||||
/* XzIn.c - Xz input
|
||||
2015-04-21 : Igor Pavlov : Public domain */
|
||||
2015-11-08 : Igor Pavlov : Public domain */
|
||||
|
||||
#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)
|
||||
{
|
||||
size_t i, numBlocks, pos = 1;
|
||||
size_t numBlocks, pos = 1;
|
||||
UInt32 crc;
|
||||
|
||||
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);
|
||||
if (numBlocks != 0)
|
||||
{
|
||||
size_t i;
|
||||
p->numBlocks = numBlocks;
|
||||
p->numBlocksAllocated = numBlocks;
|
||||
p->blocks = alloc->Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks);
|
||||
|
||||
@@ -158,14 +158,6 @@ SOURCE=.\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -350,14 +342,6 @@ SOURCE=..\Common\CoderMixer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\HandlerOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -254,8 +254,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
lps->Init(extractCallback, false);
|
||||
|
||||
CDecoder decoder(
|
||||
#ifndef USE_MIXER_ST
|
||||
#if !defined(USE_MIXER_MT)
|
||||
false
|
||||
#elif !defined(USE_MIXER_ST)
|
||||
true
|
||||
#elif !defined(__7Z_SET_PROPERTIES)
|
||||
#ifdef _7ZIP_ST
|
||||
false
|
||||
#else
|
||||
true
|
||||
#endif
|
||||
#else
|
||||
_useMultiThreadMixer
|
||||
#endif
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// 7zFolderOutStream.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
@@ -1,6 +0,0 @@
|
||||
// 7zFolderOutStream.h
|
||||
|
||||
#ifndef __7Z_FOLDER_OUT_STREAM_H
|
||||
#define __7Z_FOLDER_OUT_STREAM_H
|
||||
|
||||
#endif
|
||||
@@ -36,10 +36,14 @@ CHandler::CHandler()
|
||||
#endif
|
||||
|
||||
#ifdef EXTRACT_ONLY
|
||||
|
||||
_crcSize = 4;
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
_numThreads = NSystem::GetNumberOfProcessors();
|
||||
_useMultiThreadMixer = true;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -722,10 +726,14 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
return E_INVALIDARG;
|
||||
const PROPVARIANT &value = values[i];
|
||||
UInt32 number;
|
||||
int index = ParseStringToUInt32(name, number);
|
||||
unsigned index = ParseStringToUInt32(name, number);
|
||||
if (index == 0)
|
||||
{
|
||||
if (name.IsEqualTo("mtf")) return PROPVARIANT_to_bool(value, _useMultiThreadMixer);
|
||||
if (name.IsEqualTo("mtf"))
|
||||
{
|
||||
RINOK(PROPVARIANT_to_bool(value, _useMultiThreadMixer));
|
||||
continue;
|
||||
}
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||
{
|
||||
RINOK(ParseMtProp(name.Ptr(2), value, numProcessors, _numThreads));
|
||||
|
||||
@@ -87,6 +87,8 @@ struct CFolders
|
||||
return PackPositions[index + 1] - PackPositions[index];
|
||||
}
|
||||
|
||||
CFolders(): NumPackStreams(0), NumFolders(0) {}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
NumPackStreams = 0;
|
||||
|
||||
@@ -13,7 +13,6 @@ AR_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
@@ -65,7 +64,6 @@ COMPRESS_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// CrossThreadProgress.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "CrossThreadProgress.h"
|
||||
|
||||
STDMETHODIMP CCrossThreadProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
|
||||
{
|
||||
InSize = inSize;
|
||||
OutSize = outSize;
|
||||
ProgressEvent.Set();
|
||||
WaitEvent.Lock();
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// CrossThreadProgress.h
|
||||
|
||||
#ifndef __CROSSTHREADPROGRESS_H
|
||||
#define __CROSSTHREADPROGRESS_H
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
class CCrossThreadProgress:
|
||||
public ICompressProgressInfo,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
const UInt64 *InSize;
|
||||
const UInt64 *OutSize;
|
||||
HRESULT Result;
|
||||
NWindows::NSynchronization::CAutoResetEvent ProgressEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent WaitEvent;
|
||||
|
||||
HRes Create()
|
||||
{
|
||||
RINOK(ProgressEvent.CreateIfNotCreated());
|
||||
return WaitEvent.CreateIfNotCreated();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
ProgressEvent.Reset();
|
||||
WaitEvent.Reset();
|
||||
}
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -147,7 +147,9 @@ HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PR
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return ParseMethodFromPROPVARIANT(names[i], value);
|
||||
{
|
||||
RINOK(ParseMethodFromPROPVARIANT(names[i], value));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ HINSTANCE g_hInstance;
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION return FALSE;
|
||||
|
||||
#ifdef _WIN32
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(
|
||||
#ifdef UNDER_CE
|
||||
@@ -49,6 +50,7 @@ BOOL WINAPI DllMain(
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
DEFINE_GUID(CLSID_CArchiveHandler,
|
||||
k_7zip_GUID_Data1,
|
||||
|
||||
@@ -294,7 +294,11 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
|
||||
d.FileStructureVersion = ReadByte(); // = 1
|
||||
SkipZeros(1);
|
||||
ReadBytes(d.ApplicationUse, sizeof(d.ApplicationUse));
|
||||
SkipZeros(653);
|
||||
|
||||
// Most ISO contains zeros in the following field (reserved for future standardization).
|
||||
// But some ISO programs write some data to that area.
|
||||
// So we disable check for zeros.
|
||||
Skip(653); // SkipZeros(653);
|
||||
}
|
||||
|
||||
static const Byte kSig_CD001[5] = { 'C', 'D', '0', '0', '1' };
|
||||
|
||||
@@ -1292,6 +1292,18 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidError:
|
||||
{
|
||||
if (/* &_missingVol || */ !_missingVolName.IsEmpty())
|
||||
{
|
||||
UString s;
|
||||
s.SetFromAscii("Missing volume : ");
|
||||
s += _missingVolName;
|
||||
prop = s;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidErrorFlags:
|
||||
{
|
||||
UInt32 v = _errorFlags;
|
||||
@@ -1813,6 +1825,8 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
int prevSplitFile = -1;
|
||||
int prevMainFile = -1;
|
||||
|
||||
bool nextVol_is_Required = false;
|
||||
|
||||
CInArchive arch;
|
||||
|
||||
for (;;)
|
||||
@@ -1840,14 +1854,20 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
break;
|
||||
}
|
||||
|
||||
HRESULT result = openVolumeCallback->GetStream(seqName.GetNextName(), &inStream);
|
||||
if (result == S_FALSE)
|
||||
break;
|
||||
if (result != S_OK)
|
||||
const UString volName = seqName.GetNextName();
|
||||
|
||||
HRESULT result = openVolumeCallback->GetStream(volName, &inStream);
|
||||
|
||||
if (result != S_OK && result != S_FALSE)
|
||||
return result;
|
||||
if (!inStream)
|
||||
|
||||
if (!inStream || result != S_OK)
|
||||
{
|
||||
if (nextVol_is_Required)
|
||||
_missingVolName = volName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UInt64 endPos = 0;
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &arch.StreamStartPosition));
|
||||
@@ -2094,11 +2114,18 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
}
|
||||
|
||||
curBytes += endPos;
|
||||
|
||||
nextVol_is_Required = false;
|
||||
|
||||
if (!arcInfo.IsVolume())
|
||||
break;
|
||||
if (arcInfo.EndOfArchive_was_Read
|
||||
&& !arcInfo.AreMoreVolumes())
|
||||
|
||||
if (arcInfo.EndOfArchive_was_Read)
|
||||
{
|
||||
if (!arcInfo.AreMoreVolumes())
|
||||
break;
|
||||
nextVol_is_Required = true;
|
||||
}
|
||||
}
|
||||
|
||||
FillLinks();
|
||||
@@ -2120,6 +2147,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
_missingVolName.Empty();
|
||||
_errorFlags = 0;
|
||||
// _warningFlags = 0;
|
||||
_isArc = false;
|
||||
|
||||
@@ -381,6 +381,7 @@ private:
|
||||
// UInt32 _warningFlags;
|
||||
bool _isArc;
|
||||
CByteBuffer _comment;
|
||||
UString _missingVolName;
|
||||
|
||||
DECL_EXTERNAL_CODECS_VARS
|
||||
|
||||
|
||||
@@ -640,6 +640,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
|
||||
{
|
||||
ArcInfo.EndFlags = m_BlockHeader.Flags;
|
||||
UInt32 offset = 7;
|
||||
|
||||
if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_DataCRC)
|
||||
{
|
||||
if (processed < offset + 4)
|
||||
@@ -648,6 +649,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
|
||||
ArcInfo.DataCRC = Get32(m_FileHeaderData + offset);
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
if (m_BlockHeader.Flags & NHeader::NArchive::kEndOfArc_Flags_VolNumber)
|
||||
{
|
||||
if (processed < offset + 2)
|
||||
@@ -657,6 +659,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
|
||||
|
||||
ArcInfo.EndOfArchive_was_Read = true;
|
||||
}
|
||||
|
||||
m_Position += processed;
|
||||
FinishCryptoBlock();
|
||||
ArcInfo.EndPos = m_Position;
|
||||
@@ -699,11 +702,13 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
|
||||
continue;
|
||||
*/
|
||||
}
|
||||
|
||||
if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 10))
|
||||
{
|
||||
error = k_ErrorType_DecryptionError;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if ((m_BlockHeader.Flags & NHeader::NBlock::kLongBlock) != 0)
|
||||
{
|
||||
if (m_FileHeaderData.Size() < 7 + 4)
|
||||
@@ -855,7 +860,20 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
break;
|
||||
}
|
||||
|
||||
// case kpidError: if (!_errorMessage.IsEmpty()) prop = _errorMessage; break;
|
||||
|
||||
case kpidError:
|
||||
{
|
||||
// if (!_errorMessage.IsEmpty()) prop = _errorMessage; break;
|
||||
|
||||
if (/* &_missingVol || */ !_missingVolName.IsEmpty())
|
||||
{
|
||||
UString s;
|
||||
s.SetFromAscii("Missing volume : ");
|
||||
s += _missingVolName;
|
||||
prop = s;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidErrorFlags:
|
||||
{
|
||||
@@ -1019,7 +1037,10 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
openCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getTextPassword);
|
||||
}
|
||||
|
||||
bool nextVol_is_Required = false;
|
||||
|
||||
CInArchive archive;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
CMyComPtr<IInStream> inStream;
|
||||
@@ -1050,15 +1071,20 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
*/
|
||||
}
|
||||
|
||||
UString fullName = seqName.GetNextName();
|
||||
HRESULT result = openVolumeCallback->GetStream(fullName, &inStream);
|
||||
if (result == S_FALSE)
|
||||
break;
|
||||
if (result != S_OK)
|
||||
const UString volName = seqName.GetNextName();
|
||||
|
||||
HRESULT result = openVolumeCallback->GetStream(volName, &inStream);
|
||||
|
||||
if (result != S_OK && result != S_FALSE)
|
||||
return result;
|
||||
if (!inStream)
|
||||
|
||||
if (!inStream || result != S_OK)
|
||||
{
|
||||
if (nextVol_is_Required)
|
||||
_missingVolName = volName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
inStream = stream;
|
||||
|
||||
@@ -1174,6 +1200,18 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
arc.PhySize = archive.ArcInfo.GetPhySize();
|
||||
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
|
||||
// _errorMessage.Empty();
|
||||
_missingVolName.Empty();
|
||||
_errorFlags = 0;
|
||||
_warningFlags = 0;
|
||||
_isArc = false;
|
||||
|
||||
@@ -45,6 +45,7 @@ struct CInArcInfo
|
||||
|
||||
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_DataCRC_Defined() const { return (EndFlags & NHeader::NArchive::kEndOfArc_Flags_DataCRC) != 0; }
|
||||
};
|
||||
@@ -79,6 +80,7 @@ class CHandler:
|
||||
UInt32 _errorFlags;
|
||||
UInt32 _warningFlags;
|
||||
bool _isArc;
|
||||
UString _missingVolName;
|
||||
|
||||
DECL_EXTERNAL_CODECS_VARS
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
if (!_archive.IsArc) v |= kpv_ErrorFlags_IsNotArc;
|
||||
if (_archive.Unsupported) v |= kpv_ErrorFlags_UnsupportedFeature;
|
||||
if (_archive.UnexpectedEnd) v |= kpv_ErrorFlags_UnexpectedEnd;
|
||||
if (_archive.NoEndAnchor) v |= kpv_ErrorFlags_HeadersError;
|
||||
prop = v;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -610,6 +610,7 @@ API_FUNC_IsArc IsArc_Udf(const Byte *p, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HRESULT CInArchive::Open2()
|
||||
{
|
||||
Clear();
|
||||
@@ -644,8 +645,10 @@ HRESULT CInArchive::Open2()
|
||||
CExtent extentVDS;
|
||||
extentVDS.Parse(buf + i + 16);
|
||||
*/
|
||||
|
||||
const size_t kBufSize = 1 << 11;
|
||||
Byte buf[kBufSize];
|
||||
|
||||
for (SecLogSize = 11;; SecLogSize -= 3)
|
||||
{
|
||||
if (SecLogSize < 8)
|
||||
@@ -665,6 +668,7 @@ HRESULT CInArchive::Open2()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PhySize = (UInt32)(256 + 1) << SecLogSize;
|
||||
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;
|
||||
}
|
||||
|
||||
NoEndAnchor = true;
|
||||
|
||||
if (PhySize < fileSize)
|
||||
{
|
||||
UInt64 rem = fileSize - PhySize;
|
||||
const size_t secSize = (size_t)1 << SecLogSize;
|
||||
|
||||
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
|
||||
|
||||
for (unsigned sec = 0; sec < 1024; sec++)
|
||||
{
|
||||
if (rem == 0)
|
||||
break;
|
||||
|
||||
size_t readSize = secSize;
|
||||
if (readSize > rem)
|
||||
readSize = (size_t)rem;
|
||||
|
||||
RINOK(ReadStream(_stream, buf, &readSize));
|
||||
if (readSize == bufSize)
|
||||
|
||||
if (readSize == 0)
|
||||
break;
|
||||
|
||||
if (readSize == secSize && NoEndAnchor)
|
||||
{
|
||||
CTag tag;
|
||||
if (tag.Parse(buf, readSize) == S_OK)
|
||||
if (tag.Id == DESC_TYPE_AnchorVolPtr)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CInArchive::Open(IInStream *inStream, CProgressVirt *progress)
|
||||
{
|
||||
_progress = progress;
|
||||
@@ -1000,6 +1039,7 @@ void CInArchive::Clear()
|
||||
IsArc = false;
|
||||
Unsupported = false;
|
||||
UnexpectedEnd = false;
|
||||
NoEndAnchor = false;
|
||||
|
||||
PhySize = 0;
|
||||
FileSize = 0;
|
||||
|
||||
@@ -370,6 +370,7 @@ public:
|
||||
bool IsArc;
|
||||
bool Unsupported;
|
||||
bool UnexpectedEnd;
|
||||
bool NoEndAnchor;
|
||||
|
||||
void UpdatePhySize(UInt64 val)
|
||||
{
|
||||
|
||||
@@ -682,9 +682,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
s += " -> ";
|
||||
const CHandler *p = this;
|
||||
while (p != 0 && p->NeedParent())
|
||||
while (p && p->NeedParent())
|
||||
p = p->Parent;
|
||||
if (p == 0)
|
||||
if (!p)
|
||||
s += '?';
|
||||
else
|
||||
s += p->Footer.GetTypeString();
|
||||
@@ -750,26 +750,24 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback *openArchiveCallback, unsigned level)
|
||||
{
|
||||
Close();
|
||||
Stream = stream;
|
||||
if (level > (1 << 12)) // Maybe we need to increase that limit
|
||||
return S_FALSE;
|
||||
|
||||
RINOK(Open3());
|
||||
|
||||
if (child && memcmp(child->Dyn.ParentId, Footer.Id, 16) != 0)
|
||||
return S_FALSE;
|
||||
if (Footer.Type != kDiskType_Diff)
|
||||
return S_OK;
|
||||
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
|
||||
if (openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback) != S_OK)
|
||||
{
|
||||
// return S_FALSE;
|
||||
}
|
||||
CMyComPtr<IInStream> nextStream;
|
||||
|
||||
bool useRelative;
|
||||
UString name;
|
||||
|
||||
if (!Dyn.RelativeParentNameFromLocator.IsEmpty())
|
||||
{
|
||||
useRelative = true;
|
||||
@@ -780,11 +778,17 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
||||
useRelative = false;
|
||||
name = Dyn.ParentName;
|
||||
}
|
||||
|
||||
Dyn.RelativeNameWasUsed = useRelative;
|
||||
|
||||
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
|
||||
openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
|
||||
|
||||
if (openVolumeCallback)
|
||||
{
|
||||
CMyComPtr<IInStream> nextStream;
|
||||
HRESULT res = openVolumeCallback->GetStream(name, &nextStream);
|
||||
|
||||
if (res == S_FALSE)
|
||||
{
|
||||
if (useRelative && Dyn.ParentName != Dyn.RelativeParentNameFromLocator)
|
||||
@@ -793,19 +797,35 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
||||
if (res == S_OK)
|
||||
Dyn.RelativeNameWasUsed = false;
|
||||
}
|
||||
if (res == S_FALSE)
|
||||
}
|
||||
|
||||
if (res != S_OK && res != S_FALSE)
|
||||
return res;
|
||||
|
||||
if (res == S_FALSE || !nextStream)
|
||||
{
|
||||
UString s;
|
||||
s.SetFromAscii("Missing volume : ");
|
||||
s += name;
|
||||
AddErrorMessage(s);
|
||||
return S_OK;
|
||||
}
|
||||
RINOK(res);
|
||||
|
||||
Parent = new CHandler;
|
||||
ParentStream = Parent;
|
||||
|
||||
res = Parent->Open2(nextStream, this, openArchiveCallback, level + 1);
|
||||
if (res == S_FALSE)
|
||||
|
||||
if (res != S_OK)
|
||||
{
|
||||
Parent = NULL;
|
||||
ParentStream.Release();
|
||||
if (res == E_ABORT)
|
||||
return res;
|
||||
if (res != S_FALSE)
|
||||
{
|
||||
// we must show that error code
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -813,7 +833,7 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
||||
while (p->NeedParent())
|
||||
{
|
||||
p = p->Parent;
|
||||
if (p == 0)
|
||||
if (!p)
|
||||
{
|
||||
AddErrorMessage(L"Can't open parent VHD file:");
|
||||
AddErrorMessage(Dyn.ParentName);
|
||||
@@ -824,12 +844,13 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
void CHandler::CloseAtError()
|
||||
{
|
||||
_phySize = 0;
|
||||
Bat.Clear();
|
||||
NumUsedBlocks = 0;
|
||||
Parent = 0;
|
||||
Parent = NULL;
|
||||
Stream.Release();
|
||||
ParentStream.Release();
|
||||
Dyn.Clear();
|
||||
|
||||
@@ -451,6 +451,8 @@ class CHandler: public CHandlerImg
|
||||
CByteBuffer _descriptorBuf;
|
||||
CDescriptor _descriptor;
|
||||
|
||||
UString _missingVolName;
|
||||
|
||||
void InitAndSeekMain()
|
||||
{
|
||||
_virtPos = 0;
|
||||
@@ -882,6 +884,19 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
|
||||
case kpidNumVolumes: if (_isMultiVol) prop = (UInt32)_extents.Size(); break;
|
||||
|
||||
case kpidError:
|
||||
{
|
||||
if (_missingVol || !_missingVolName.IsEmpty())
|
||||
{
|
||||
UString s;
|
||||
s.SetFromAscii("Missing volume : ");
|
||||
if (!_missingVolName.IsEmpty())
|
||||
s += _missingVolName;
|
||||
prop = s;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidErrorFlags:
|
||||
{
|
||||
UInt32 v = 0;
|
||||
@@ -889,7 +904,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
if (_unsupported) v |= kpv_ErrorFlags_UnsupportedMethod;
|
||||
if (_unsupportedSome) v |= kpv_ErrorFlags_UnsupportedMethod;
|
||||
if (_headerError) v |= kpv_ErrorFlags_HeadersError;
|
||||
if (_missingVol) v |= kpv_ErrorFlags_UnexpectedEnd;
|
||||
// if (_missingVol) v |= kpv_ErrorFlags_UnexpectedEnd;
|
||||
if (v != 0)
|
||||
prop = v;
|
||||
break;
|
||||
@@ -1081,15 +1096,14 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *openCallback)
|
||||
}
|
||||
|
||||
HRESULT result = volumeCallback->GetStream(u, &nextStream);
|
||||
if (result == S_FALSE)
|
||||
{
|
||||
_missingVol = true;
|
||||
continue;
|
||||
}
|
||||
if (result != S_OK)
|
||||
|
||||
if (result != S_OK && result != S_FALSE)
|
||||
return result;
|
||||
if (!nextStream)
|
||||
|
||||
if (!nextStream || result != S_OK)
|
||||
{
|
||||
if (_missingVolName.IsEmpty())
|
||||
_missingVolName = u;
|
||||
_missingVol = true;
|
||||
continue;
|
||||
}
|
||||
@@ -1431,6 +1445,8 @@ STDMETHODIMP CHandler::Close()
|
||||
_isMultiVol = false;
|
||||
_needDeflate = false;
|
||||
|
||||
_missingVolName.Empty();
|
||||
|
||||
_descriptorBuf.Free();
|
||||
_descriptor.Clear();
|
||||
|
||||
|
||||
@@ -1028,6 +1028,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCal
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_firstVolumeIndex = -1;
|
||||
@@ -1093,7 +1094,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
CMyComPtr<ICompressProgressInfo> progress = lps;
|
||||
lps->Init(extractCallback, false);
|
||||
|
||||
for (i = 0; i < numItems;
|
||||
for (i = 0;; i++,
|
||||
currentTotalUnPacked += currentItemUnPacked)
|
||||
{
|
||||
currentItemUnPacked = 0;
|
||||
@@ -1102,14 +1103,18 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
lps->OutSize = currentTotalUnPacked;
|
||||
|
||||
RINOK(lps->SetCur());
|
||||
|
||||
if (i >= numItems)
|
||||
break;
|
||||
|
||||
UInt32 index = allFilesMode ? i : indices[i];
|
||||
i++;
|
||||
Int32 askMode = testMode ?
|
||||
NExtract::NAskMode::kTest :
|
||||
NExtract::NAskMode::kExtract;
|
||||
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||
|
||||
if (index >= _db.SortedItems.Size())
|
||||
{
|
||||
if (!testMode && !realOutStream)
|
||||
@@ -1153,13 +1158,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
continue;
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
Int32 opRes = NExtract::NOperationResult::kOK;
|
||||
|
||||
if (streamIndex != prevSuccessStreamIndex || realOutStream)
|
||||
{
|
||||
Byte digest[kHashSize];
|
||||
const CVolume &vol = _volumes[si.PartNumber];
|
||||
bool needDigest = !si.IsEmptyHash();
|
||||
|
||||
HRESULT res = unpacker.Unpack(vol.Stream, si.Resource, vol.Header, &_db,
|
||||
realOutStream, progress, needDigest ? digest : NULL);
|
||||
|
||||
if (res == S_OK)
|
||||
{
|
||||
if (!needDigest || memcmp(digest, si.Hash, kHashSize) == 0)
|
||||
@@ -1174,13 +1182,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
else
|
||||
return res;
|
||||
}
|
||||
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(opRes));
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _db.SortedItems.Size() +
|
||||
|
||||
@@ -256,6 +256,11 @@ HRESULT CUnpacker::Unpack2(
|
||||
_solidIndex = resource.SolidIndex;
|
||||
_unpackedChunkIndex = chunkIndex;
|
||||
|
||||
if (cur < offsetInChunk)
|
||||
return E_FAIL;
|
||||
|
||||
cur -= offsetInChunk;
|
||||
|
||||
if (cur > rem)
|
||||
cur = (size_t)rem;
|
||||
|
||||
|
||||
@@ -373,6 +373,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
ConvertUInt32ToString(f.AlgId, temp + 1);
|
||||
m += temp;
|
||||
}
|
||||
if (f.CertificateIsUsed())
|
||||
m += "-Cert";
|
||||
}
|
||||
else
|
||||
m += kMethod_StrongCrypto;
|
||||
|
||||
@@ -188,9 +188,9 @@ API_FUNC_IsArc IsArc_Zip(const Byte *p, size_t size)
|
||||
// Crc = Get32(p + 10);
|
||||
// PackSize = Get32(p + 14);
|
||||
// Size = Get32(p + 18);
|
||||
unsigned nameSize = Get16(p + 22);
|
||||
const unsigned nameSize = Get16(p + 22);
|
||||
unsigned extraSize = Get16(p + 24);
|
||||
UInt32 extraOffset = kLocalHeaderSize + (UInt32)nameSize;
|
||||
const UInt32 extraOffset = kLocalHeaderSize + (UInt32)nameSize;
|
||||
if (extraOffset + extraSize > (1 << 16))
|
||||
return k_IsArc_Res_NO;
|
||||
|
||||
@@ -562,13 +562,21 @@ bool CInArchive::ReadLocalItem(CItemEx &item)
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CheckDosTime(item.Time))
|
||||
{
|
||||
HeadersWarning = true;
|
||||
// return false;
|
||||
}
|
||||
|
||||
if (item.Name.Len() != nameSize)
|
||||
{
|
||||
// we support "bad" archives with null-terminated name.
|
||||
if (item.Name.Len() + 1 != nameSize)
|
||||
return false;
|
||||
HeadersWarning = true;
|
||||
}
|
||||
|
||||
return item.LocalFullHeaderSize <= ((UInt32)1 << 16);
|
||||
}
|
||||
|
||||
@@ -782,9 +790,9 @@ HRESULT CInArchive::ReadCdItem(CItemEx &item)
|
||||
item.Crc = Get32(p + 12);
|
||||
item.PackSize = Get32(p + 16);
|
||||
item.Size = Get32(p + 20);
|
||||
unsigned nameSize = Get16(p + 24);
|
||||
UInt16 extraSize = Get16(p + 26);
|
||||
UInt16 commentSize = Get16(p + 28);
|
||||
const unsigned nameSize = Get16(p + 24);
|
||||
const unsigned extraSize = Get16(p + 26);
|
||||
const unsigned commentSize = Get16(p + 28);
|
||||
UInt32 diskNumberStart = Get16(p + 30);
|
||||
item.InternalAttrib = Get16(p + 32);
|
||||
item.ExternalAttrib = Get32(p + 34);
|
||||
@@ -961,7 +969,7 @@ HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UI
|
||||
CItemEx cdItem;
|
||||
RINOK(ReadCdItem(cdItem));
|
||||
items.Add(cdItem);
|
||||
if (progress && items.Size() % 1 == 0)
|
||||
if (progress && (items.Size() & 0xFFF) == 0)
|
||||
RINOK(progress->SetCompletedCD(items.Size()));
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CInArchive::ReadLocals(
|
||||
CObjectVector<CItemEx> &items, CProgressVirt *progress)
|
||||
{
|
||||
@@ -1037,7 +1046,8 @@ HRESULT CInArchive::ReadLocals(
|
||||
return S_FALSE;
|
||||
throw;
|
||||
}
|
||||
if (progress && items.Size() % 1 == 0)
|
||||
|
||||
if (progress && (items.Size() & 0xFF) == 0)
|
||||
RINOK(progress->SetCompletedLocal(items.Size(), item.LocalHeaderPos));
|
||||
}
|
||||
|
||||
@@ -1154,15 +1164,17 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
||||
HeadersError = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
_inBufMode = true;
|
||||
_inBuffer.Init();
|
||||
cdAbsOffset = m_Position - 4;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
CItemEx cdItem;
|
||||
RINOK(ReadCdItem(cdItem));
|
||||
cdItems.Add(cdItem);
|
||||
if (progress && cdItems.Size() % 1 == 0)
|
||||
if (progress && (cdItems.Size() & 0xFFF) == 0)
|
||||
RINOK(progress->SetCompletedCD(items.Size()));
|
||||
m_Signature = ReadUInt32();
|
||||
if (m_Signature != NSignature::kCentralFileHeader)
|
||||
@@ -1183,6 +1195,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
||||
CEcd64 ecd64;
|
||||
bool isZip64 = false;
|
||||
UInt64 ecd64AbsOffset = m_Position - 4;
|
||||
|
||||
if (m_Signature == NSignature::kEcd64)
|
||||
{
|
||||
IsZip64 = isZip64 = true;
|
||||
@@ -1213,6 +1226,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
||||
(!items.IsEmpty())))
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
if (m_Signature == NSignature::kEcd64Locator)
|
||||
{
|
||||
if (!isZip64)
|
||||
@@ -1224,6 +1238,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
||||
return S_FALSE;
|
||||
m_Signature = ReadUInt32();
|
||||
}
|
||||
|
||||
if (m_Signature != NSignature::kEcd)
|
||||
return S_FALSE;
|
||||
|
||||
@@ -1323,6 +1338,7 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items, CProgressVirt *p
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress)
|
||||
{
|
||||
HRESULT res;
|
||||
|
||||
@@ -109,6 +109,8 @@ struct CStrongCryptoExtra
|
||||
Flags = GetUi16(p + 6);
|
||||
return (Format == 2);
|
||||
}
|
||||
|
||||
bool CertificateIsUsed() const { return (Flags > 0x0001); }
|
||||
};
|
||||
|
||||
struct CExtraBlock
|
||||
|
||||
@@ -554,14 +554,6 @@ SOURCE=..\..\Common\CreateCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CWrappers.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -1285,14 +1277,6 @@ SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -77,7 +77,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\FindSignature.obj \
|
||||
$O\HandlerOut.obj \
|
||||
@@ -94,7 +93,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -546,14 +546,6 @@ SOURCE=..\..\Common\CreateCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CWrappers.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -812,14 +804,6 @@ SOURCE=..\..\Compress\LzmaEncoder.h
|
||||
|
||||
SOURCE=..\..\Compress\LzmaRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\RangeCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\RangeCoderBit.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive"
|
||||
|
||||
@@ -865,14 +849,6 @@ SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -67,7 +67,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
@@ -83,7 +82,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -211,122 +211,6 @@ SOURCE=..\..\UI\FileManager\Test.bmp
|
||||
# Begin Group "Archive"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "7z"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zCompressionMode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zDecode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zDecode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zEncode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zEncode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHeader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHeader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zOut.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zProperties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zSpecStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zSpecStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zUpdate.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zUpdate.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
@@ -403,6 +287,114 @@ SOURCE=..\..\Archive\Common\ParseProperties.cpp
|
||||
SOURCE=..\..\Archive\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7z"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zCompressionMode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zDecode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zDecode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zEncode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zEncode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHeader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHeader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zOut.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zProperties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zSpecStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zSpecStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zUpdate.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zUpdate.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\IArchive.h
|
||||
|
||||
@@ -49,7 +49,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
@@ -63,7 +62,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -7,12 +7,12 @@ COMMON_OBJS = \
|
||||
$O\CRC.obj \
|
||||
$O\CrcReg.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\MyString.obj \
|
||||
$O\MyVector.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\Sha256Reg.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
$O\MyVector.obj \
|
||||
$O\Wildcard.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
@@ -42,7 +42,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
@@ -51,7 +50,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zCompressionMode.obj \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHeader.obj \
|
||||
$O\7zIn.obj \
|
||||
|
||||
@@ -42,7 +42,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
@@ -53,7 +52,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zCompressionMode.obj \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHeader.obj \
|
||||
$O\7zIn.obj \
|
||||
|
||||
@@ -93,7 +93,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\FindSignature.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
@@ -111,7 +110,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -47,7 +47,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
@@ -61,7 +60,6 @@ AR_COMMON_OBJS = \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
|
||||
@@ -18,7 +18,6 @@ FILE_IO =FileIO
|
||||
FILE_IO_2 =Windows/$(FILE_IO)
|
||||
|
||||
MT_FILES = \
|
||||
System.o \
|
||||
LzFindMt.o \
|
||||
Threads.o \
|
||||
|
||||
@@ -60,6 +59,7 @@ OBJS = \
|
||||
StringConvert.o \
|
||||
StringToInt.o \
|
||||
PropVariant.o \
|
||||
System.o \
|
||||
7zCrc.o \
|
||||
7zCrcOpt.o \
|
||||
Alloc.o \
|
||||
@@ -150,10 +150,8 @@ StringToInt.o: ../../../Common/StringToInt.cpp
|
||||
PropVariant.o: ../../../Windows/PropVariant.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Windows/PropVariant.cpp
|
||||
|
||||
ifdef MT_FILES
|
||||
System.o: ../../../Windows/System.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Windows/System.cpp
|
||||
endif
|
||||
|
||||
7zCrc.o: ../../../../C/7zCrc.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
|
||||
@@ -195,4 +193,3 @@ Lzma86Enc.o: ../../../../C/Lzma86Enc.c
|
||||
|
||||
clean:
|
||||
-$(RM) $(PROG) $(OBJS)
|
||||
|
||||
|
||||
@@ -117,14 +117,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -221,14 +213,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -72,7 +72,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
@@ -81,7 +80,6 @@ AR_COMMON_OBJS = \
|
||||
7Z_OBJS = \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zIn.obj \
|
||||
$O\7zRegister.obj \
|
||||
|
||||
@@ -157,14 +157,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -205,14 +197,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -67,14 +67,12 @@ FM_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zIn.obj \
|
||||
$O\7zRegister.obj \
|
||||
|
||||
@@ -149,14 +149,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zFolderOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\7z\7zHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -197,14 +189,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -92,7 +92,6 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
@@ -100,7 +99,6 @@ AR_COMMON_OBJS = \
|
||||
7Z_OBJS = \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zIn.obj \
|
||||
$O\7zRegister.obj \
|
||||
|
||||
@@ -73,8 +73,10 @@ void CRandomGenerator::Init()
|
||||
HASH_UPD(v2);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
DWORD tickCount = ::GetTickCount();
|
||||
HASH_UPD(tickCount);
|
||||
#endif
|
||||
|
||||
for (unsigned j = 0; j < 100; j++)
|
||||
{
|
||||
|
||||
@@ -112,25 +112,87 @@ HRESULT CDecoder::Init_and_CheckPassword(bool &passwOK)
|
||||
if (algId * 64 + 128 != bitLen)
|
||||
return E_NOTIMPL;
|
||||
_key.KeySize = 16 + algId * 8;
|
||||
if ((flags & 1) == 0)
|
||||
return E_NOTIMPL;
|
||||
bool cert = ((flags & 2) != 0);
|
||||
|
||||
if ((flags & 0x4000) != 0)
|
||||
{
|
||||
// Use 3DES
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (cert)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((flags & 1) == 0)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
UInt32 rdSize = GetUi16(p + 8);
|
||||
if ((rdSize & 0xF) != 0 || rdSize + 16 > _remSize)
|
||||
return E_NOTIMPL;
|
||||
memmove(p, p + 10, rdSize);
|
||||
Byte *validData = p + rdSize + 16;
|
||||
if (GetUi32(validData - 6) != 0) // reserved
|
||||
return E_NOTIMPL;
|
||||
UInt32 validSize = GetUi16(validData - 2);
|
||||
if ((validSize & 0xF) != 0 || 16 + rdSize + validSize != _remSize)
|
||||
|
||||
if (rdSize + 16 > _remSize)
|
||||
return E_NOTIMPL;
|
||||
|
||||
/*
|
||||
if (cert)
|
||||
{
|
||||
// how to filter rd, if ((rdSize & 0xF) != 0) ?
|
||||
/*
|
||||
if ((rdSize & 0x7) != 0)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
if ((rdSize & 0xF) != 0)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
memmove(p, p + 10, rdSize);
|
||||
const Byte *p2 = p + rdSize + 10;
|
||||
UInt32 reserved = GetUi32(p2);
|
||||
p2 += 4;
|
||||
|
||||
/*
|
||||
if (cert)
|
||||
{
|
||||
UInt32 numRecipients = reserved;
|
||||
|
||||
if (numRecipients == 0)
|
||||
return E_NOTIMPL;
|
||||
|
||||
{
|
||||
UInt32 hashAlg = GetUi16(p2);
|
||||
hashAlg = hashAlg;
|
||||
UInt32 hashSize = GetUi16(p2 + 2);
|
||||
hashSize = hashSize;
|
||||
p2 += 4;
|
||||
|
||||
reserved = reserved;
|
||||
// return E_NOTIMPL;
|
||||
|
||||
for (unsigned r = 0; r < numRecipients; r++)
|
||||
{
|
||||
UInt32 specSize = GetUi16(p2);
|
||||
p2 += 2;
|
||||
p2 += specSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
if (reserved != 0)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
UInt32 validSize = GetUi16(p2);
|
||||
p2 += 2;
|
||||
const size_t validOffset = p2 - p;
|
||||
if ((validSize & 0xF) != 0 || validOffset + validSize != _remSize)
|
||||
return E_NOTIMPL;
|
||||
|
||||
{
|
||||
RINOK(SetKey(_key.MasterKey, _key.KeySize));
|
||||
@@ -149,12 +211,14 @@ HRESULT CDecoder::Init_and_CheckPassword(bool &passwOK)
|
||||
RINOK(SetKey(fileKey, _key.KeySize));
|
||||
RINOK(SetInitVector(_iv, 16));
|
||||
Init();
|
||||
Filter(validData, validSize);
|
||||
|
||||
memmove(p, p + validOffset, validSize);
|
||||
Filter(p, validSize);
|
||||
|
||||
if (validSize < 4)
|
||||
return E_NOTIMPL;
|
||||
validSize -= 4;
|
||||
if (GetUi32(validData + validSize) != CrcCalc(validData, validSize))
|
||||
if (GetUi32(p + validSize) != CrcCalc(p, validSize))
|
||||
return S_OK;
|
||||
passwOK = true;
|
||||
return S_OK;
|
||||
|
||||
@@ -248,7 +248,8 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
|
||||
unsigned len = 0;
|
||||
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)
|
||||
{
|
||||
const void *p;
|
||||
|
||||
@@ -693,7 +693,7 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef
|
||||
return StringToBstr(Password, password);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Main function
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION PrintError("Unsupported Windows version"); return 1;
|
||||
@@ -709,12 +709,14 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
PrintStringLn(kHelpString);
|
||||
return 1;
|
||||
}
|
||||
|
||||
NDLL::CLibrary lib;
|
||||
if (!lib.Load(NDLL::GetModuleDirPrefix() + FTEXT(kDllName)))
|
||||
{
|
||||
PrintError("Can not load 7-zip library");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Func_CreateObject createObjectFunc = (Func_CreateObject)lib.GetProc("CreateObject");
|
||||
if (!createObjectFunc)
|
||||
{
|
||||
@@ -732,7 +734,9 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
}
|
||||
c = (char)MyCharLower_Ascii(command[0]);
|
||||
}
|
||||
|
||||
FString archiveName = CmdStringToFString(args[2]);
|
||||
|
||||
if (c == 'a')
|
||||
{
|
||||
// create archive command
|
||||
@@ -766,6 +770,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
dirItems.Add(di);
|
||||
}
|
||||
}
|
||||
|
||||
COutFileStream *outFileStreamSpec = new COutFileStream;
|
||||
CMyComPtr<IOutStream> outFileStream = outFileStreamSpec;
|
||||
if (!outFileStreamSpec->Create(archiveName, false))
|
||||
@@ -812,17 +817,21 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
*/
|
||||
|
||||
HRESULT result = outArchive->UpdateItems(outFileStream, dirItems.Size(), updateCallback);
|
||||
|
||||
updateCallbackSpec->Finilize();
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
PrintError("Update Error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
FOR_VECTOR (i, updateCallbackSpec->FailedFiles)
|
||||
{
|
||||
PrintNewLine();
|
||||
PrintError("Error for file", updateCallbackSpec->FailedFiles[i]);
|
||||
}
|
||||
|
||||
if (updateCallbackSpec->FailedFiles.Size() != 0)
|
||||
return 1;
|
||||
}
|
||||
@@ -835,6 +844,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
}
|
||||
|
||||
bool listCommand;
|
||||
|
||||
if (c == 'l')
|
||||
listCommand = true;
|
||||
else if (c == 'x')
|
||||
@@ -913,7 +923,27 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
extractCallbackSpec->PasswordIsDefined = false;
|
||||
// extractCallbackSpec->PasswordIsDefined = true;
|
||||
// extractCallbackSpec->Password = L"1";
|
||||
|
||||
/*
|
||||
const wchar_t *names[] =
|
||||
{
|
||||
L"mt",
|
||||
L"mtf"
|
||||
};
|
||||
const unsigned kNumProps = sizeof(names) / sizeof(names[0]);
|
||||
NCOM::CPropVariant values[kNumProps] =
|
||||
{
|
||||
(UInt32)1,
|
||||
false
|
||||
};
|
||||
CMyComPtr<ISetProperties> setProperties;
|
||||
archive->QueryInterface(IID_ISetProperties, (void **)&setProperties);
|
||||
if (setProperties)
|
||||
setProperties->SetProperties(names, values, kNumProps);
|
||||
*/
|
||||
|
||||
HRESULT result = archive->Extract(NULL, (UInt32)(Int32)(-1), false, extractCallback);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
PrintError("Extract Error");
|
||||
@@ -921,5 +951,6 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ static const unsigned kCommandIndex = 0;
|
||||
static const char *kCannotFindListFile = "Cannot find listfile";
|
||||
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 *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 *kCannotFindArchive = "Cannot find archive";
|
||||
|
||||
@@ -1219,8 +1219,26 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
|
||||
|
||||
if (isExtractGroupCommand)
|
||||
{
|
||||
if (options.StdOutMode && options.IsStdOutTerminal && options.IsStdErrTerminal)
|
||||
if (options.StdOutMode)
|
||||
{
|
||||
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)
|
||||
{
|
||||
eo.OutputDir = us2fs(parser[NKey::kOutputDir].PostStrings[0]);
|
||||
@@ -1293,8 +1311,18 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
|
||||
|
||||
if (updateOptions.StdOutMode && updateOptions.EMailMode)
|
||||
throw CArcCmdLineException("stdout mode and email mode cannot be combined");
|
||||
if (updateOptions.StdOutMode && options.IsStdOutTerminal)
|
||||
|
||||
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)
|
||||
updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();
|
||||
|
||||
|
||||
@@ -451,32 +451,42 @@ static UString GetDirPrefixOf(const UString &src)
|
||||
return s;
|
||||
}
|
||||
|
||||
static bool IsSafePath(const UString &path)
|
||||
#endif
|
||||
|
||||
|
||||
bool IsSafePath(const UString &path)
|
||||
{
|
||||
if (NName::IsAbsolutePath(path))
|
||||
return false;
|
||||
|
||||
UStringVector parts;
|
||||
SplitPathToParts(path, parts);
|
||||
int level = 0;
|
||||
unsigned level = 0;
|
||||
|
||||
FOR_VECTOR (i, parts)
|
||||
{
|
||||
const UString &s = parts[i];
|
||||
if (s.IsEmpty())
|
||||
{
|
||||
if (i == 0)
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
if (s == L".")
|
||||
continue;
|
||||
if (s == L"..")
|
||||
{
|
||||
if (level <= 0)
|
||||
if (level == 0)
|
||||
return false;
|
||||
level--;
|
||||
}
|
||||
else
|
||||
level++;
|
||||
}
|
||||
|
||||
return level > 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*inStream = NULL;
|
||||
|
||||
if (_subArchiveMode)
|
||||
return S_FALSE;
|
||||
if (Callback)
|
||||
{
|
||||
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;
|
||||
if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name), fullPath))
|
||||
if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name2), fullPath))
|
||||
return S_FALSE;
|
||||
if (!_fileInfo.Find(fullPath))
|
||||
return S_FALSE;
|
||||
@@ -93,10 +115,15 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre
|
||||
CInFileStreamVol *inFile = new CInFileStreamVol;
|
||||
CMyComPtr<IInStream> inStreamTemp = inFile;
|
||||
if (!inFile->Open(fullPath))
|
||||
return ::GetLastError();
|
||||
{
|
||||
DWORD lastError = ::GetLastError();
|
||||
if (lastError == 0)
|
||||
return E_FAIL;
|
||||
return HRESULT_FROM_WIN32(lastError);
|
||||
}
|
||||
|
||||
FileSizes.Add(_fileInfo.Size);
|
||||
FileNames.Add(name);
|
||||
FileNames.Add(name2);
|
||||
inFile->FileNameIndex = FileNames_WasUsed.Add(true);
|
||||
inFile->OpenCallbackImp = 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 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
|
||||
{
|
||||
|
||||
@@ -142,15 +142,17 @@ void ConvertPropertyToShortString(char *dest, const PROPVARIANT &prop, PROPID pr
|
||||
case kpidVa:
|
||||
{
|
||||
UInt64 v = 0;
|
||||
if (ConvertPropVariantToUInt64(prop, v))
|
||||
{
|
||||
if (prop.vt == VT_UI4)
|
||||
v = prop.ulVal;
|
||||
else if (prop.vt == VT_UI8)
|
||||
v = (UInt64)prop.uhVal.QuadPart;
|
||||
else
|
||||
break;
|
||||
dest[0] = '0';
|
||||
dest[1] = 'x';
|
||||
ConvertUInt64ToHex(prop.ulVal, dest + 2);
|
||||
ConvertUInt64ToHex(v, dest + 2);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ConvertPropVariantToShortString(prop, dest);
|
||||
|
||||
@@ -14,8 +14,10 @@ static int CompareStrings(const unsigned *p1, const unsigned *p2, void *param)
|
||||
|
||||
void SortFileNames(const UStringVector &strings, CUIntVector &indices)
|
||||
{
|
||||
unsigned numItems = strings.Size();
|
||||
const unsigned numItems = strings.Size();
|
||||
indices.ClearAndSetSize(numItems);
|
||||
if (numItems == 0)
|
||||
return;
|
||||
unsigned *vals = &indices[0];
|
||||
for (unsigned i = 0; i < numItems; i++)
|
||||
vals[i] = i;
|
||||
|
||||
@@ -17,5 +17,3 @@ void CTempFiles::Clear()
|
||||
Paths.DeleteBack();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "../../../Windows/FileDir.h"
|
||||
#include "../../../Windows/FileName.h"
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
|
||||
#include "../../Common/StreamObjects.h"
|
||||
|
||||
@@ -429,7 +428,9 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
static NSynchronization::CCriticalSection CS;
|
||||
#endif
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStream **inStream, UInt32 mode)
|
||||
{
|
||||
@@ -536,7 +537,9 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea
|
||||
|
||||
if (ProcessedItemsStatuses)
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
NSynchronization::CCriticalSectionLock lock(CS);
|
||||
#endif
|
||||
ProcessedItemsStatuses[(unsigned)up.DirIndex] = 1;
|
||||
}
|
||||
*inStream = inStreamLoc.Detach();
|
||||
@@ -754,4 +757,3 @@ void CArchiveUpdateCallback::InFileStream_On_Destroy(UINT_PTR val)
|
||||
}
|
||||
throw 20141125;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ void GetUpdatePairInfoList(
|
||||
|
||||
{
|
||||
arcIndices.ClearAndSetSize(numArcItems);
|
||||
if (numArcItems != 0)
|
||||
{
|
||||
unsigned *vals = &arcIndices[0];
|
||||
for (unsigned i = 0; i < numArcItems; i++)
|
||||
|
||||
@@ -17,7 +17,7 @@ FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FStr
|
||||
{
|
||||
NWorkDir::NMode::EEnum mode = workDirInfo.Mode;
|
||||
|
||||
#ifndef UNDER_CE
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
if (workDirInfo.ForRemovableOnly)
|
||||
{
|
||||
mode = NWorkDir::NMode::kCurrent;
|
||||
|
||||
@@ -33,3 +33,4 @@ UI_COMMON_OBJS = \
|
||||
$O\UpdatePair.obj \
|
||||
$O\UpdateProduce.obj \
|
||||
|
||||
#
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Psapi.h>
|
||||
#endif
|
||||
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES)
|
||||
#if defined( _7ZIP_LARGE_PAGES)
|
||||
#include "../../../../C/Alloc.h"
|
||||
#endif
|
||||
|
||||
@@ -158,7 +160,7 @@ static const char *kHelpString =
|
||||
" -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options\n"
|
||||
" -v{Size}[b|k|m|g] : Create volumes\n"
|
||||
" -w[{path}] : assign Work directory. Empty path means a temporary directory\n"
|
||||
" -x[r[-|0]]]{@listfile|!wildcard} : eXclude filenames\n"
|
||||
" -x[r[-|0]]{@listfile|!wildcard} : eXclude filenames\n"
|
||||
" -y : assume Yes on all queries\n";
|
||||
|
||||
// ---------------------------
|
||||
@@ -470,7 +472,7 @@ static void PrintHexId(CStdOutStream &so, UInt64 id)
|
||||
|
||||
int Main2(
|
||||
#ifndef _WIN32
|
||||
int numArgs, const char *args[]
|
||||
int numArgs, char *args[]
|
||||
#endif
|
||||
)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ CStdOutStream *g_ErrStream = NULL;
|
||||
|
||||
extern int Main2(
|
||||
#ifndef _WIN32
|
||||
int numArgs, const char *args[]
|
||||
int numArgs, char *args[]
|
||||
#endif
|
||||
);
|
||||
|
||||
@@ -49,7 +49,7 @@ static void PrintError(const char *message)
|
||||
int MY_CDECL main
|
||||
(
|
||||
#ifndef _WIN32
|
||||
int numArgs, const char *args[]
|
||||
int numArgs, char *args[]
|
||||
#endif
|
||||
)
|
||||
{
|
||||
|
||||
@@ -3,11 +3,6 @@
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
// #define _CRT_SECURE_NO_DEPRECATE
|
||||
// #include <windows.h>
|
||||
// #include <stdio.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ using namespace NFind;
|
||||
|
||||
#define MENU_HEIGHT 26
|
||||
|
||||
bool g_RAM_Size_Defined;
|
||||
UInt64 g_RAM_Size;
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -425,7 +426,7 @@ static void ErrorMessage(const wchar_t *s)
|
||||
|
||||
static int WINAPI WinMain2(int nCmdShow)
|
||||
{
|
||||
g_RAM_Size = NSystem::GetRamSize();
|
||||
g_RAM_Size_Defined = NSystem::GetRamSize(g_RAM_Size);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
|
||||
@@ -69,31 +69,67 @@ struct CPanelCallback
|
||||
|
||||
void PanelCopyItems();
|
||||
|
||||
struct CItemProperty
|
||||
|
||||
struct CPropColumn
|
||||
{
|
||||
UString Name;
|
||||
int Order;
|
||||
PROPID ID;
|
||||
VARTYPE Type;
|
||||
int Order;
|
||||
bool IsVisible;
|
||||
bool IsRawProp;
|
||||
UInt32 Width;
|
||||
UString Name;
|
||||
|
||||
int Compare(const CItemProperty &a) const { return MyCompare(Order, a.Order); }
|
||||
bool IsEqualTo(const CPropColumn &a) const
|
||||
{
|
||||
return Order == a.Order
|
||||
&& ID == a.ID
|
||||
&& Type == a.Type
|
||||
&& IsVisible == a.IsVisible
|
||||
&& IsRawProp == a.IsRawProp
|
||||
&& Width == a.Width
|
||||
&& Name == a.Name;
|
||||
}
|
||||
|
||||
int Compare(const CPropColumn &a) const { return MyCompare(Order, a.Order); }
|
||||
|
||||
int Compare_NameFirst(const CPropColumn &a) const
|
||||
{
|
||||
if (ID == kpidName)
|
||||
{
|
||||
if (a.ID != kpidName)
|
||||
return -1;
|
||||
}
|
||||
else if (a.ID == kpidName)
|
||||
return 1;
|
||||
return MyCompare(Order, a.Order);
|
||||
}
|
||||
};
|
||||
|
||||
class CItemProperties: public CObjectVector<CItemProperty>
|
||||
|
||||
class CPropColumns: public CObjectVector<CPropColumn>
|
||||
{
|
||||
public:
|
||||
int FindItemWithID(PROPID id)
|
||||
int FindItem_for_PropID(PROPID id) const
|
||||
{
|
||||
FOR_VECTOR (i, (*this))
|
||||
if ((*this)[i].ID == id)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool IsEqualTo(const CPropColumns &props) const
|
||||
{
|
||||
if (Size() != props.Size())
|
||||
return false;
|
||||
FOR_VECTOR (i, (*this))
|
||||
if (!(*this)[i].IsEqualTo(props[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct CTempFileInfo
|
||||
{
|
||||
UInt32 FileIndex; // index of file in folder
|
||||
@@ -284,8 +320,8 @@ private:
|
||||
void ChangeWindowSize(int xSize, int ySize);
|
||||
|
||||
HRESULT InitColumns();
|
||||
// void InitColumns2(PROPID sortID);
|
||||
void InsertColumn(unsigned index);
|
||||
void DeleteColumn(unsigned index);
|
||||
void AddColumn(const CPropColumn &prop);
|
||||
|
||||
void SetFocusedSelectedItem(int index, bool select);
|
||||
HRESULT RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
|
||||
@@ -446,7 +482,6 @@ public:
|
||||
void SetFocusToLastRememberedItem();
|
||||
|
||||
|
||||
void ReadListViewInfo();
|
||||
void SaveListViewInfo();
|
||||
|
||||
CPanel() :
|
||||
@@ -484,8 +519,9 @@ public:
|
||||
bool _needSaveInfo;
|
||||
UString _typeIDString;
|
||||
CListViewInfo _listViewInfo;
|
||||
CItemProperties _properties;
|
||||
CItemProperties _visibleProperties;
|
||||
|
||||
CPropColumns _columns;
|
||||
CPropColumns _visibleColumns;
|
||||
|
||||
PROPID _sortID;
|
||||
// int _sortIndex;
|
||||
@@ -698,15 +734,26 @@ public:
|
||||
|
||||
void OpenFolder(int index);
|
||||
HRESULT OpenParentArchiveFolder();
|
||||
HRESULT OpenItemAsArchive(IInStream *inStream,
|
||||
|
||||
HRESULT OpenAsArc(IInStream *inStream,
|
||||
const CTempFileInfo &tempFileInfo,
|
||||
const UString &virtualFilePath,
|
||||
const UString &arcFormat,
|
||||
bool &encrypted);
|
||||
HRESULT OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted);
|
||||
HRESULT OpenItemAsArchive(int index, const wchar_t *type = NULL);
|
||||
|
||||
HRESULT OpenAsArc_Msg(IInStream *inStream,
|
||||
const CTempFileInfo &tempFileInfo,
|
||||
const UString &virtualFilePath,
|
||||
const UString &arcFormat,
|
||||
bool &encrypted,
|
||||
bool showErrorMessage);
|
||||
|
||||
HRESULT OpenAsArc_Name(const UString &relPath, const UString &arcFormat, bool &encrypted, bool showErrorMessage);
|
||||
HRESULT OpenAsArc_Index(int index, const wchar_t *type /* = NULL */, bool showErrorMessage);
|
||||
|
||||
void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
|
||||
bool editMode, bool useEditor, const wchar_t *type = NULL);
|
||||
|
||||
HRESULT OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, bool usePassword, const UString &password);
|
||||
LRESULT OnOpenItemChanged(LPARAM lParam);
|
||||
|
||||
|
||||
@@ -183,13 +183,13 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
FString dirPrefix, fileName;
|
||||
NDir::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
|
||||
HRESULT res;
|
||||
// = OpenItemAsArchive(fs2us(fileName), arcFormat, encrypted);
|
||||
// = OpenAsArc(fs2us(fileName), arcFormat, encrypted);
|
||||
{
|
||||
CTempFileInfo tfi;
|
||||
tfi.RelPath = fs2us(fileName);
|
||||
tfi.FolderPath = dirPrefix;
|
||||
tfi.FilePath = us2fs(sysPath);
|
||||
res = OpenItemAsArchive(NULL, tfi, sysPath, arcFormat, encrypted);
|
||||
res = OpenAsArc(NULL, tfi, sysPath, arcFormat, encrypted);
|
||||
}
|
||||
|
||||
if (res == S_FALSE)
|
||||
@@ -204,6 +204,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
path.Delete(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (newFolder)
|
||||
{
|
||||
SetNewFolder(newFolder);
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "RegistryUtils.h"
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
#include "../GUI/ExtractRes.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
using namespace NWindows;
|
||||
@@ -34,6 +36,7 @@ using namespace NSynchronization;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
|
||||
extern bool g_RAM_Size_Defined;
|
||||
extern UInt64 g_RAM_Size;
|
||||
|
||||
#ifndef _UNICODE
|
||||
@@ -182,7 +185,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
|
||||
|
||||
HRESULT CPanel::OpenAsArc(IInStream *inStream,
|
||||
const CTempFileInfo &tempFileInfo,
|
||||
const UString &virtualFilePath,
|
||||
const UString &arcFormat,
|
||||
@@ -191,6 +195,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
|
||||
encrypted = false;
|
||||
CFolderLink folderLink;
|
||||
(CTempFileInfo &)folderLink = tempFileInfo;
|
||||
|
||||
if (inStream)
|
||||
folderLink.IsVirtual = true;
|
||||
else
|
||||
@@ -224,6 +229,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
|
||||
folderLink.ParentFolderPath = GetFolderPath(_folder);
|
||||
else
|
||||
folderLink.ParentFolderPath = _currentFolderPrefix;
|
||||
|
||||
if (!_parentFolders.IsEmpty())
|
||||
folderLink.ParentFolder = _folder;
|
||||
|
||||
@@ -240,6 +246,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
|
||||
CMyComPtr<IGetFolderArcProps> getFolderArcProps;
|
||||
_folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
|
||||
_thereAreDeletedItems = false;
|
||||
|
||||
if (getFolderArcProps)
|
||||
{
|
||||
CMyComPtr<IFolderArcProps> arcProps;
|
||||
@@ -304,22 +311,58 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CPanel::OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted)
|
||||
|
||||
HRESULT CPanel::OpenAsArc_Msg(IInStream *inStream,
|
||||
const CTempFileInfo &tempFileInfo,
|
||||
const UString &virtualFilePath,
|
||||
const UString &arcFormat,
|
||||
bool &encrypted,
|
||||
bool showErrorMessage)
|
||||
{
|
||||
HRESULT res = OpenAsArc(inStream, tempFileInfo, virtualFilePath, arcFormat, encrypted);
|
||||
|
||||
if (res == S_OK)
|
||||
return res;
|
||||
if (res == E_ABORT)
|
||||
return res;
|
||||
|
||||
if (showErrorMessage && encrypted)
|
||||
{
|
||||
UString message = L"Error";
|
||||
if (res == S_FALSE)
|
||||
{
|
||||
message = MyFormatNew(
|
||||
encrypted ?
|
||||
IDS_CANT_OPEN_ENCRYPTED_ARCHIVE :
|
||||
IDS_CANT_OPEN_ARCHIVE,
|
||||
virtualFilePath);
|
||||
}
|
||||
else
|
||||
message = HResultToMessage(res);
|
||||
MessageBoxMyError(message);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CPanel::OpenAsArc_Name(const UString &relPath, const UString &arcFormat, bool &encrypted, bool showErrorMessage)
|
||||
{
|
||||
CTempFileInfo tfi;
|
||||
tfi.RelPath = relPath;
|
||||
tfi.FolderPath = us2fs(GetFsPath());
|
||||
const UString fullPath = GetFsPath() + relPath;
|
||||
tfi.FilePath = us2fs(fullPath);
|
||||
return OpenItemAsArchive(NULL, tfi, fullPath, arcFormat, encrypted);
|
||||
return OpenAsArc_Msg(NULL, tfi, fullPath, arcFormat, encrypted, showErrorMessage);
|
||||
}
|
||||
|
||||
HRESULT CPanel::OpenItemAsArchive(int index, const wchar_t *type)
|
||||
|
||||
HRESULT CPanel::OpenAsArc_Index(int index, const wchar_t *type, bool showErrorMessage)
|
||||
{
|
||||
CDisableTimerProcessing disableTimerProcessing1(*this);
|
||||
CDisableNotify disableNotify(*this);
|
||||
bool encrypted;
|
||||
HRESULT res = OpenItemAsArchive(GetItemRelPath2(index), type ? type : L"", encrypted);
|
||||
HRESULT res = OpenAsArc_Name(GetItemRelPath2(index), type ? type : L"", encrypted, showErrorMessage);
|
||||
if (res != S_OK)
|
||||
{
|
||||
RefreshTitle(true); // in case of error we must refresh changed title of 7zFM
|
||||
@@ -329,6 +372,7 @@ HRESULT CPanel::OpenItemAsArchive(int index, const wchar_t *type)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CPanel::OpenParentArchiveFolder()
|
||||
{
|
||||
CDisableTimerProcessing disableTimerProcessing(*this);
|
||||
@@ -359,6 +403,7 @@ HRESULT CPanel::OpenParentArchiveFolder()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static const char *kStartExtensions =
|
||||
#ifdef UNDER_CE
|
||||
" cab"
|
||||
@@ -668,6 +713,7 @@ bool CPanel::IsVirus_Message(const UString &name)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar_t *type)
|
||||
{
|
||||
CDisableTimerProcessing disableTimerProcessing(*this);
|
||||
@@ -689,7 +735,7 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar
|
||||
if (tryInternal)
|
||||
if (!tryExternal || !DoItemAlwaysStart(name))
|
||||
{
|
||||
HRESULT res = OpenItemAsArchive(index, type);
|
||||
HRESULT res = OpenAsArc_Index(index, type, true);
|
||||
disableNotify.Restore(); // we must restore to allow text notification update
|
||||
InvalidateList();
|
||||
if (res == S_OK || res == E_ABORT)
|
||||
@@ -1069,22 +1115,18 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
if (subStream)
|
||||
{
|
||||
bool encrypted;
|
||||
HRESULT res = OpenItemAsArchive(subStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted);
|
||||
HRESULT res = OpenAsArc_Msg(subStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true);
|
||||
if (res == S_OK)
|
||||
{
|
||||
tempDirectory.DisableDeleting();
|
||||
RefreshListCtrl();
|
||||
return;
|
||||
}
|
||||
if (res == E_ABORT)
|
||||
if (res == E_ABORT || res != S_FALSE)
|
||||
return;
|
||||
if (res != S_FALSE)
|
||||
{
|
||||
// probably we must show some message here
|
||||
// return;
|
||||
}
|
||||
if (!tryExternal)
|
||||
return;
|
||||
tryAsArchive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1132,7 +1174,10 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
_folder->GetProperty(index, kpidSize, &prop);
|
||||
UInt64 fileLimit = g_RAM_Size / 4;
|
||||
UInt64 fileLimit = 1 << 22;
|
||||
if (g_RAM_Size_Defined)
|
||||
fileLimit = g_RAM_Size / 4;
|
||||
|
||||
UInt64 fileSize = 0;
|
||||
if (!ConvertPropVariantToUInt64(prop, fileSize))
|
||||
fileSize = fileLimit;
|
||||
@@ -1183,12 +1228,21 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
CMyComPtr<IInStream> bufInStream = bufInStreamSpec;
|
||||
bufInStreamSpec->Init(file.Data, streamSize, virtFileSystem);
|
||||
bool encrypted;
|
||||
if (OpenItemAsArchive(bufInStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted) == S_OK)
|
||||
|
||||
HRESULT res = OpenAsArc_Msg(bufInStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true);
|
||||
if (res == S_OK)
|
||||
{
|
||||
tempDirectory.DisableDeleting();
|
||||
RefreshListCtrl();
|
||||
return;
|
||||
}
|
||||
|
||||
if (res == E_ABORT || res != S_FALSE)
|
||||
return;
|
||||
if (!tryExternal)
|
||||
return;
|
||||
|
||||
tryAsArchive = false;
|
||||
if (virtFileSystemSpec->FlushToDisk(true) != S_OK)
|
||||
return;
|
||||
}
|
||||
@@ -1209,14 +1263,20 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
if (tryAsArchive)
|
||||
{
|
||||
bool encrypted;
|
||||
if (OpenItemAsArchive(NULL, tempFileInfo, fullVirtPath, type ? type : L"", encrypted) == S_OK)
|
||||
HRESULT res = OpenAsArc_Msg(NULL, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true);
|
||||
if (res == S_OK)
|
||||
{
|
||||
tempDirectory.DisableDeleting();
|
||||
RefreshListCtrl();
|
||||
return;
|
||||
}
|
||||
if (res == E_ABORT || res != S_FALSE)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tryExternal)
|
||||
return;
|
||||
|
||||
CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo());
|
||||
CTmpProcessInfo *tpi = tmpProcessInfoPtr.get();
|
||||
tpi->FolderPath = tempDir;
|
||||
@@ -1230,9 +1290,6 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
|
||||
CTmpProcessInfoRelease tmpProcessInfoRelease(*tpi);
|
||||
|
||||
if (!tryExternal)
|
||||
return;
|
||||
|
||||
CProcess process;
|
||||
// HRESULT res;
|
||||
if (editMode)
|
||||
|
||||
@@ -82,15 +82,33 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int ItemProperty_Compare_NameFirst(void *const *a1, void *const *a2, void * /* param */)
|
||||
{
|
||||
return (*(*((const CPropColumn **)a1))).Compare_NameFirst(*(*((const CPropColumn **)a2)));
|
||||
}
|
||||
|
||||
HRESULT CPanel::InitColumns()
|
||||
{
|
||||
if (_needSaveInfo)
|
||||
SaveListViewInfo();
|
||||
|
||||
_listView.DeleteAllItems();
|
||||
_selectedStatusVector.Clear();
|
||||
|
||||
ReadListViewInfo();
|
||||
{
|
||||
// ReadListViewInfo();
|
||||
const UString oldType = _typeIDString;
|
||||
_typeIDString = GetFolderTypeID();
|
||||
// an empty _typeIDString is allowed.
|
||||
|
||||
// we read registry only for new FolderTypeID
|
||||
if (!_needSaveInfo || _typeIDString != oldType)
|
||||
_listViewInfo.Read(_typeIDString);
|
||||
|
||||
// folders with same FolderTypeID can have different columns
|
||||
// so we still read columns for that case.
|
||||
// if (_needSaveInfo && _typeIDString == oldType) return S_OK;
|
||||
}
|
||||
|
||||
// PROPID sortID;
|
||||
/*
|
||||
@@ -101,9 +119,8 @@ HRESULT CPanel::InitColumns()
|
||||
|
||||
_ascending = _listViewInfo.Ascending;
|
||||
|
||||
_properties.Clear();
|
||||
_columns.Clear();
|
||||
|
||||
_needSaveInfo = true;
|
||||
bool isFsFolder = IsFSFolder() || IsAltStreamsFolder();
|
||||
|
||||
{
|
||||
@@ -125,7 +142,7 @@ HRESULT CPanel::InitColumns()
|
||||
}
|
||||
if (propID == kpidIsDir)
|
||||
continue;
|
||||
CItemProperty prop;
|
||||
CPropColumn prop;
|
||||
prop.Type = varType;
|
||||
prop.ID = propID;
|
||||
prop.Name = GetNameOfProperty(propID, name);
|
||||
@@ -133,7 +150,7 @@ HRESULT CPanel::InitColumns()
|
||||
prop.IsVisible = GetColumnVisible(propID, isFsFolder);
|
||||
prop.Width = GetColumnWidth(propID, varType);
|
||||
prop.IsRawProp = false;
|
||||
_properties.Add(prop);
|
||||
_columns.Add(prop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,13 +158,15 @@ HRESULT CPanel::InitColumns()
|
||||
{
|
||||
UInt32 numProps;
|
||||
_folderRawProps->GetNumRawProps(&numProps);
|
||||
|
||||
for (UInt32 i = 0; i < numProps; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
RINOK(_folderRawProps->GetRawPropInfo(i, &name, &propID));
|
||||
|
||||
CItemProperty prop;
|
||||
HRESULT res = _folderRawProps->GetRawPropInfo(i, &name, &propID);
|
||||
if (res != S_OK)
|
||||
continue;
|
||||
CPropColumn prop;
|
||||
prop.Type = VT_EMPTY;
|
||||
prop.ID = propID;
|
||||
prop.Name = GetNameOfProperty(propID, name);
|
||||
@@ -155,83 +174,147 @@ HRESULT CPanel::InitColumns()
|
||||
prop.IsVisible = GetColumnVisible(propID, isFsFolder);
|
||||
prop.Width = GetColumnWidth(propID, VT_BSTR);;
|
||||
prop.IsRawProp = true;
|
||||
_properties.Add(prop);
|
||||
_columns.Add(prop);
|
||||
}
|
||||
}
|
||||
|
||||
// InitColumns2(sortID);
|
||||
|
||||
for (;;)
|
||||
if (!_listView.DeleteColumn(0))
|
||||
break;
|
||||
|
||||
unsigned order = 0;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < _listViewInfo.Columns.Size(); i++)
|
||||
{
|
||||
const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
|
||||
int index = _properties.FindItemWithID(columnInfo.PropID);
|
||||
int index = _columns.FindItem_for_PropID(columnInfo.PropID);
|
||||
if (index >= 0)
|
||||
{
|
||||
CItemProperty &item = _properties[index];
|
||||
item.IsVisible = columnInfo.IsVisible;
|
||||
CPropColumn &item = _columns[index];
|
||||
if (item.Order >= 0)
|
||||
continue; // we ignore duplicated items
|
||||
bool isVisible = columnInfo.IsVisible;
|
||||
// we enable kpidName, if it was disabled by some incorrect code
|
||||
if (columnInfo.PropID == kpidName)
|
||||
isVisible = true;
|
||||
item.IsVisible = isVisible;
|
||||
item.Width = columnInfo.Width;
|
||||
if (columnInfo.IsVisible)
|
||||
if (isVisible)
|
||||
item.Order = order++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < _properties.Size(); i++)
|
||||
for (i = 0; i < _columns.Size(); i++)
|
||||
{
|
||||
CItemProperty &item = _properties[i];
|
||||
CPropColumn &item = _columns[i];
|
||||
if (item.IsVisible && item.Order < 0)
|
||||
item.Order = order++;
|
||||
}
|
||||
|
||||
for (i = 0; i < _columns.Size(); i++)
|
||||
{
|
||||
CPropColumn &item = _columns[i];
|
||||
if (item.Order < 0)
|
||||
item.Order = order++;
|
||||
}
|
||||
|
||||
_visibleProperties.Clear();
|
||||
for (i = 0; i < _properties.Size(); i++)
|
||||
CPropColumns newColumns;
|
||||
|
||||
for (i = 0; i < _columns.Size(); i++)
|
||||
{
|
||||
const CItemProperty &prop = _properties[i];
|
||||
const CPropColumn &prop = _columns[i];
|
||||
if (prop.IsVisible)
|
||||
_visibleProperties.Add(prop);
|
||||
newColumns.Add(prop);
|
||||
}
|
||||
|
||||
// _sortIndex = 0;
|
||||
_sortID = kpidName;
|
||||
|
||||
/*
|
||||
_sortIndex = 0;
|
||||
if (_listViewInfo.SortIndex >= 0)
|
||||
{
|
||||
int sortIndex = _properties.FindItemWithID(sortID);
|
||||
int sortIndex = _columns.FindItem_for_PropID(sortID);
|
||||
if (sortIndex >= 0)
|
||||
_sortIndex = sortIndex;
|
||||
}
|
||||
*/
|
||||
|
||||
if (_listViewInfo.IsLoaded)
|
||||
_sortID = _listViewInfo.SortID;
|
||||
else
|
||||
{
|
||||
_sortID = 0;
|
||||
if (IsFSFolder() || IsAltStreamsFolder() || IsArcFolder())
|
||||
_sortID = kpidName;
|
||||
}
|
||||
|
||||
_visibleProperties.Sort();
|
||||
/* There are restrictions in ListView control:
|
||||
1) main column (kpidName) must have (LV_COLUMNW::iSubItem = 0)
|
||||
So we need special sorting for columns.
|
||||
2) when we add new column, LV_COLUMNW::iOrder can not be larger than already inserted columns)
|
||||
So we set column order after all columns are added.
|
||||
*/
|
||||
newColumns.Sort(ItemProperty_Compare_NameFirst, NULL);
|
||||
|
||||
for (i = 0; i < _visibleProperties.Size(); i++)
|
||||
InsertColumn(i);
|
||||
if (newColumns.IsEqualTo(_visibleColumns))
|
||||
return S_OK;
|
||||
|
||||
CIntArr columns(newColumns.Size());
|
||||
for (i = 0; i < newColumns.Size(); i++)
|
||||
columns[i] = -1;
|
||||
|
||||
bool orderError = false;
|
||||
|
||||
for (i = 0; i < newColumns.Size(); i++)
|
||||
{
|
||||
const CPropColumn &prop = newColumns[i];
|
||||
if (prop.Order < (int)newColumns.Size() && columns[prop.Order] == -1)
|
||||
columns[prop.Order] = i;
|
||||
else
|
||||
orderError = true;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
unsigned numColumns = _visibleColumns.Size();
|
||||
if (numColumns == 0)
|
||||
break;
|
||||
DeleteColumn(numColumns - 1);
|
||||
}
|
||||
|
||||
for (i = 0; i < newColumns.Size(); i++)
|
||||
AddColumn(newColumns[i]);
|
||||
|
||||
// columns[0], columns[1], .... should be displayed from left to right:
|
||||
if (!orderError)
|
||||
_listView.SetColumnOrderArray(_visibleColumns.Size(), columns);
|
||||
|
||||
_needSaveInfo = true;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CPanel::InsertColumn(unsigned index)
|
||||
|
||||
void CPanel::DeleteColumn(unsigned index)
|
||||
{
|
||||
const CItemProperty &prop = _visibleProperties[index];
|
||||
_visibleColumns.Delete(index);
|
||||
_listView.DeleteColumn(index);
|
||||
}
|
||||
|
||||
void CPanel::AddColumn(const CPropColumn &prop)
|
||||
{
|
||||
const int index = _visibleColumns.Size();
|
||||
|
||||
LV_COLUMNW column;
|
||||
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
|
||||
column.cx = prop.Width;
|
||||
column.fmt = GetColumnAlign(prop.ID, prop.Type);
|
||||
column.iOrder = prop.Order;
|
||||
// iOrder must be <= _listView.ItemCount
|
||||
column.iSubItem = index;
|
||||
column.iOrder = index; // must be <= _listView.ItemCount
|
||||
column.iSubItem = index; // must be <= _listView.ItemCount
|
||||
column.pszText = const_cast<wchar_t *>((const wchar_t *)prop.Name);
|
||||
|
||||
_visibleColumns.Add(prop);
|
||||
_listView.InsertColumn(index, &column);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CPanel::RefreshListCtrl()
|
||||
{
|
||||
return RefreshListCtrl(UString(), -1, true, UStringVector());
|
||||
@@ -959,20 +1042,17 @@ UInt64 CPanel::GetItemSize(int itemIndex) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CPanel::ReadListViewInfo()
|
||||
{
|
||||
_typeIDString = GetFolderTypeID();
|
||||
if (!_typeIDString.IsEmpty())
|
||||
_listViewInfo.Read(_typeIDString);
|
||||
}
|
||||
|
||||
void CPanel::SaveListViewInfo()
|
||||
{
|
||||
if (!_needSaveInfo)
|
||||
return;
|
||||
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < _visibleProperties.Size(); i++)
|
||||
for (i = 0; i < _visibleColumns.Size(); i++)
|
||||
{
|
||||
CItemProperty &prop = _visibleProperties[i];
|
||||
CPropColumn &prop = _visibleColumns[i];
|
||||
LVCOLUMN winColumnInfo;
|
||||
winColumnInfo.mask = LVCF_ORDER | LVCF_WIDTH;
|
||||
if (!_listView.GetColumn(i, &winColumnInfo))
|
||||
@@ -983,14 +1063,18 @@ void CPanel::SaveListViewInfo()
|
||||
|
||||
CListViewInfo viewInfo;
|
||||
|
||||
// PROPID sortPropID = _properties[_sortIndex].ID;
|
||||
// PROPID sortPropID = _columns[_sortIndex].ID;
|
||||
PROPID sortPropID = _sortID;
|
||||
|
||||
_visibleProperties.Sort();
|
||||
// we save columns as "sorted by order" to registry
|
||||
|
||||
for (i = 0; i < _visibleProperties.Size(); i++)
|
||||
CPropColumns sortedProperties = _visibleColumns;
|
||||
|
||||
sortedProperties.Sort();
|
||||
|
||||
for (i = 0; i < sortedProperties.Size(); i++)
|
||||
{
|
||||
const CItemProperty &prop = _visibleProperties[i];
|
||||
const CPropColumn &prop = sortedProperties[i];
|
||||
CColumnInfo columnInfo;
|
||||
columnInfo.IsVisible = prop.IsVisible;
|
||||
columnInfo.PropID = prop.ID;
|
||||
@@ -998,13 +1082,13 @@ void CPanel::SaveListViewInfo()
|
||||
viewInfo.Columns.Add(columnInfo);
|
||||
}
|
||||
|
||||
for (i = 0; i < _properties.Size(); i++)
|
||||
for (i = 0; i < _columns.Size(); i++)
|
||||
{
|
||||
const CItemProperty &prop = _properties[i];
|
||||
if (!prop.IsVisible)
|
||||
const CPropColumn &prop = _columns[i];
|
||||
if (sortedProperties.FindItem_for_PropID(prop.ID) < 0)
|
||||
{
|
||||
CColumnInfo columnInfo;
|
||||
columnInfo.IsVisible = prop.IsVisible;
|
||||
columnInfo.IsVisible = false;
|
||||
columnInfo.PropID = prop.ID;
|
||||
columnInfo.Width = prop.Width;
|
||||
viewInfo.Columns.Add(columnInfo);
|
||||
@@ -1013,6 +1097,7 @@ void CPanel::SaveListViewInfo()
|
||||
|
||||
viewInfo.SortID = sortPropID;
|
||||
viewInfo.Ascending = _ascending;
|
||||
viewInfo.IsLoaded = true;
|
||||
if (!_listViewInfo.IsEqual(viewInfo))
|
||||
{
|
||||
viewInfo.Save(_typeIDString);
|
||||
@@ -1040,9 +1125,9 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
|
||||
menu.CreatePopup();
|
||||
|
||||
const int kCommandStart = 100;
|
||||
FOR_VECTOR (i, _properties)
|
||||
FOR_VECTOR (i, _columns)
|
||||
{
|
||||
const CItemProperty &prop = _properties[i];
|
||||
const CPropColumn &prop = _columns[i];
|
||||
UINT flags = MF_STRING;
|
||||
if (prop.IsVisible)
|
||||
flags |= MF_CHECKED;
|
||||
@@ -1053,25 +1138,22 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
|
||||
|
||||
int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView);
|
||||
|
||||
if (menuResult >= kCommandStart && menuResult <= kCommandStart + (int)_properties.Size())
|
||||
if (menuResult >= kCommandStart && menuResult <= kCommandStart + (int)_columns.Size())
|
||||
{
|
||||
int index = menuResult - kCommandStart;
|
||||
CItemProperty &prop = _properties[index];
|
||||
CPropColumn &prop = _columns[index];
|
||||
prop.IsVisible = !prop.IsVisible;
|
||||
|
||||
if (prop.IsVisible)
|
||||
{
|
||||
unsigned num = _visibleProperties.Size();
|
||||
prop.Order = num;
|
||||
_visibleProperties.Add(prop);
|
||||
InsertColumn(num);
|
||||
prop.Order = _visibleColumns.Size();
|
||||
AddColumn(prop);
|
||||
}
|
||||
else
|
||||
{
|
||||
int visibleIndex = _visibleProperties.FindItemWithID(prop.ID);
|
||||
int visibleIndex = _visibleColumns.FindItem_for_PropID(prop.ID);
|
||||
if (visibleIndex >= 0)
|
||||
{
|
||||
_visibleProperties.Delete(visibleIndex);
|
||||
/*
|
||||
if (_sortIndex == index)
|
||||
{
|
||||
@@ -1084,8 +1166,7 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
|
||||
_sortID = kpidName;
|
||||
_ascending = true;
|
||||
}
|
||||
|
||||
_listView.DeleteColumn(visibleIndex);
|
||||
DeleteColumn(visibleIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
if (item.cchTextMax <= 1)
|
||||
return 0;
|
||||
|
||||
const CItemProperty &property = _visibleProperties[item.iSubItem];
|
||||
const CPropColumn &property = _visibleColumns[item.iSubItem];
|
||||
PROPID propID = property.ID;
|
||||
|
||||
if (realIndex == kParentIndex)
|
||||
|
||||
@@ -82,20 +82,21 @@ void CPanel::OnInsert()
|
||||
LVIS_CUT : 0;
|
||||
_listView.SetItemState(focusedItem, state, LVIS_CUT);
|
||||
// _listView.SetItemState_Selected(focusedItem);
|
||||
|
||||
*/
|
||||
|
||||
int focusedItem = _listView.GetFocusedItem();
|
||||
if (focusedItem < 0)
|
||||
return;
|
||||
int realIndex = GetRealItemIndex(focusedItem);
|
||||
bool isSelected = !_selectedStatusVector[realIndex];
|
||||
if (realIndex != kParentIndex)
|
||||
_selectedStatusVector[realIndex] = isSelected;
|
||||
|
||||
int realIndex = GetRealItemIndex(focusedItem);
|
||||
if (realIndex != kParentIndex)
|
||||
{
|
||||
bool isSelected = !_selectedStatusVector[realIndex];
|
||||
_selectedStatusVector[realIndex] = isSelected;
|
||||
if (!_mySelectMode)
|
||||
_listView.SetItemState_Selected(focusedItem, isSelected);
|
||||
|
||||
_listView.RedrawItem(focusedItem);
|
||||
}
|
||||
|
||||
int nextIndex = focusedItem + 1;
|
||||
if (nextIndex < _listView.GetItemCount())
|
||||
@@ -112,6 +113,8 @@ void CPanel::OnUpWithShift()
|
||||
if (focusedItem < 0)
|
||||
return;
|
||||
int index = GetRealItemIndex(focusedItem);
|
||||
if (index == kParentIndex)
|
||||
return;
|
||||
_selectedStatusVector[index] = !_selectedStatusVector[index];
|
||||
_listView.RedrawItem(index);
|
||||
}
|
||||
@@ -122,6 +125,8 @@ void CPanel::OnDownWithShift()
|
||||
if (focusedItem < 0)
|
||||
return;
|
||||
int index = GetRealItemIndex(focusedItem);
|
||||
if (index == kParentIndex)
|
||||
return;
|
||||
_selectedStatusVector[index] = !_selectedStatusVector[index];
|
||||
_listView.RedrawItem(index);
|
||||
}
|
||||
|
||||
@@ -83,9 +83,9 @@ static inline const wchar_t *GetExtensionPtr(const UString &name)
|
||||
void CPanel::SetSortRawStatus()
|
||||
{
|
||||
_isRawSortProp = false;
|
||||
FOR_VECTOR (i, _properties)
|
||||
FOR_VECTOR (i, _columns)
|
||||
{
|
||||
const CItemProperty &prop = _properties[i];
|
||||
const CPropColumn &prop = _columns[i];
|
||||
if (prop.ID == _sortID)
|
||||
{
|
||||
_isRawSortProp = prop.IsRawProp ? 1 : 0;
|
||||
@@ -169,7 +169,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
|
||||
return ::CompareFileTime(&file1.MTime, &file2.MTime);
|
||||
*/
|
||||
|
||||
// PROPID propID = panel->_properties[panel->_sortIndex].ID;
|
||||
// PROPID propID = panel->_columns[panel->_sortIndex].ID;
|
||||
|
||||
NCOM::CPropVariant prop1, prop2;
|
||||
// Name must be first property
|
||||
@@ -215,7 +215,7 @@ void CPanel::SortItems(int index)
|
||||
{
|
||||
_sortIndex = index;
|
||||
_ascending = true;
|
||||
switch (_properties[_sortIndex].ID)
|
||||
switch (_columns[_sortIndex].ID)
|
||||
{
|
||||
case kpidSize:
|
||||
case kpidPackedSize:
|
||||
@@ -229,13 +229,15 @@ void CPanel::SortItems(int index)
|
||||
_listView.SortItems(CompareItems, (LPARAM)this);
|
||||
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
|
||||
}
|
||||
|
||||
void CPanel::SortItemsWithPropID(PROPID propID)
|
||||
{
|
||||
int index = _properties.FindItemWithID(propID);
|
||||
int index = _columns.FindItem_for_PropID(propID);
|
||||
if (index >= 0)
|
||||
SortItems(index);
|
||||
}
|
||||
*/
|
||||
|
||||
void CPanel::SortItemsWithPropID(PROPID propID)
|
||||
{
|
||||
if (propID == _sortID)
|
||||
@@ -264,8 +266,8 @@ void CPanel::SortItemsWithPropID(PROPID propID)
|
||||
void CPanel::OnColumnClick(LPNMLISTVIEW info)
|
||||
{
|
||||
/*
|
||||
int index = _properties.FindItemWithID(_visibleProperties[info->iSubItem].ID);
|
||||
int index = _columns.FindItem_for_PropID(_visibleColumns[info->iSubItem].ID);
|
||||
SortItems(index);
|
||||
*/
|
||||
SortItemsWithPropID(_visibleProperties[info->iSubItem].ID);
|
||||
SortItemsWithPropID(_visibleColumns[info->iSubItem].ID);
|
||||
}
|
||||
|
||||
@@ -97,6 +97,8 @@ void CListViewInfo::Read(const UString &id)
|
||||
Get32(buf + 4, SortID);
|
||||
GetBool(buf + 8, Ascending);
|
||||
|
||||
IsLoaded = true;
|
||||
|
||||
size -= kListViewHeaderSize;
|
||||
if (size % kColumnInfoSize != 0)
|
||||
return;
|
||||
|
||||
@@ -23,14 +23,22 @@ struct CListViewInfo
|
||||
CRecordVector<CColumnInfo> Columns;
|
||||
PROPID SortID;
|
||||
bool Ascending;
|
||||
bool IsLoaded;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
SortID = 0;
|
||||
Ascending = true;
|
||||
IsLoaded = false;
|
||||
Columns.Clear();
|
||||
}
|
||||
|
||||
CListViewInfo():
|
||||
SortID(0),
|
||||
Ascending(true),
|
||||
IsLoaded(false)
|
||||
{}
|
||||
|
||||
/*
|
||||
int FindColumnWithID(PROPID propID) const
|
||||
{
|
||||
|
||||
@@ -71,11 +71,13 @@ static const LPCTSTR kMB = TEXT(" MB");
|
||||
static const LPCTSTR kMIPS = TEXT(" MIPS");
|
||||
static const LPCTSTR kKBs = TEXT(" KB/s");
|
||||
|
||||
static const unsigned kMinDicLogSize =
|
||||
#ifdef UNDER_CE
|
||||
static const int kMinDicLogSize = 20;
|
||||
20;
|
||||
#else
|
||||
static const int kMinDicLogSize = 21;
|
||||
21;
|
||||
#endif
|
||||
|
||||
static const UInt32 kMinDicSize = (1 << kMinDicLogSize);
|
||||
static const UInt32 kMaxDicSize =
|
||||
#ifdef MY_CPU_64BIT
|
||||
@@ -175,7 +177,9 @@ bool CBenchmarkDialog::OnInit()
|
||||
|
||||
m_Dictionary.Attach(GetItem(IDC_BENCH_DICTIONARY));
|
||||
cur = 0;
|
||||
UInt64 ramSize = NSystem::GetRamSize();
|
||||
|
||||
UInt64 ramSize = (UInt64)(sizeof(size_t)) << 29;
|
||||
bool ramSize_Defined = NSystem::GetRamSize(ramSize);
|
||||
|
||||
#ifdef UNDER_CE
|
||||
const UInt32 kNormalizedCeSize = (16 << 20);
|
||||
@@ -185,29 +189,34 @@ bool CBenchmarkDialog::OnInit()
|
||||
|
||||
if (Sync.DictionarySize == (UInt32)(Int32)-1)
|
||||
{
|
||||
int dicSizeLog;
|
||||
for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
|
||||
unsigned dicSizeLog = 25;
|
||||
|
||||
#ifdef UNDER_CE
|
||||
dicSizeLog = 20;
|
||||
#endif
|
||||
|
||||
if (ramSize_Defined)
|
||||
for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
|
||||
if (GetBenchMemoryUsage(Sync.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
|
||||
break;
|
||||
Sync.DictionarySize = (1 << dicSizeLog);
|
||||
}
|
||||
if (Sync.DictionarySize < kMinDicSize)
|
||||
Sync.DictionarySize = kMinDicSize;
|
||||
if (Sync.DictionarySize > kMaxDicSize)
|
||||
Sync.DictionarySize = kMaxDicSize;
|
||||
|
||||
for (int i = kMinDicLogSize; i <= 30; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
if (Sync.DictionarySize < kMinDicSize) Sync.DictionarySize = kMinDicSize;
|
||||
if (Sync.DictionarySize > kMaxDicSize) Sync.DictionarySize = kMaxDicSize;
|
||||
|
||||
for (unsigned i = kMinDicLogSize; i <= 30; i++)
|
||||
for (unsigned j = 0; j < 2; j++)
|
||||
{
|
||||
UInt32 dictionary = (1 << i) + (j << (i - 1));
|
||||
if (dictionary > kMaxDicSize)
|
||||
UInt32 dict = (1 << i) + (j << (i - 1));
|
||||
if (dict > kMaxDicSize)
|
||||
continue;
|
||||
TCHAR s[16];
|
||||
ConvertUInt32ToString((dictionary >> 20), s);
|
||||
ConvertUInt32ToString((dict >> 20), s);
|
||||
lstrcat(s, kMB);
|
||||
int index = (int)m_Dictionary.AddString(s);
|
||||
m_Dictionary.SetItemData(index, dictionary);
|
||||
if (dictionary <= Sync.DictionarySize)
|
||||
m_Dictionary.SetItemData(index, dict);
|
||||
if (dict <= Sync.DictionarySize)
|
||||
cur = index;
|
||||
}
|
||||
m_Dictionary.SetCurSel(cur);
|
||||
@@ -265,14 +274,14 @@ UInt32 CBenchmarkDialog::GetNumberOfThreads()
|
||||
|
||||
UInt32 CBenchmarkDialog::OnChangeDictionary()
|
||||
{
|
||||
UInt32 dictionary = (UInt32)m_Dictionary.GetItemData_of_CurSel();
|
||||
UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dictionary);
|
||||
UInt32 dict = (UInt32)m_Dictionary.GetItemData_of_CurSel();
|
||||
UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dict);
|
||||
memUsage = (memUsage + (1 << 20) - 1) >> 20;
|
||||
TCHAR s[40];
|
||||
ConvertUInt64ToString(memUsage, s);
|
||||
lstrcat(s, kMB);
|
||||
SetItemText(IDT_BENCH_MEMORY_VAL, s);
|
||||
return dictionary;
|
||||
return dict;
|
||||
}
|
||||
|
||||
static const UInt32 g_IDs[] =
|
||||
@@ -303,7 +312,7 @@ static const UInt32 g_IDs[] =
|
||||
void CBenchmarkDialog::OnChangeSettings()
|
||||
{
|
||||
EnableItem(IDB_STOP, true);
|
||||
UInt32 dictionary = OnChangeDictionary();
|
||||
UInt32 dict = OnChangeDictionary();
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(g_IDs); i++)
|
||||
SetItemText(g_IDs[i], kProcessingString);
|
||||
@@ -311,7 +320,7 @@ void CBenchmarkDialog::OnChangeSettings()
|
||||
PrintTime();
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(Sync.CS);
|
||||
Sync.Init();
|
||||
Sync.DictionarySize = dictionary;
|
||||
Sync.DictionarySize = dict;
|
||||
Sync.Changed = true;
|
||||
Sync.NumThreads = GetNumberOfThreads();
|
||||
}
|
||||
|
||||
@@ -250,9 +250,10 @@ static bool IsMethodSupportedBySfx(int methodID)
|
||||
return false;
|
||||
}
|
||||
|
||||
static UInt64 GetMaxRamSizeForProgram()
|
||||
static bool GetMaxRamSizeForProgram(UInt64 &physSize)
|
||||
{
|
||||
UInt64 physSize = NSystem::GetRamSize();
|
||||
physSize = (UInt64)(sizeof(size_t)) << 29;
|
||||
bool ramSize_Defined = NSystem::GetRamSize(physSize);
|
||||
const UInt64 kMinSysSize = (1 << 24);
|
||||
if (physSize <= kMinSysSize)
|
||||
physSize = 0;
|
||||
@@ -261,7 +262,7 @@ static UInt64 GetMaxRamSizeForProgram()
|
||||
const UInt64 kMinUseSize = (1 << 24);
|
||||
if (physSize < kMinUseSize)
|
||||
physSize = kMinUseSize;
|
||||
return physSize;
|
||||
return ramSize_Defined;
|
||||
}
|
||||
|
||||
|
||||
@@ -1170,7 +1171,8 @@ void CCompressDialog::SetDictionary()
|
||||
UInt32 level = GetLevel2();
|
||||
if (methodID < 0)
|
||||
return;
|
||||
const UInt64 maxRamSize = GetMaxRamSizeForProgram();
|
||||
UInt64 maxRamSize;
|
||||
bool maxRamSize_Defined = GetMaxRamSizeForProgram(maxRamSize);
|
||||
|
||||
switch (methodID)
|
||||
{
|
||||
@@ -1196,6 +1198,7 @@ void CCompressDialog::SetDictionary()
|
||||
if (i == 20 && j > 0)
|
||||
continue;
|
||||
UInt32 dict = ((UInt32)(2 + j) << (i - 1));
|
||||
|
||||
if (dict >
|
||||
#ifdef MY_CPU_64BIT
|
||||
(3 << 29)
|
||||
@@ -1204,10 +1207,11 @@ void CCompressDialog::SetDictionary()
|
||||
#endif
|
||||
)
|
||||
continue;
|
||||
|
||||
AddDictionarySize(dict);
|
||||
UInt64 decomprSize;
|
||||
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
|
||||
if (dict <= defaultDict && requiredComprSize <= maxRamSize)
|
||||
if (dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
|
||||
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
|
||||
}
|
||||
|
||||
@@ -1242,11 +1246,12 @@ void CCompressDialog::SetDictionary()
|
||||
AddDictionarySize(dict);
|
||||
UInt64 decomprSize;
|
||||
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
|
||||
if (dict <= defaultDict && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
|
||||
if ((dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
|
||||
|| m_Dictionary.GetCount() == 1)
|
||||
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
|
||||
}
|
||||
|
||||
SetNearestSelectComboBox(m_Dictionary, defaultDict);
|
||||
// SetNearestSelectComboBox(m_Dictionary, defaultDict);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1295,11 +1300,12 @@ void CCompressDialog::SetDictionary()
|
||||
AddDictionarySize(dict);
|
||||
UInt64 decomprSize;
|
||||
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
|
||||
if (dict <= defaultDict && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
|
||||
if ((dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
|
||||
|| m_Dictionary.GetCount() == 1)
|
||||
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
|
||||
}
|
||||
|
||||
SetNearestSelectComboBox(m_Dictionary, defaultDict);
|
||||
// SetNearestSelectComboBox(m_Dictionary, defaultDict);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +175,7 @@ void AddHashBundleRes(UString &s, const CHashBundle &hb, const UString &firstFil
|
||||
AddValuePair(s, IDS_PROP_NUM_ERRORS, hb.NumErrors);
|
||||
s.Add_LF();
|
||||
}
|
||||
|
||||
if (hb.NumFiles == 1 && hb.NumDirs == 0 && !firstFileName.IsEmpty())
|
||||
{
|
||||
AddLangString(s, IDS_PROP_NAME);
|
||||
@@ -197,6 +198,12 @@ void AddHashBundleRes(UString &s, const CHashBundle &hb, const UString &firstFil
|
||||
AddSizeValuePair(s, IDS_PROP_ALT_STREAMS_SIZE, hb.AltStreamsSize);
|
||||
}
|
||||
|
||||
if (hb.NumErrors == 0 && hb.Hashers.IsEmpty())
|
||||
{
|
||||
s.Add_LF();
|
||||
AddLangString(s, IDS_MESSAGE_NO_ERRORS);
|
||||
}
|
||||
|
||||
FOR_VECTOR (i, hb.Hashers)
|
||||
{
|
||||
s.Add_LF();
|
||||
|
||||
@@ -109,7 +109,7 @@ void * __cdecl operator new(size_t size)
|
||||
}
|
||||
if (p == 0)
|
||||
throw CNewException();
|
||||
printf("Alloc %6d, size = %8d\n", numAllocs, size);
|
||||
printf("Alloc %6d, size = %8u\n", numAllocs, (unsigned)size);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,5 +12,3 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ static void UnicodeStringToMultiByte2(AString &dest, const UString &src, UINT co
|
||||
{
|
||||
BOOL defUsed = FALSE;
|
||||
bool isUtf = (codePage == CP_UTF8 || codePage == CP_UTF7);
|
||||
defaultChar = defaultChar;
|
||||
// defaultChar = defaultChar;
|
||||
len = WideCharToMultiByte(codePage, 0, src, src.Len(),
|
||||
dest.GetBuf(len), len,
|
||||
(isUtf ? NULL : &defaultChar),
|
||||
|
||||
@@ -17,5 +17,3 @@ int FindTextConfigItem(const CObjectVector<CTextConfigPair> &pairs, const UStrin
|
||||
UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const UString &id);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -32,6 +32,18 @@ public:
|
||||
|
||||
int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
|
||||
int InsertColumn(int columnIndex, LPCTSTR text, int width);
|
||||
bool SetColumnOrderArray(int count, const int *columns) { return BOOLToBool(ListView_SetColumnOrderArray(_window, count, columns)); }
|
||||
|
||||
/*
|
||||
int GetNumColumns()
|
||||
{
|
||||
HWND header = ListView_GetHeader(_window);
|
||||
if (!header)
|
||||
return -1;
|
||||
return Header_GetItemCount(header);
|
||||
}
|
||||
*/
|
||||
|
||||
int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
|
||||
int InsertItem(int index, LPCTSTR text);
|
||||
bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user