mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 01:14:55 -06:00
4.45 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
d9666cf046
commit
a145bfc7cf
101
Asm/x64/7zCrcT8U.asm
Executable file
101
Asm/x64/7zCrcT8U.asm
Executable file
@@ -0,0 +1,101 @@
|
||||
.code
|
||||
|
||||
|
||||
|
||||
|
||||
CRC1b macro
|
||||
movzx EDX, BYTE PTR [RSI]
|
||||
inc RSI
|
||||
movzx EBX, AL
|
||||
xor EDX, EBX
|
||||
shr EAX, 8
|
||||
xor EAX, [RDI + RDX * 4]
|
||||
dec R8
|
||||
endm
|
||||
|
||||
|
||||
|
||||
|
||||
align 16
|
||||
CrcUpdateT8 PROC
|
||||
|
||||
push RBX
|
||||
push RSI
|
||||
push RDI
|
||||
push RBP
|
||||
|
||||
mov EAX, ECX
|
||||
mov RSI, RDX
|
||||
mov RDI, R9
|
||||
|
||||
|
||||
test R8, R8
|
||||
jz sl_end
|
||||
sl:
|
||||
test RSI, 7
|
||||
jz sl_end
|
||||
CRC1b
|
||||
jnz sl
|
||||
sl_end:
|
||||
|
||||
cmp R8, 16
|
||||
jb crc_end
|
||||
mov R9, R8
|
||||
and R8, 7
|
||||
add R8, 8
|
||||
sub R9, R8
|
||||
|
||||
add R9, RSI
|
||||
xor EAX, [RSI]
|
||||
mov EBX, [RSI + 4]
|
||||
movzx ECX, BL
|
||||
align 16
|
||||
main_loop:
|
||||
mov EDX, [RDI + RCX*4 + 0C00h]
|
||||
movzx EBP, BH
|
||||
xor EDX, [RDI + RBP*4 + 0800h]
|
||||
shr EBX, 16
|
||||
movzx ECX, BL
|
||||
xor EDX, [RSI + 8]
|
||||
xor EDX, [RDI + RCX*4 + 0400h]
|
||||
movzx ECX, AL
|
||||
movzx EBP, BH
|
||||
xor EDX, [RDI + RBP*4 + 0000h]
|
||||
|
||||
mov EBX, [RSI + 12]
|
||||
|
||||
xor EDX, [RDI + RCX*4 + 01C00h]
|
||||
movzx EBP, AH
|
||||
shr EAX, 16
|
||||
movzx ECX, AL
|
||||
xor EDX, [RDI + RBP*4 + 01800h]
|
||||
movzx EBP, AH
|
||||
mov EAX, [RDI + RCX*4 + 01400h]
|
||||
add RSI, 8
|
||||
xor EAX, [RDI + RBP*4 + 01000h]
|
||||
movzx ECX, BL
|
||||
xor EAX,EDX
|
||||
|
||||
cmp RSI, R9
|
||||
jne main_loop
|
||||
xor EAX, [RSI]
|
||||
|
||||
|
||||
|
||||
crc_end:
|
||||
|
||||
test R8, R8
|
||||
jz fl_end
|
||||
fl:
|
||||
CRC1b
|
||||
jnz fl
|
||||
fl_end:
|
||||
|
||||
pop RBP
|
||||
pop RDI
|
||||
pop RSI
|
||||
pop RBX
|
||||
ret
|
||||
CrcUpdateT8 ENDP
|
||||
|
||||
end
|
||||
101
Asm/x86/7zCrcT8U.asm
Executable file
101
Asm/x86/7zCrcT8U.asm
Executable file
@@ -0,0 +1,101 @@
|
||||
.386
|
||||
.model flat
|
||||
|
||||
_TEXT$00 SEGMENT PARA PUBLIC 'CODE'
|
||||
|
||||
CRC1b macro
|
||||
movzx EDX, BYTE PTR [ESI]
|
||||
inc ESI
|
||||
movzx EBX, AL
|
||||
xor EDX, EBX
|
||||
shr EAX, 8
|
||||
xor EAX, [EBP + EDX * 4]
|
||||
dec EDI
|
||||
endm
|
||||
|
||||
data_size equ (4 + 4*4)
|
||||
crc_table equ (data_size + 4)
|
||||
|
||||
align 16
|
||||
public @CrcUpdateT8@16
|
||||
@CrcUpdateT8@16:
|
||||
push EBX
|
||||
push ESI
|
||||
push EDI
|
||||
push EBP
|
||||
|
||||
mov EAX, ECX
|
||||
mov ESI, EDX
|
||||
mov EDI, [ESP + data_size]
|
||||
mov EBP, [ESP + crc_table]
|
||||
|
||||
test EDI, EDI
|
||||
jz sl_end
|
||||
sl:
|
||||
test ESI, 7
|
||||
jz sl_end
|
||||
CRC1b
|
||||
jnz sl
|
||||
sl_end:
|
||||
|
||||
cmp EDI, 16
|
||||
jb crc_end
|
||||
mov [ESP + data_size], EDI
|
||||
sub EDI, 8
|
||||
and EDI, NOT 7
|
||||
sub [ESP + data_size], EDI
|
||||
|
||||
add EDI, ESI
|
||||
xor EAX, [ESI]
|
||||
mov EBX, [ESI + 4]
|
||||
movzx ECX, BL
|
||||
align 16
|
||||
main_loop:
|
||||
mov EDX, [EBP + ECX*4 + 0C00h]
|
||||
movzx ECX, BH
|
||||
xor EDX, [EBP + ECX*4 + 0800h]
|
||||
shr EBX, 16
|
||||
movzx ECX, BL
|
||||
xor EDX, [EBP + ECX*4 + 0400h]
|
||||
xor EDX, [ESI + 8]
|
||||
movzx ECX, AL
|
||||
movzx EBX, BH
|
||||
xor EDX, [EBP + EBX*4 + 0000h]
|
||||
|
||||
mov EBX, [ESI + 12]
|
||||
|
||||
xor EDX, [EBP + ECX*4 + 01C00h]
|
||||
movzx ECX, AH
|
||||
add ESI, 8
|
||||
shr EAX, 16
|
||||
xor EDX, [EBP + ECX*4 + 01800h]
|
||||
movzx ECX, AL
|
||||
xor EDX, [EBP + ECX*4 + 01400h]
|
||||
movzx ECX, AH
|
||||
mov EAX, [EBP + ECX*4 + 01000h]
|
||||
movzx ECX, BL
|
||||
xor EAX,EDX
|
||||
|
||||
cmp ESI, EDI
|
||||
jne main_loop
|
||||
xor EAX, [ESI]
|
||||
|
||||
mov EDI, [ESP + data_size]
|
||||
|
||||
crc_end:
|
||||
|
||||
test EDI, EDI
|
||||
jz fl_end
|
||||
fl:
|
||||
CRC1b
|
||||
jnz fl
|
||||
fl_end:
|
||||
|
||||
pop EBP
|
||||
pop EDI
|
||||
pop ESI
|
||||
pop EBX
|
||||
ret 8
|
||||
|
||||
|
||||
end
|
||||
123
C/7zCrc.c
123
C/7zCrc.c
@@ -3,12 +3,9 @@
|
||||
#include "7zCrc.h"
|
||||
|
||||
#define kCrcPoly 0xEDB88320
|
||||
UInt32 g_CrcTable[256];
|
||||
|
||||
UInt32 g_CrcTable[256]
|
||||
|
||||
#ifdef CRC_GENERATE_TABLE
|
||||
;
|
||||
void CrcGenerateTable()
|
||||
void MY_FAST_CALL CrcGenerateTable()
|
||||
{
|
||||
UInt32 i;
|
||||
for (i = 0; i < 256; i++)
|
||||
@@ -16,122 +13,20 @@ void CrcGenerateTable()
|
||||
UInt32 r = i;
|
||||
int j;
|
||||
for (j = 0; j < 8; j++)
|
||||
if (r & 1)
|
||||
r = (r >> 1) ^ kCrcPoly;
|
||||
else
|
||||
r >>= 1;
|
||||
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
||||
g_CrcTable[i] = r;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
= {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
void CrcInit(UInt32 *crc) { *crc = 0xFFFFFFFF; }
|
||||
UInt32 CrcGetDigest(UInt32 *crc) { return *crc ^ 0xFFFFFFFF; }
|
||||
|
||||
void CrcUpdateByte(UInt32 *crc, Byte b)
|
||||
UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
|
||||
{
|
||||
*crc = g_CrcTable[((Byte)(*crc)) ^ b] ^ (*crc >> 8);
|
||||
}
|
||||
|
||||
void CrcUpdateUInt16(UInt32 *crc, UInt16 v)
|
||||
{
|
||||
CrcUpdateByte(crc, (Byte)v);
|
||||
CrcUpdateByte(crc, (Byte)(v >> 8));
|
||||
}
|
||||
|
||||
void CrcUpdateUInt32(UInt32 *crc, UInt32 v)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
CrcUpdateByte(crc, (Byte)(v >> (8 * i)));
|
||||
}
|
||||
|
||||
void CrcUpdateUInt64(UInt32 *crc, UInt64 v)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
CrcUpdateByte(crc, (Byte)(v));
|
||||
v >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
void CrcUpdate(UInt32 *crc, const void *data, size_t size)
|
||||
{
|
||||
UInt32 v = *crc;
|
||||
const Byte *p = (const Byte *)data;
|
||||
for (; size > 0 ; size--, p++)
|
||||
v = g_CrcTable[((Byte)(v)) ^ *p] ^ (v >> 8);
|
||||
*crc = v;
|
||||
for (; size > 0 ; size--, p++)
|
||||
v = CRC_UPDATE_BYTE(v, *p);
|
||||
return v;
|
||||
}
|
||||
|
||||
UInt32 CrcCalculateDigest(const void *data, size_t size)
|
||||
UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
|
||||
{
|
||||
UInt32 crc;
|
||||
CrcInit(&crc);
|
||||
CrcUpdate(&crc, data, size);
|
||||
return CrcGetDigest(&crc);
|
||||
}
|
||||
|
||||
int CrcVerifyDigest(UInt32 digest, const void *data, size_t size)
|
||||
{
|
||||
return (CrcCalculateDigest(data, size) == digest);
|
||||
return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
24
C/7zCrc.h
24
C/7zCrc.h
@@ -7,25 +7,15 @@
|
||||
|
||||
#include "Types.h"
|
||||
|
||||
extern UInt32 g_CrcTable[256];
|
||||
extern UInt32 g_CrcTable[];
|
||||
|
||||
// #define CRC_GENERATE_TABLE
|
||||
void MY_FAST_CALL CrcGenerateTable();
|
||||
|
||||
#ifdef CRC_GENERATE_TABLE
|
||||
void CrcGenerateTable();
|
||||
#else
|
||||
#define CrcGenerateTable()
|
||||
#endif
|
||||
#define CRC_INIT_VAL 0xFFFFFFFF
|
||||
#define CRC_GET_DIGEST(crc) ((crc) ^ 0xFFFFFFFF)
|
||||
#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
||||
|
||||
void CrcInit(UInt32 *crc);
|
||||
UInt32 CrcGetDigest(UInt32 *crc);
|
||||
void CrcUpdateByte(UInt32 *crc, Byte v);
|
||||
void CrcUpdateUInt16(UInt32 *crc, UInt16 v);
|
||||
void CrcUpdateUInt32(UInt32 *crc, UInt32 v);
|
||||
void CrcUpdateUInt64(UInt32 *crc, UInt64 v);
|
||||
void CrcUpdate(UInt32 *crc, const void *data, size_t size);
|
||||
|
||||
UInt32 CrcCalculateDigest(const void *data, size_t size);
|
||||
int CrcVerifyDigest(UInt32 digest, const void *data, size_t size);
|
||||
UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size);
|
||||
UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
40
C/7zCrcT8.c
Executable file
40
C/7zCrcT8.c
Executable file
@@ -0,0 +1,40 @@
|
||||
/* 7zCrc.c */
|
||||
|
||||
#include "7zCrc.h"
|
||||
|
||||
#define kCrcPoly 0xEDB88320
|
||||
#define CRC_NUM_TABLES 8
|
||||
|
||||
UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
|
||||
|
||||
void MY_FAST_CALL CrcGenerateTable()
|
||||
{
|
||||
UInt32 i;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
UInt32 r = i;
|
||||
int j;
|
||||
for (j = 0; j < 8; j++)
|
||||
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
||||
g_CrcTable[i] = r;
|
||||
}
|
||||
#if CRC_NUM_TABLES > 1
|
||||
for (; i < 256 * CRC_NUM_TABLES; i++)
|
||||
{
|
||||
UInt32 r = g_CrcTable[i - 256];
|
||||
g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
||||
|
||||
UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
|
||||
{
|
||||
return CrcUpdateT8(v, data, size, g_CrcTable);
|
||||
}
|
||||
|
||||
UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
|
||||
{
|
||||
return CrcUpdateT8(CRC_INIT_VAL, data, size, g_CrcTable) ^ 0xFFFFFFFF;
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
// Common/Alloc.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
// Common/Alloc.c
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "MyWindows.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Alloc.h"
|
||||
|
||||
/* #define _SZ_ALLOC_DEBUG */
|
||||
// #define _SZ_ALLOC_DEBUG
|
||||
|
||||
/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
#include <stdio.h>
|
||||
@@ -19,39 +17,38 @@ int g_allocCountMid = 0;
|
||||
int g_allocCountBig = 0;
|
||||
#endif
|
||||
|
||||
void *MyAlloc(size_t size) throw()
|
||||
void *MyAlloc(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount++);
|
||||
#endif
|
||||
return ::malloc(size);
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void MyFree(void *address) throw()
|
||||
void MyFree(void *address)
|
||||
{
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
if (address != 0)
|
||||
fprintf(stderr, "\nFree; count = %10d", --g_allocCount);
|
||||
#endif
|
||||
|
||||
::free(address);
|
||||
free(address);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void *MidAlloc(size_t size) throw()
|
||||
void *MidAlloc(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++);
|
||||
#endif
|
||||
return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
}
|
||||
|
||||
void MidFree(void *address) throw()
|
||||
void MidFree(void *address)
|
||||
{
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
if (address != 0)
|
||||
@@ -59,46 +56,36 @@ void MidFree(void *address) throw()
|
||||
#endif
|
||||
if (address == 0)
|
||||
return;
|
||||
::VirtualFree(address, 0, MEM_RELEASE);
|
||||
VirtualFree(address, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
|
||||
#ifndef MEM_LARGE_PAGES
|
||||
#define _7ZIP_NO_LARGE_PAGES
|
||||
wedeed
|
||||
#undef _7ZIP_LARGE_PAGES
|
||||
#endif
|
||||
|
||||
// define _7ZIP_NO_LARGE_PAGES if you don't need LARGE_PAGES support
|
||||
// #define _7ZIP_NO_LARGE_PAGES
|
||||
|
||||
|
||||
#ifndef _7ZIP_NO_LARGE_PAGES
|
||||
static SIZE_T g_LargePageSize =
|
||||
#ifdef _WIN64
|
||||
(1 << 21);
|
||||
#else
|
||||
(1 << 22);
|
||||
#endif
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
SIZE_T g_LargePageSize = 0;
|
||||
typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
|
||||
#endif
|
||||
|
||||
bool SetLargePageSize()
|
||||
void SetLargePageSize()
|
||||
{
|
||||
#ifndef _7ZIP_NO_LARGE_PAGES
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
SIZE_T size = 0;
|
||||
GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
|
||||
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
|
||||
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
|
||||
if (largePageMinimum == 0)
|
||||
return false;
|
||||
SIZE_T size = largePageMinimum();
|
||||
return;
|
||||
size = largePageMinimum();
|
||||
if (size == 0 || (size & (size - 1)) != 0)
|
||||
return false;
|
||||
return;
|
||||
g_LargePageSize = size;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void *BigAlloc(size_t size) throw()
|
||||
void *BigAlloc(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
@@ -106,19 +93,19 @@ void *BigAlloc(size_t size) throw()
|
||||
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_NO_LARGE_PAGES
|
||||
if (size >= (1 << 18))
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
|
||||
{
|
||||
void *res = ::VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
|
||||
void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
|
||||
MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
|
||||
if (res != 0)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
}
|
||||
|
||||
void BigFree(void *address) throw()
|
||||
void BigFree(void *address)
|
||||
{
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
if (address != 0)
|
||||
@@ -127,7 +114,7 @@ void BigFree(void *address) throw()
|
||||
|
||||
if (address == 0)
|
||||
return;
|
||||
::VirtualFree(address, 0, MEM_RELEASE);
|
||||
VirtualFree(address, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,17 +5,17 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *MyAlloc(size_t size) throw();
|
||||
void MyFree(void *address) throw();
|
||||
void *MyAlloc(size_t size);
|
||||
void MyFree(void *address);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
bool SetLargePageSize();
|
||||
void SetLargePageSize();
|
||||
|
||||
void *MidAlloc(size_t size) throw();
|
||||
void MidFree(void *address) throw();
|
||||
void *BigAlloc(size_t size) throw();
|
||||
void BigFree(void *address) throw();
|
||||
void *MidAlloc(size_t size);
|
||||
void MidFree(void *address);
|
||||
void *BigAlloc(size_t size);
|
||||
void BigFree(void *address);
|
||||
|
||||
#else
|
||||
|
||||
20
C/Archive/7z/7zAlloc.h
Executable file
20
C/Archive/7z/7zAlloc.h
Executable file
@@ -0,0 +1,20 @@
|
||||
/* 7zAlloc.h */
|
||||
|
||||
#ifndef __7Z_ALLOC_H
|
||||
#define __7Z_ALLOC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct _ISzAlloc
|
||||
{
|
||||
void *(*Alloc)(size_t size);
|
||||
void (*Free)(void *address); /* address can be 0 */
|
||||
} ISzAlloc;
|
||||
|
||||
void *SzAlloc(size_t size);
|
||||
void SzFree(void *address);
|
||||
|
||||
void *SzAllocTemp(size_t size);
|
||||
void SzFreeTemp(void *address);
|
||||
|
||||
#endif
|
||||
19
C/Archive/7z/7zBuffer.h
Executable file
19
C/Archive/7z/7zBuffer.h
Executable file
@@ -0,0 +1,19 @@
|
||||
/* 7zBuffer.h */
|
||||
|
||||
#ifndef __7Z_BUFFER_H
|
||||
#define __7Z_BUFFER_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "../../Types.h"
|
||||
|
||||
typedef struct _CSzByteBuffer
|
||||
{
|
||||
size_t Capacity;
|
||||
Byte *Items;
|
||||
}CSzByteBuffer;
|
||||
|
||||
void SzByteBufferInit(CSzByteBuffer *buffer);
|
||||
int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size));
|
||||
void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *));
|
||||
|
||||
#endif
|
||||
21
C/Archive/7z/7zDecode.h
Executable file
21
C/Archive/7z/7zDecode.h
Executable file
@@ -0,0 +1,21 @@
|
||||
/* 7zDecode.h */
|
||||
|
||||
#ifndef __7Z_DECODE_H
|
||||
#define __7Z_DECODE_H
|
||||
|
||||
#include "7zItem.h"
|
||||
#include "7zAlloc.h"
|
||||
#ifdef _LZMA_IN_CB
|
||||
#include "7zIn.h"
|
||||
#endif
|
||||
|
||||
SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ISzInStream *stream,
|
||||
#else
|
||||
const Byte *inBuffer,
|
||||
#endif
|
||||
Byte *outBuffer, size_t outSize,
|
||||
size_t *outSizeProcessed, ISzAlloc *allocMain);
|
||||
|
||||
#endif
|
||||
@@ -83,7 +83,7 @@ SZ_RESULT SzExtract(
|
||||
{
|
||||
if (folder->UnPackCRCDefined)
|
||||
{
|
||||
if (!CrcVerifyDigest(folder->UnPackCRC, *outBuffer, (size_t)unPackSize))
|
||||
if (CrcCalc(*outBuffer, (size_t)unPackSize) != folder->UnPackCRC)
|
||||
res = SZE_FAIL;
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ SZ_RESULT SzExtract(
|
||||
{
|
||||
if (fileItem->IsFileCRCDefined)
|
||||
{
|
||||
if (!CrcVerifyDigest(fileItem->FileCRC, *outBuffer + *offset, *outSizeProcessed))
|
||||
if (CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->FileCRC)
|
||||
res = SZE_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
40
C/Archive/7z/7zExtract.h
Executable file
40
C/Archive/7z/7zExtract.h
Executable file
@@ -0,0 +1,40 @@
|
||||
/* 7zExtract.h */
|
||||
|
||||
#ifndef __7Z_EXTRACT_H
|
||||
#define __7Z_EXTRACT_H
|
||||
|
||||
#include "7zIn.h"
|
||||
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
SZ_RESULT SzExtract(
|
||||
ISzInStream *inStream,
|
||||
CArchiveDatabaseEx *db,
|
||||
UInt32 fileIndex, /* index of file */
|
||||
UInt32 *blockIndex, /* index of solid block */
|
||||
Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
|
||||
size_t *outBufferSize, /* buffer size for output buffer */
|
||||
size_t *offset, /* offset of stream for required file in *outBuffer */
|
||||
size_t *outSizeProcessed, /* size of file in *outBuffer */
|
||||
ISzAlloc *allocMain,
|
||||
ISzAlloc *allocTemp);
|
||||
|
||||
#endif
|
||||
55
C/Archive/7z/7zHeader.h
Executable file
55
C/Archive/7z/7zHeader.h
Executable file
@@ -0,0 +1,55 @@
|
||||
/* 7zHeader.h */
|
||||
|
||||
#ifndef __7Z_HEADER_H
|
||||
#define __7Z_HEADER_H
|
||||
|
||||
#include "../../Types.h"
|
||||
|
||||
#define k7zSignatureSize 6
|
||||
extern Byte k7zSignature[k7zSignatureSize];
|
||||
|
||||
#define k7zMajorVersion 0
|
||||
|
||||
#define k7zStartHeaderSize 0x20
|
||||
|
||||
enum EIdEnum
|
||||
{
|
||||
k7zIdEnd,
|
||||
|
||||
k7zIdHeader,
|
||||
|
||||
k7zIdArchiveProperties,
|
||||
|
||||
k7zIdAdditionalStreamsInfo,
|
||||
k7zIdMainStreamsInfo,
|
||||
k7zIdFilesInfo,
|
||||
|
||||
k7zIdPackInfo,
|
||||
k7zIdUnPackInfo,
|
||||
k7zIdSubStreamsInfo,
|
||||
|
||||
k7zIdSize,
|
||||
k7zIdCRC,
|
||||
|
||||
k7zIdFolder,
|
||||
|
||||
k7zIdCodersUnPackSize,
|
||||
k7zIdNumUnPackStream,
|
||||
|
||||
k7zIdEmptyStream,
|
||||
k7zIdEmptyFile,
|
||||
k7zIdAnti,
|
||||
|
||||
k7zIdName,
|
||||
k7zIdCreationTime,
|
||||
k7zIdLastAccessTime,
|
||||
k7zIdLastWriteTime,
|
||||
k7zIdWinAttributes,
|
||||
k7zIdComment,
|
||||
|
||||
k7zIdEncodedHeader,
|
||||
|
||||
k7zIdStartPos
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -208,7 +208,7 @@ SZ_RESULT SafeReadDirectByte(ISzInStream *inStream, Byte *data)
|
||||
return SafeReadDirect(inStream, data, 1);
|
||||
}
|
||||
|
||||
SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value)
|
||||
SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value, UInt32 *crc)
|
||||
{
|
||||
int i;
|
||||
*value = 0;
|
||||
@@ -217,11 +217,12 @@ SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value)
|
||||
Byte b;
|
||||
RINOK(SafeReadDirectByte(inStream, &b));
|
||||
*value |= ((UInt32)b << (8 * i));
|
||||
*crc = CRC_UPDATE_BYTE(*crc, b);
|
||||
}
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value)
|
||||
SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value, UInt32 *crc)
|
||||
{
|
||||
int i;
|
||||
*value = 0;
|
||||
@@ -230,6 +231,7 @@ SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value)
|
||||
Byte b;
|
||||
RINOK(SafeReadDirectByte(inStream, &b));
|
||||
*value |= ((UInt64)b << (8 * i));
|
||||
*crc = CRC_UPDATE_BYTE(*crc, b);
|
||||
}
|
||||
return SZ_OK;
|
||||
}
|
||||
@@ -1133,7 +1135,7 @@ SZ_RESULT SzReadAndDecodePackedStreams2(
|
||||
if (outRealSize != (UInt32)unPackSize)
|
||||
return SZE_FAIL;
|
||||
if (folder->UnPackCRCDefined)
|
||||
if (!CrcVerifyDigest(folder->UnPackCRC, outBuffer->Items, (size_t)unPackSize))
|
||||
if (CrcCalc(outBuffer->Items, (size_t)unPackSize) != folder->UnPackCRC)
|
||||
return SZE_FAIL;
|
||||
return SZ_OK;
|
||||
}
|
||||
@@ -1182,7 +1184,7 @@ SZ_RESULT SzArchiveOpen2(
|
||||
UInt64 nextHeaderOffset;
|
||||
UInt64 nextHeaderSize;
|
||||
UInt32 nextHeaderCRC;
|
||||
UInt32 crc;
|
||||
UInt32 crc = 0;
|
||||
CFileSize pos = 0;
|
||||
CSzByteBuffer buffer;
|
||||
CSzData sd;
|
||||
@@ -1202,20 +1204,17 @@ SZ_RESULT SzArchiveOpen2(
|
||||
return SZE_ARCHIVE_ERROR;
|
||||
RINOK(SafeReadDirectByte(inStream, &version));
|
||||
|
||||
RINOK(SafeReadDirectUInt32(inStream, &crcFromArchive));
|
||||
RINOK(SafeReadDirectUInt32(inStream, &crcFromArchive, &crc));
|
||||
|
||||
CrcInit(&crc);
|
||||
RINOK(SafeReadDirectUInt64(inStream, &nextHeaderOffset));
|
||||
CrcUpdateUInt64(&crc, nextHeaderOffset);
|
||||
RINOK(SafeReadDirectUInt64(inStream, &nextHeaderSize));
|
||||
CrcUpdateUInt64(&crc, nextHeaderSize);
|
||||
RINOK(SafeReadDirectUInt32(inStream, &nextHeaderCRC));
|
||||
CrcUpdateUInt32(&crc, nextHeaderCRC);
|
||||
crc = CRC_INIT_VAL;
|
||||
RINOK(SafeReadDirectUInt64(inStream, &nextHeaderOffset, &crc));
|
||||
RINOK(SafeReadDirectUInt64(inStream, &nextHeaderSize, &crc));
|
||||
RINOK(SafeReadDirectUInt32(inStream, &nextHeaderCRC, &crc));
|
||||
|
||||
pos = k7zStartHeaderSize;
|
||||
db->ArchiveInfo.StartPositionAfterHeader = pos;
|
||||
|
||||
if (CrcGetDigest(&crc) != crcFromArchive)
|
||||
if (CRC_GET_DIGEST(crc) != crcFromArchive)
|
||||
return SZE_ARCHIVE_ERROR;
|
||||
|
||||
if (nextHeaderSize == 0)
|
||||
@@ -1230,7 +1229,7 @@ SZ_RESULT SzArchiveOpen2(
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
res = SZE_ARCHIVE_ERROR;
|
||||
if (CrcVerifyDigest(nextHeaderCRC, buffer.Items, (UInt32)nextHeaderSize))
|
||||
if (CrcCalc(buffer.Items, (UInt32)nextHeaderSize) == nextHeaderCRC)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
|
||||
55
C/Archive/7z/7zIn.h
Executable file
55
C/Archive/7z/7zIn.h
Executable file
@@ -0,0 +1,55 @@
|
||||
/* 7zIn.h */
|
||||
|
||||
#ifndef __7Z_IN_H
|
||||
#define __7Z_IN_H
|
||||
|
||||
#include "7zHeader.h"
|
||||
#include "7zItem.h"
|
||||
#include "7zAlloc.h"
|
||||
|
||||
typedef struct _CInArchiveInfo
|
||||
{
|
||||
CFileSize StartPositionAfterHeader;
|
||||
CFileSize DataStartPosition;
|
||||
}CInArchiveInfo;
|
||||
|
||||
typedef struct _CArchiveDatabaseEx
|
||||
{
|
||||
CArchiveDatabase Database;
|
||||
CInArchiveInfo ArchiveInfo;
|
||||
UInt32 *FolderStartPackStreamIndex;
|
||||
CFileSize *PackStreamStartPositions;
|
||||
UInt32 *FolderStartFileIndex;
|
||||
UInt32 *FileIndexToFolderIndexMap;
|
||||
}CArchiveDatabaseEx;
|
||||
|
||||
void SzArDbExInit(CArchiveDatabaseEx *db);
|
||||
void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *));
|
||||
CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder);
|
||||
CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex);
|
||||
|
||||
typedef struct _ISzInStream
|
||||
{
|
||||
#ifdef _LZMA_IN_CB
|
||||
SZ_RESULT (*Read)(
|
||||
void *object, /* pointer to ISzInStream itself */
|
||||
void **buffer, /* out: pointer to buffer with data */
|
||||
size_t maxRequiredSize, /* max required size to read */
|
||||
size_t *processedSize); /* real processed size.
|
||||
processedSize can be less than maxRequiredSize.
|
||||
If processedSize == 0, then there are no more
|
||||
bytes in stream. */
|
||||
#else
|
||||
SZ_RESULT (*Read)(void *object, void *buffer, size_t size, size_t *processedSize);
|
||||
#endif
|
||||
SZ_RESULT (*Seek)(void *object, CFileSize pos);
|
||||
} ISzInStream;
|
||||
|
||||
|
||||
int SzArchiveOpen(
|
||||
ISzInStream *inStream,
|
||||
CArchiveDatabaseEx *db,
|
||||
ISzAlloc *allocMain,
|
||||
ISzAlloc *allocTemp);
|
||||
|
||||
#endif
|
||||
90
C/Archive/7z/7zItem.h
Executable file
90
C/Archive/7z/7zItem.h
Executable file
@@ -0,0 +1,90 @@
|
||||
/* 7zItem.h */
|
||||
|
||||
#ifndef __7Z_ITEM_H
|
||||
#define __7Z_ITEM_H
|
||||
|
||||
#include "7zMethodID.h"
|
||||
#include "7zHeader.h"
|
||||
#include "7zBuffer.h"
|
||||
|
||||
typedef struct _CCoderInfo
|
||||
{
|
||||
UInt32 NumInStreams;
|
||||
UInt32 NumOutStreams;
|
||||
CMethodID MethodID;
|
||||
CSzByteBuffer Properties;
|
||||
}CCoderInfo;
|
||||
|
||||
void SzCoderInfoInit(CCoderInfo *coder);
|
||||
void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p));
|
||||
|
||||
typedef struct _CBindPair
|
||||
{
|
||||
UInt32 InIndex;
|
||||
UInt32 OutIndex;
|
||||
}CBindPair;
|
||||
|
||||
typedef struct _CFolder
|
||||
{
|
||||
UInt32 NumCoders;
|
||||
CCoderInfo *Coders;
|
||||
UInt32 NumBindPairs;
|
||||
CBindPair *BindPairs;
|
||||
UInt32 NumPackStreams;
|
||||
UInt32 *PackStreams;
|
||||
CFileSize *UnPackSizes;
|
||||
int UnPackCRCDefined;
|
||||
UInt32 UnPackCRC;
|
||||
|
||||
UInt32 NumUnPackStreams;
|
||||
}CFolder;
|
||||
|
||||
void SzFolderInit(CFolder *folder);
|
||||
CFileSize SzFolderGetUnPackSize(CFolder *folder);
|
||||
int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex);
|
||||
UInt32 SzFolderGetNumOutStreams(CFolder *folder);
|
||||
CFileSize SzFolderGetUnPackSize(CFolder *folder);
|
||||
|
||||
/* #define CArchiveFileTime UInt64 */
|
||||
|
||||
typedef struct _CFileItem
|
||||
{
|
||||
/*
|
||||
CArchiveFileTime LastWriteTime;
|
||||
CFileSize StartPos;
|
||||
UInt32 Attributes;
|
||||
*/
|
||||
CFileSize Size;
|
||||
UInt32 FileCRC;
|
||||
char *Name;
|
||||
|
||||
Byte IsFileCRCDefined;
|
||||
Byte HasStream;
|
||||
Byte IsDirectory;
|
||||
Byte IsAnti;
|
||||
/*
|
||||
int AreAttributesDefined;
|
||||
int IsLastWriteTimeDefined;
|
||||
int IsStartPosDefined;
|
||||
*/
|
||||
}CFileItem;
|
||||
|
||||
void SzFileInit(CFileItem *fileItem);
|
||||
|
||||
typedef struct _CArchiveDatabase
|
||||
{
|
||||
UInt32 NumPackStreams;
|
||||
CFileSize *PackSizes;
|
||||
Byte *PackCRCsDefined;
|
||||
UInt32 *PackCRCs;
|
||||
UInt32 NumFolders;
|
||||
CFolder *Folders;
|
||||
UInt32 NumFiles;
|
||||
CFileItem *Files;
|
||||
}CArchiveDatabase;
|
||||
|
||||
void SzArchiveDatabaseInit(CArchiveDatabase *db);
|
||||
void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *));
|
||||
|
||||
|
||||
#endif
|
||||
@@ -159,7 +159,11 @@ SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
|
||||
{
|
||||
LARGE_INTEGER value;
|
||||
value.LowPart = (DWORD)pos;
|
||||
value.HighPart = (LONG)(pos >> 32);
|
||||
value.HighPart = (LONG)((UInt64)pos >> 32);
|
||||
#ifdef _SZ_FILE_SIZE_32
|
||||
// VC 6.0 has bug with >> 32 shifts.
|
||||
value.HighPart = 0;
|
||||
#endif
|
||||
value.LowPart = SetFilePointer(s->File, value.LowPart, &value.HighPart, FILE_BEGIN);
|
||||
if (value.LowPart == 0xFFFFFFFF)
|
||||
if(GetLastError() != NO_ERROR)
|
||||
@@ -187,7 +191,7 @@ int main(int numargs, char *args[])
|
||||
ISzAlloc allocImp;
|
||||
ISzAlloc allocTempImp;
|
||||
|
||||
printf("\n7z ANSI-C Decoder 4.44 Copyright (c) 1999-2006 Igor Pavlov 2006-08-27\n");
|
||||
printf("\n7z ANSI-C Decoder 4.45 Copyright (c) 1999-2007 Igor Pavlov 2007-03-15\n");
|
||||
if (numargs == 1)
|
||||
{
|
||||
printf(
|
||||
|
||||
18
C/Archive/7z/7zMethodID.h
Executable file
18
C/Archive/7z/7zMethodID.h
Executable file
@@ -0,0 +1,18 @@
|
||||
/* 7zMethodID.h */
|
||||
|
||||
#ifndef __7Z_METHOD_ID_H
|
||||
#define __7Z_METHOD_ID_H
|
||||
|
||||
#include "../../Types.h"
|
||||
|
||||
#define kMethodIDSize 15
|
||||
|
||||
typedef struct _CMethodID
|
||||
{
|
||||
Byte ID[kMethodIDSize];
|
||||
Byte IDSize;
|
||||
} CMethodID;
|
||||
|
||||
int AreMethodsEqual(CMethodID *a1, CMethodID *a2);
|
||||
|
||||
#endif
|
||||
@@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /D "_SZ_FILE_SIZE_64" /YX /FD /c
|
||||
# ADD CPP /nologo /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -66,7 +66,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /D "_SZ_FILE_SIZE_64" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -109,6 +109,10 @@ SOURCE=..\..\7zCrc.c
|
||||
|
||||
SOURCE=..\..\7zCrc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Types.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
@@ -178,9 +182,5 @@ SOURCE=.\7zMethodID.c
|
||||
|
||||
SOURCE=.\7zMethodID.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zTypes.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
||||
@@ -8,11 +8,11 @@ O=O
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -GS-
|
||||
CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -GS- -WX -Gy
|
||||
CFLAGS_O1 = $(CFLAGS) -O1
|
||||
CFLAGS_O2 = $(CFLAGS) -O2
|
||||
|
||||
LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98
|
||||
LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98 -OPT:REF
|
||||
|
||||
PROGPATH = $O\$(PROG)
|
||||
|
||||
@@ -20,11 +20,13 @@ COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
|
||||
COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
|
||||
COMPL = $(CPP) $(CFLAGS_O1) $**
|
||||
|
||||
C_OBJS = \
|
||||
$O\7zCrc.obj \
|
||||
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zAlloc.obj \
|
||||
$O\7zBuffer.obj \
|
||||
$O\7zCrc.obj \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zHeader.obj \
|
||||
@@ -36,6 +38,7 @@ COMPL = $(CPP) $(CFLAGS_O1) $**
|
||||
OBJS = \
|
||||
$(7Z_OBJS) \
|
||||
$O\LzmaDecode.obj \
|
||||
$(C_OBJS) \
|
||||
|
||||
all: $(PROGPATH)
|
||||
|
||||
@@ -51,5 +54,7 @@ $(PROGPATH): $O $(OBJS)
|
||||
|
||||
$(7Z_OBJS): $(*B).c
|
||||
$(COMPL)
|
||||
$O\LzmaDecode.obj: ../../Compress/LZMA_C/$(*B).c
|
||||
$O\LzmaDecode.obj: ../../Compress/Lzma/$(*B).c
|
||||
$(COMPL_O2)
|
||||
$(C_OBJS): ../../$(*B).c
|
||||
$(COMPL_O2)
|
||||
|
||||
@@ -17,8 +17,8 @@ $(PROG): $(OBJS)
|
||||
7zBuffer.o: 7zBuffer.c
|
||||
$(CXX) $(CFLAGS) 7zBuffer.c
|
||||
|
||||
7zCrc.o: 7zCrc.c
|
||||
$(CXX) $(CFLAGS) 7zCrc.c
|
||||
7zCrc.o: ../../7zCrc.c
|
||||
$(CXX) $(CFLAGS) ../../7zCrc.c
|
||||
|
||||
7zDecode.o: 7zDecode.c
|
||||
$(CXX) $(CFLAGS) 7zDecode.c
|
||||
@@ -41,8 +41,8 @@ $(PROG): $(OBJS)
|
||||
7zMethodID.o: 7zMethodID.c
|
||||
$(CXX) $(CFLAGS) 7zMethodID.c
|
||||
|
||||
LzmaDecode.o: ../../Compress/LZMA_C/LzmaDecode.c
|
||||
$(CXX) $(CFLAGS) ../../Compress/LZMA_C/LzmaDecode.c
|
||||
LzmaDecode.o: ../../Compress/Lzma/LzmaDecode.c
|
||||
$(CXX) $(CFLAGS) ../../Compress/Lzma/LzmaDecode.c
|
||||
|
||||
|
||||
clean:
|
||||
|
||||
@@ -9,9 +9,9 @@ UInt32 ARM_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
|
||||
{
|
||||
if (data[i + 3] == 0xEB)
|
||||
{
|
||||
UInt32 dest;
|
||||
UInt32 src = (data[i + 2] << 16) | (data[i + 1] << 8) | (data[i + 0]);
|
||||
src <<= 2;
|
||||
UInt32 dest;
|
||||
if (encoding)
|
||||
dest = nowPos + i + 8 + src;
|
||||
else
|
||||
|
||||
@@ -10,6 +10,7 @@ UInt32 ARMThumb_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
|
||||
if ((data[i + 1] & 0xF8) == 0xF0 &&
|
||||
(data[i + 3] & 0xF8) == 0xF8)
|
||||
{
|
||||
UInt32 dest;
|
||||
UInt32 src =
|
||||
((data[i + 1] & 0x7) << 19) |
|
||||
(data[i + 0] << 11) |
|
||||
@@ -17,7 +18,6 @@ UInt32 ARMThumb_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
|
||||
(data[i + 2]);
|
||||
|
||||
src <<= 1;
|
||||
UInt32 dest;
|
||||
if (encoding)
|
||||
dest = nowPos + i + 4 + src;
|
||||
else
|
||||
|
||||
@@ -18,29 +18,32 @@ UInt32 IA64_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
|
||||
UInt32 instrTemplate = data[i] & 0x1F;
|
||||
UInt32 mask = kBranchTable[instrTemplate];
|
||||
UInt32 bitPos = 5;
|
||||
for (int slot = 0; slot < 3; slot++, bitPos += 41)
|
||||
int slot;
|
||||
for (slot = 0; slot < 3; slot++, bitPos += 41)
|
||||
{
|
||||
UInt32 bytePos, bitRes;
|
||||
UInt64 instruction, instNorm;
|
||||
int j;
|
||||
if (((mask >> slot) & 1) == 0)
|
||||
continue;
|
||||
UInt32 bytePos = (bitPos >> 3);
|
||||
UInt32 bitRes = bitPos & 0x7;
|
||||
UInt64 instruction = 0;
|
||||
int j;
|
||||
bytePos = (bitPos >> 3);
|
||||
bitRes = bitPos & 0x7;
|
||||
instruction = 0;
|
||||
for (j = 0; j < 6; j++)
|
||||
instruction += (UInt64)(data[i + j + bytePos]) << (8 * j);
|
||||
|
||||
UInt64 instNorm = instruction >> bitRes;
|
||||
instNorm = instruction >> bitRes;
|
||||
if (((instNorm >> 37) & 0xF) == 0x5
|
||||
&& ((instNorm >> 9) & 0x7) == 0
|
||||
/* && (instNorm & 0x3F)== 0 */
|
||||
)
|
||||
{
|
||||
UInt32 src = UInt32((instNorm >> 13) & 0xFFFFF);
|
||||
src |= ((instNorm >> 36) & 1) << 20;
|
||||
UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
|
||||
UInt32 dest;
|
||||
src |= ((UInt32)(instNorm >> 36) & 1) << 20;
|
||||
|
||||
src <<= 4;
|
||||
|
||||
UInt32 dest;
|
||||
if (encoding)
|
||||
dest = nowPos + i + src;
|
||||
else
|
||||
@@ -48,14 +51,14 @@ UInt32 IA64_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
|
||||
|
||||
dest >>= 4;
|
||||
|
||||
instNorm &= ~(UInt64(0x8FFFFF) << 13);
|
||||
instNorm |= (UInt64(dest & 0xFFFFF) << 13);
|
||||
instNorm |= (UInt64(dest & 0x100000) << (36 - 20));
|
||||
instNorm &= ~((UInt64)(0x8FFFFF) << 13);
|
||||
instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
|
||||
instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
|
||||
|
||||
instruction &= (1 << bitRes) - 1;
|
||||
instruction |= (instNorm << bitRes);
|
||||
for (j = 0; j < 6; j++)
|
||||
data[i + j + bytePos] = Byte(instruction >> (8 * j));
|
||||
data[i + j + bytePos] = (Byte)(instruction >> (8 * j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ UInt32 SPARC_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
|
||||
((UInt32)data[i + 1] << 16) |
|
||||
((UInt32)data[i + 2] << 8) |
|
||||
((UInt32)data[i + 3]);
|
||||
UInt32 dest;
|
||||
|
||||
src <<= 2;
|
||||
UInt32 dest;
|
||||
if (encoding)
|
||||
dest = nowPos + i + src;
|
||||
else
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
#include "BranchTypes.h"
|
||||
|
||||
UInt32 SPARC_B_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding);
|
||||
UInt32 SPARC_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,4 +22,17 @@ typedef unsigned int UInt32;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT64_DEFINED
|
||||
#define _7ZIP_UINT64_DEFINED
|
||||
#ifdef _SZ_NO_INT_64
|
||||
typedef unsigned long UInt64;
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned __int64 UInt64;
|
||||
#else
|
||||
typedef unsigned long long int UInt64;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* MatchFinderMt.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include "../../7zCrc.h"
|
||||
#include "LzHash.h"
|
||||
|
||||
@@ -460,7 +460,7 @@ void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc)
|
||||
#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)
|
||||
|
||||
static unsigned StdCall HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
|
||||
static unsigned StdCall BtThreadFunc2(void *p) { BtThreadFunc((CMatchFinderMt *)p); return 0; }
|
||||
static unsigned StdCall BtThreadFunc2(void *p) { alloca(0x180); BtThreadFunc((CMatchFinderMt *)p); return 0; }
|
||||
|
||||
HRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
|
||||
UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc)
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include "../../Threads.h"
|
||||
#include "MatchFinder.h"
|
||||
|
||||
#define _LZ_MT
|
||||
|
||||
#define kMtHashBlockSize (1 << 13)
|
||||
#define kMtHashNumBlocks (1 << 3)
|
||||
#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
|
||||
|
||||
20
C/Types.h
20
C/Types.h
@@ -48,14 +48,14 @@ typedef unsigned long long int UInt64;
|
||||
#endif
|
||||
|
||||
|
||||
/* #define _SZ_FILE_SIZE_64 */
|
||||
/* Use _SZ_FILE_SIZE_64 if you need support for files larger than 4 GB*/
|
||||
/* #define _SZ_FILE_SIZE_32 */
|
||||
/* You can define _SZ_FILE_SIZE_32, if you don't need support for files larger than 4 GB*/
|
||||
|
||||
#ifndef CFileSize
|
||||
#ifdef _SZ_FILE_SIZE_64
|
||||
typedef UInt64 CFileSize;
|
||||
#else
|
||||
#ifdef _SZ_FILE_SIZE_32
|
||||
typedef UInt32 CFileSize;
|
||||
#else
|
||||
typedef UInt64 CFileSize;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -76,7 +76,7 @@ typedef int HRes;
|
||||
|
||||
|
||||
#ifndef RINOK
|
||||
#define RINOK(x) { int __result_ = (x); if(__result_ != 0) return __result_; }
|
||||
#define RINOK(x) { HRes __result_ = (x); if(__result_ != 0) return __result_; }
|
||||
#endif
|
||||
|
||||
typedef int Bool;
|
||||
@@ -89,4 +89,12 @@ typedef int Bool;
|
||||
#define StdCall
|
||||
#endif
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
#define MY_FAST_CALL __declspec(noinline) __fastcall
|
||||
#elif defined( _MSC_VER)
|
||||
#define MY_FAST_CALL __fastcall
|
||||
#else
|
||||
#define MY_FAST_CALL
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,7 +43,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
@@ -70,7 +70,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
@@ -97,7 +97,11 @@ SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
SOURCE=..\ArchiveExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -194,22 +198,6 @@ SOURCE=.\7zItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zMethodID.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zMethodID.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zMethods.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zMethods.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -226,6 +214,10 @@ SOURCE=.\7zProperties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zSpecStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -278,14 +270,6 @@ SOURCE=..\..\PropID.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Buffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -294,10 +278,6 @@ SOURCE=..\..\..\Common\CRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\DynamicBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -354,22 +334,6 @@ SOURCE=..\..\..\Common\Vector.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderLoader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderMixer2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -394,14 +358,6 @@ SOURCE=..\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\FilterCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\FilterCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\InStreamWithCRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -446,6 +402,22 @@ SOURCE=..\Common\ParseProperties.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CreateCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CreateCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilterCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilterCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InOutTempBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -470,6 +442,14 @@ SOURCE=..\..\Common\LockedStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\MethodId.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\MethodId.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -486,6 +466,14 @@ SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\RegisterArc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\RegisterCodec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamBinder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -585,6 +573,28 @@ SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "C"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7z.ico
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
#ifndef __7Z_COMPRESSION_MODE_H
|
||||
#define __7Z_COMPRESSION_MODE_H
|
||||
|
||||
#include "../../../Common/String.h"
|
||||
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
|
||||
#include "7zMethodID.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
@@ -18,18 +20,10 @@ struct CProperty
|
||||
|
||||
struct CMethodFull
|
||||
{
|
||||
CMethodID MethodID;
|
||||
CMethodId MethodID;
|
||||
UInt32 NumInStreams;
|
||||
UInt32 NumOutStreams;
|
||||
bool IsSimpleCoder() const
|
||||
{ return (NumInStreams == 1) && (NumOutStreams == 1); }
|
||||
|
||||
#ifdef EXCLUDE_COM
|
||||
#else
|
||||
CLSID EncoderClassID;
|
||||
CSysString FilePath;
|
||||
#endif
|
||||
|
||||
bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
|
||||
CObjectVector<CProperty> CoderProperties;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,61 +9,8 @@
|
||||
#include "../../Common/StreamObjects.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
#include "../Common/FilterCoder.h"
|
||||
|
||||
#include "7zMethods.h"
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
#include "../../Compress/LZMA/LZMADecoder.h"
|
||||
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
#include "../../Compress/PPMD/PPMDDecoder.h"
|
||||
static NArchive::N7z::CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
#include "../../Compress/Branch/x86.h"
|
||||
static NArchive::N7z::CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
#include "../../Compress/Branch/x86_2.h"
|
||||
static NArchive::N7z::CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
#ifndef COMPRESS_DEFLATE_DECODER
|
||||
#define COMPRESS_DEFLATE_DECODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_DECODER
|
||||
#include "../../Compress/Deflate/DeflateDecoder.h"
|
||||
static NArchive::N7z::CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2
|
||||
#ifndef COMPRESS_BZIP2_DECODER
|
||||
#define COMPRESS_BZIP2_DECODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_DECODER
|
||||
#include "../../Compress/BZip2/BZip2Decoder.h"
|
||||
static NArchive::N7z::CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTO_7ZAES
|
||||
#include "../../Crypto/7zAES/7zAES.h"
|
||||
static NArchive::N7z::CMethodID k_7zAES = { { 0x6, 0xF1, 0x07, 0x01 }, 4 };
|
||||
#endif
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../Common/FilterCoder.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
@@ -88,8 +35,7 @@ static void ConvertFolderItemInfoToBindInfo(const CFolder &folder,
|
||||
coderStreamsInfo.NumInStreams = (UInt32)coderInfo.NumInStreams;
|
||||
coderStreamsInfo.NumOutStreams = (UInt32)coderInfo.NumOutStreams;
|
||||
bindInfo.Coders.Add(coderStreamsInfo);
|
||||
const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
|
||||
bindInfo.CoderMethodIDs.Add(altCoderInfo.MethodID);
|
||||
bindInfo.CoderMethodIDs.Add(coderInfo.MethodID);
|
||||
for (UInt32 j = 0; j < coderStreamsInfo.NumOutStreams; j++, outStreamIndex++)
|
||||
if (folder.FindBindPairForOutStream(outStreamIndex) < 0)
|
||||
bindInfo.OutStreams.Add(outStreamIndex);
|
||||
@@ -141,12 +87,11 @@ CDecoder::CDecoder(bool multiThread)
|
||||
#endif
|
||||
_multiThread = multiThread;
|
||||
_bindInfoExPrevIsDefined = false;
|
||||
#ifndef EXCLUDE_COM
|
||||
LoadMethodMap();
|
||||
#endif
|
||||
}
|
||||
|
||||
HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
HRESULT CDecoder::Decode(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
UInt64 startPos,
|
||||
const UInt64 *packSizes,
|
||||
const CFolder &folderInfo,
|
||||
@@ -217,72 +162,21 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
for (i = 0; i < numCoders; i++)
|
||||
{
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
|
||||
#ifndef EXCLUDE_COM
|
||||
CMethodInfo methodInfo;
|
||||
if (!GetMethodInfo(altCoderInfo.MethodID, methodInfo))
|
||||
return E_NOTIMPL;
|
||||
#endif
|
||||
|
||||
|
||||
CMyComPtr<ICompressCoder> decoder;
|
||||
CMyComPtr<ICompressCoder2> decoder2;
|
||||
RINOK(CreateCoder(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
coderInfo.MethodID, decoder, decoder2, false));
|
||||
CMyComPtr<IUnknown> decoderUnknown;
|
||||
if (coderInfo.IsSimpleCoder())
|
||||
{
|
||||
CMyComPtr<ICompressCoder> decoder;
|
||||
CMyComPtr<ICompressFilter> filter;
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
if (altCoderInfo.MethodID == k_LZMA)
|
||||
decoder = new NCompress::NLZMA::CDecoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
if (altCoderInfo.MethodID == k_PPMD)
|
||||
decoder = new NCompress::NPPMD::CDecoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
if (altCoderInfo.MethodID == k_BCJ_X86)
|
||||
filter = new CBCJ_x86_Decoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_DECODER
|
||||
if (altCoderInfo.MethodID == k_Deflate)
|
||||
decoder = new NCompress::NDeflate::NDecoder::CCOMCoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_DECODER
|
||||
if (altCoderInfo.MethodID == k_BZip2)
|
||||
decoder = new NCompress::NBZip2::CDecoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
if (altCoderInfo.MethodID == k_Copy)
|
||||
decoder = new NCompress::CCopyCoder;
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTO_7ZAES
|
||||
if (altCoderInfo.MethodID == k_7zAES)
|
||||
filter = new NCrypto::NSevenZ::CDecoder;
|
||||
#endif
|
||||
|
||||
if (filter)
|
||||
{
|
||||
CFilterCoder *coderSpec = new CFilterCoder;
|
||||
decoder = coderSpec;
|
||||
coderSpec->Filter = filter;
|
||||
}
|
||||
#ifndef EXCLUDE_COM
|
||||
if (decoder == 0)
|
||||
{
|
||||
RINOK(_libraries.CreateCoderSpec(methodInfo.FilePath,
|
||||
methodInfo.Decoder, &decoder));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (decoder == 0)
|
||||
return E_NOTIMPL;
|
||||
|
||||
_decoders.Add((IUnknown *)decoder);
|
||||
|
||||
decoderUnknown = (IUnknown *)decoder;
|
||||
|
||||
if (_multiThread)
|
||||
_mixerCoderMTSpec->AddCoder(decoder);
|
||||
#ifdef _ST_MODE
|
||||
@@ -292,32 +186,25 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
}
|
||||
else
|
||||
{
|
||||
CMyComPtr<ICompressCoder2> decoder;
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
if (altCoderInfo.MethodID == k_BCJ2)
|
||||
decoder = new CBCJ2_x86_Decoder;
|
||||
#endif
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
if (decoder == 0)
|
||||
{
|
||||
RINOK(_libraries.CreateCoder2(methodInfo.FilePath,
|
||||
methodInfo.Decoder, &decoder));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (decoder == 0)
|
||||
if (decoder2 == 0)
|
||||
return E_NOTIMPL;
|
||||
|
||||
_decoders.Add((IUnknown *)decoder);
|
||||
decoderUnknown = (IUnknown *)decoder2;
|
||||
if (_multiThread)
|
||||
_mixerCoderMTSpec->AddCoder2(decoder);
|
||||
_mixerCoderMTSpec->AddCoder2(decoder2);
|
||||
#ifdef _ST_MODE
|
||||
else
|
||||
_mixerCoderSTSpec->AddCoder2(decoder, false);
|
||||
_mixerCoderSTSpec->AddCoder2(decoder2, false);
|
||||
#endif
|
||||
}
|
||||
_decoders.Add(decoderUnknown);
|
||||
#ifdef EXTERNAL_CODECS
|
||||
CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
|
||||
decoderUnknown.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
|
||||
if (setCompressCodecsInfo)
|
||||
{
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecsInfo));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
_bindInfoExPrev = bindInfo;
|
||||
_bindInfoExPrevIsDefined = true;
|
||||
@@ -332,7 +219,6 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
for (i = 0; i < numCoders; i++)
|
||||
{
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
|
||||
CMyComPtr<IUnknown> &decoder = _decoders[coderIndex];
|
||||
|
||||
{
|
||||
@@ -340,7 +226,7 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
|
||||
if (setDecoderProperties)
|
||||
{
|
||||
const CByteBuffer &properties = altCoderInfo.Properties;
|
||||
const CByteBuffer &properties = coderInfo.Properties;
|
||||
size_t size = properties.GetCapacity();
|
||||
if (size > 0xFFFFFFFF)
|
||||
return E_NOTIMPL;
|
||||
|
||||
@@ -11,9 +11,8 @@
|
||||
#ifdef _ST_MODE
|
||||
#include "../Common/CoderMixer2ST.h"
|
||||
#endif
|
||||
#ifndef EXCLUDE_COM
|
||||
#include "../Common/CoderLoader.h"
|
||||
#endif
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#include "7zItem.h"
|
||||
|
||||
@@ -22,7 +21,7 @@ namespace N7z {
|
||||
|
||||
struct CBindInfoEx: public NCoderMixer2::CBindInfo
|
||||
{
|
||||
CRecordVector<CMethodID> CoderMethodIDs;
|
||||
CRecordVector<CMethodId> CoderMethodIDs;
|
||||
void Clear()
|
||||
{
|
||||
CBindInfo::Clear();
|
||||
@@ -32,10 +31,6 @@ struct CBindInfoEx: public NCoderMixer2::CBindInfo
|
||||
|
||||
class CDecoder
|
||||
{
|
||||
#ifndef EXCLUDE_COM
|
||||
CCoderLibraries _libraries;
|
||||
#endif
|
||||
|
||||
bool _bindInfoExPrevIsDefined;
|
||||
CBindInfoEx _bindInfoExPrev;
|
||||
|
||||
@@ -51,7 +46,9 @@ class CDecoder
|
||||
// CObjectVector<CMyComPtr<ICompressCoder2> > _decoders2;
|
||||
public:
|
||||
CDecoder(bool multiThread);
|
||||
HRESULT Decode(IInStream *inStream,
|
||||
HRESULT Decode(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
UInt64 startPos,
|
||||
const UInt64 *packSizes,
|
||||
const CFolder &folder,
|
||||
|
||||
@@ -4,84 +4,24 @@
|
||||
|
||||
#include "7zEncode.h"
|
||||
#include "7zSpecStream.h"
|
||||
#include "7zMethods.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
#include "../../Common/InOutTempBuffer.h"
|
||||
#include "../../Common/StreamObjects.h"
|
||||
#include "../Common/FilterCoder.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../Common/FilterCoder.h"
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#endif
|
||||
|
||||
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static NArchive::N7z::CMethodID k_LZMA2 = { { 0x3, 0x1, 0x2 }, 3 };
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
#include "../../Compress/LZMA/LZMAEncoder.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
#include "../../Compress/PPMD/PPMDEncoder.h"
|
||||
static NArchive::N7z::CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
static NArchive::N7z::CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
#include "../../Compress/Branch/x86.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
static NArchive::N7z::CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
#include "../../Compress/Branch/x86_2.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
#ifndef COMPRESS_DEFLATE_ENCODER
|
||||
#define COMPRESS_DEFLATE_ENCODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_ENCODER
|
||||
#include "../../Compress/Deflate/DeflateEncoder.h"
|
||||
static NArchive::N7z::CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2
|
||||
#ifndef COMPRESS_BZIP2_ENCODER
|
||||
#define COMPRESS_BZIP2_ENCODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_ENCODER
|
||||
#include "../../Compress/BZip2/BZip2Encoder.h"
|
||||
static NArchive::N7z::CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
|
||||
#endif
|
||||
|
||||
static NArchive::N7z::CMethodID k_AES = { { 0x6, 0xF1, 0x7, 0x1}, 4 };
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
static const wchar_t *kCryproMethod = L"7zAES";
|
||||
/*
|
||||
// {23170F69-40C1-278B-06F1-070100000100}
|
||||
DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00);
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTO_7ZAES
|
||||
#include "../../Crypto/7zAES/7zAES.h"
|
||||
#endif
|
||||
static UInt64 k_LZMA = 0x030101;
|
||||
// static UInt64 k_LZMA2 = 0x030102;
|
||||
static UInt64 k_AES = 0x06F10701;
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
static void ConvertBindInfoToFolderItemInfo(const NCoderMixer2::CBindInfo &bindInfo,
|
||||
const CRecordVector<CMethodID> decompressionMethods,
|
||||
const CRecordVector<CMethodId> decompressionMethods,
|
||||
CFolder &folder)
|
||||
{
|
||||
folder.Coders.Clear();
|
||||
@@ -103,20 +43,16 @@ static void ConvertBindInfoToFolderItemInfo(const NCoderMixer2::CBindInfo &bindI
|
||||
const NCoderMixer2::CCoderStreamsInfo &coderStreamsInfo = bindInfo.Coders[i];
|
||||
coderInfo.NumInStreams = coderStreamsInfo.NumInStreams;
|
||||
coderInfo.NumOutStreams = coderStreamsInfo.NumOutStreams;
|
||||
|
||||
// coderInfo.MethodID = decompressionMethods[i];
|
||||
// if (coderInfo.AltCoders.Size() == 0)
|
||||
coderInfo.AltCoders.Add(CAltCoderInfo());
|
||||
CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
|
||||
altCoderInfo.MethodID = decompressionMethods[i];
|
||||
|
||||
coderInfo.MethodID = decompressionMethods[i];
|
||||
folder.Coders.Add(coderInfo);
|
||||
}
|
||||
for (i = 0; i < bindInfo.InStreams.Size(); i++)
|
||||
folder.PackStreams.Add(bindInfo.InStreams[i]);
|
||||
}
|
||||
|
||||
HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
HRESULT CEncoder::CreateMixerCoder(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const UInt64 *inSizeForReduce)
|
||||
{
|
||||
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
|
||||
_mixerCoder = _mixerCoderSpec;
|
||||
@@ -127,88 +63,19 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
_codersInfo.Add(CCoderInfo());
|
||||
CCoderInfo &encodingInfo = _codersInfo.Back();
|
||||
CMyComPtr<ICompressCoder> encoder;
|
||||
CMyComPtr<ICompressFilter> filter;
|
||||
CMyComPtr<ICompressCoder2> encoder2;
|
||||
|
||||
if (methodFull.IsSimpleCoder())
|
||||
{
|
||||
#ifdef COMPRESS_LZMA
|
||||
if (methodFull.MethodID == k_LZMA)
|
||||
encoder = new NCompress::NLZMA::CEncoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
if (methodFull.MethodID == k_PPMD)
|
||||
encoder = new NCompress::NPPMD::CEncoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
if (methodFull.MethodID == k_BCJ_X86)
|
||||
filter = new CBCJ_x86_Encoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
if (methodFull.MethodID == k_Copy)
|
||||
encoder = new NCompress::CCopyCoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_ENCODER
|
||||
if (methodFull.MethodID == k_BZip2)
|
||||
encoder = new NCompress::NBZip2::CEncoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_ENCODER
|
||||
if (methodFull.MethodID == k_Deflate)
|
||||
encoder = new NCompress::NDeflate::NEncoder::CCOMCoder;
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTO_7ZAES
|
||||
if (methodFull.MethodID == k_AES)
|
||||
filter = new NCrypto::NSevenZ::CEncoder;
|
||||
#endif
|
||||
|
||||
if (filter)
|
||||
{
|
||||
CFilterCoder *coderSpec = new CFilterCoder;
|
||||
encoder = coderSpec;
|
||||
coderSpec->Filter = filter;
|
||||
}
|
||||
RINOK(CreateCoder(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodFull.MethodID, encoder, encoder2, true));
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
if (encoder == 0)
|
||||
{
|
||||
RINOK(_libraries.CreateCoderSpec(methodFull.FilePath,
|
||||
methodFull.EncoderClassID, &encoder));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (encoder == 0)
|
||||
return E_FAIL;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef COMPRESS_BCJ2
|
||||
if (methodFull.MethodID == k_BCJ2)
|
||||
encoder2 = new CBCJ2_x86_Encoder;
|
||||
#endif
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
if (encoder2 == 0)
|
||||
{
|
||||
RINOK(_libraries.CreateCoder2(methodFull.FilePath,
|
||||
methodFull.EncoderClassID, &encoder2));
|
||||
}
|
||||
#else
|
||||
|
||||
if (encoder2 == 0)
|
||||
return E_FAIL;
|
||||
#endif
|
||||
}
|
||||
if (!encoder && !encoder2)
|
||||
return E_FAIL;
|
||||
|
||||
bool tryReduce = false;
|
||||
UInt32 reducedDictionarySize = 1 << 10;
|
||||
if (inSizeForReduce != 0 && (methodFull.MethodID == k_LZMA || methodFull.MethodID == k_LZMA2))
|
||||
if (inSizeForReduce != 0 && (methodFull.MethodID == k_LZMA /* || methodFull.MethodID == k_LZMA2 */))
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -230,7 +97,7 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
}
|
||||
}
|
||||
|
||||
CMyComPtr<IUnknown> encoderCommon = methodFull.IsSimpleCoder() ? (IUnknown *)encoder : (IUnknown *)encoder2;
|
||||
CMyComPtr<IUnknown> encoderCommon = encoder ? (IUnknown *)encoder : (IUnknown *)encoder2;
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
{
|
||||
@@ -284,14 +151,18 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
|
||||
size_t size = outStreamSpec->GetSize();
|
||||
|
||||
// encodingInfo.Properties.SetCapacity(size);
|
||||
if (encodingInfo.AltCoders.Size() == 0)
|
||||
encodingInfo.AltCoders.Add(CAltCoderInfo());
|
||||
CAltCoderInfo &altCoderInfo = encodingInfo.AltCoders.Front();
|
||||
altCoderInfo.Properties.SetCapacity(size);
|
||||
|
||||
memmove(altCoderInfo.Properties, outStreamSpec->GetBuffer(), size);
|
||||
encodingInfo.Properties.SetCapacity(size);
|
||||
memmove(encodingInfo.Properties, outStreamSpec->GetBuffer(), size);
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
|
||||
encoderCommon.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
|
||||
if (setCompressCodecsInfo)
|
||||
{
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecsInfo));
|
||||
}
|
||||
#endif
|
||||
|
||||
CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
|
||||
encoderCommon.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
|
||||
@@ -310,7 +181,7 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, sizeInBytes));
|
||||
}
|
||||
|
||||
if (methodFull.IsSimpleCoder())
|
||||
if (encoder)
|
||||
_mixerCoderSpec->AddCoder(encoder);
|
||||
else
|
||||
_mixerCoderSpec->AddCoder2(encoder2);
|
||||
@@ -318,16 +189,20 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CEncoder::Encode(ISequentialInStream *inStream,
|
||||
HRESULT CEncoder::Encode(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
ISequentialInStream *inStream,
|
||||
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
|
||||
CFolder &folderItem,
|
||||
ISequentialOutStream *outStream,
|
||||
CRecordVector<UInt64> &packSizes,
|
||||
ICompressProgressInfo *compressProgress)
|
||||
{
|
||||
RINOK(EncoderConstr());
|
||||
|
||||
if (_mixerCoderSpec == NULL)
|
||||
{
|
||||
RINOK(CreateMixerCoder(inSizeForReduce));
|
||||
RINOK(CreateMixerCoder(EXTERNAL_CODECS_LOC_VARS inSizeForReduce));
|
||||
}
|
||||
_mixerCoderSpec->ReInit();
|
||||
// _mixerCoderSpec->SetCoderInfo(0, NULL, NULL, progress);
|
||||
@@ -423,50 +298,41 @@ HRESULT CEncoder::Encode(ISequentialInStream *inStream,
|
||||
folderItem.UnPackSizes.Add(streamSize);
|
||||
}
|
||||
for (i = numMethods - 1; i >= 0; i--)
|
||||
{
|
||||
// folderItem.Coders[numMethods - 1 - i].Properties = _codersInfo[i].Properties;
|
||||
for (int j = 0; j < _codersInfo[i].AltCoders.Size(); j++)
|
||||
folderItem.Coders[numMethods - 1 - i].AltCoders[j].Properties
|
||||
= _codersInfo[i].AltCoders[j].Properties;
|
||||
}
|
||||
folderItem.Coders[numMethods - 1 - i].Properties = _codersInfo[i].Properties;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
_bindReverseConverter(0)
|
||||
_bindReverseConverter(0),
|
||||
_constructed(false)
|
||||
{
|
||||
if (options.IsEmpty())
|
||||
throw 1;
|
||||
|
||||
_options = options;
|
||||
_mixerCoderSpec = NULL;
|
||||
}
|
||||
|
||||
if (options.Methods.IsEmpty())
|
||||
HRESULT CEncoder::EncoderConstr()
|
||||
{
|
||||
if (_constructed)
|
||||
return S_OK;
|
||||
if (_options.Methods.IsEmpty())
|
||||
{
|
||||
// it has only password method;
|
||||
if (!options.PasswordIsDefined)
|
||||
if (!_options.PasswordIsDefined)
|
||||
throw 1;
|
||||
if (!options.Binds.IsEmpty())
|
||||
if (!_options.Binds.IsEmpty())
|
||||
throw 1;
|
||||
NCoderMixer2::CCoderStreamsInfo coderStreamsInfo;
|
||||
CMethodFull method;
|
||||
|
||||
method.NumInStreams = 1;
|
||||
method.NumOutStreams = 1;
|
||||
coderStreamsInfo.NumInStreams = method.NumOutStreams;
|
||||
coderStreamsInfo.NumOutStreams = method.NumInStreams;
|
||||
coderStreamsInfo.NumInStreams = 1;
|
||||
coderStreamsInfo.NumOutStreams = 1;
|
||||
method.MethodID = k_AES;
|
||||
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
CMethodInfo2 methodInfo;
|
||||
if (!GetMethodInfo(kCryproMethod, methodInfo))
|
||||
throw 2;
|
||||
method.FilePath = methodInfo.FilePath;
|
||||
method.EncoderClassID = methodInfo.Encoder;
|
||||
// method.EncoderClassID = CLSID_CCrypto7zAESEncoder;
|
||||
#endif
|
||||
|
||||
_options.Methods.Add(method);
|
||||
_bindInfo.Coders.Add(coderStreamsInfo);
|
||||
@@ -479,15 +345,15 @@ CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
|
||||
UInt32 numInStreams = 0, numOutStreams = 0;
|
||||
int i;
|
||||
for (i = 0; i < options.Methods.Size(); i++)
|
||||
for (i = 0; i < _options.Methods.Size(); i++)
|
||||
{
|
||||
const CMethodFull &methodFull = options.Methods[i];
|
||||
const CMethodFull &methodFull = _options.Methods[i];
|
||||
NCoderMixer2::CCoderStreamsInfo coderStreamsInfo;
|
||||
coderStreamsInfo.NumInStreams = methodFull.NumOutStreams;
|
||||
coderStreamsInfo.NumOutStreams = methodFull.NumInStreams;
|
||||
if (options.Binds.IsEmpty())
|
||||
if (_options.Binds.IsEmpty())
|
||||
{
|
||||
if (i < options.Methods.Size() - 1)
|
||||
if (i < _options.Methods.Size() - 1)
|
||||
{
|
||||
NCoderMixer2::CBindPair bindPair;
|
||||
bindPair.InIndex = numInStreams + coderStreamsInfo.NumInStreams;
|
||||
@@ -506,12 +372,12 @@ CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
_bindInfo.Coders.Add(coderStreamsInfo);
|
||||
}
|
||||
|
||||
if (!options.Binds.IsEmpty())
|
||||
if (!_options.Binds.IsEmpty())
|
||||
{
|
||||
for (i = 0; i < options.Binds.Size(); i++)
|
||||
for (i = 0; i < _options.Binds.Size(); i++)
|
||||
{
|
||||
NCoderMixer2::CBindPair bindPair;
|
||||
const CBind &bind = options.Binds[i];
|
||||
const CBind &bind = _options.Binds[i];
|
||||
bindPair.InIndex = _bindInfo.GetCoderInStreamIndex(bind.InCoder) + bind.InStream;
|
||||
bindPair.OutIndex = _bindInfo.GetCoderOutStreamIndex(bind.OutCoder) + bind.OutStream;
|
||||
_bindInfo.BindPairs.Add(bindPair);
|
||||
@@ -579,15 +445,6 @@ CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
coderStreamsInfo.NumOutStreams = method.NumInStreams;
|
||||
method.MethodID = k_AES;
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
CMethodInfo2 methodInfo;
|
||||
if (!GetMethodInfo(kCryproMethod, methodInfo))
|
||||
throw 2;
|
||||
method.FilePath = methodInfo.FilePath;
|
||||
method.EncoderClassID = methodInfo.Encoder;
|
||||
// method.EncoderClassID = CLSID_CCrypto7zAESEncoder;
|
||||
#endif
|
||||
|
||||
_options.Methods.Add(method);
|
||||
_bindInfo.Coders.Add(coderStreamsInfo);
|
||||
_bindInfo.OutStreams.Add(numOutStreams + i);
|
||||
@@ -604,6 +461,8 @@ CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
|
||||
_bindReverseConverter = new NCoderMixer2::CBindReverseConverter(_bindInfo);
|
||||
_bindReverseConverter->CreateReverseBindInfo(_decompressBindInfo);
|
||||
_constructed = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CEncoder::~CEncoder()
|
||||
|
||||
@@ -12,23 +12,15 @@
|
||||
#ifdef _ST_MODE
|
||||
#include "../Common/CoderMixer2ST.h"
|
||||
#endif
|
||||
#ifndef EXCLUDE_COM
|
||||
#include "../Common/CoderLoader.h"
|
||||
#endif
|
||||
#include "7zMethods.h"
|
||||
#include "7zItem.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
class CEncoder
|
||||
{
|
||||
#ifndef EXCLUDE_COM
|
||||
// CMethodMap _methodMap;
|
||||
// it must be in top of objects
|
||||
CCoderLibraries _libraries;
|
||||
#endif
|
||||
|
||||
NCoderMixer2::CCoderMixer2MT *_mixerCoderSpec;
|
||||
CMyComPtr<ICompressCoder2> _mixerCoder;
|
||||
|
||||
@@ -38,14 +30,19 @@ class CEncoder
|
||||
NCoderMixer2::CBindInfo _bindInfo;
|
||||
NCoderMixer2::CBindInfo _decompressBindInfo;
|
||||
NCoderMixer2::CBindReverseConverter *_bindReverseConverter;
|
||||
CRecordVector<CMethodID> _decompressionMethods;
|
||||
CRecordVector<CMethodId> _decompressionMethods;
|
||||
|
||||
HRESULT CreateMixerCoder(const UInt64 *inSizeForReduce);
|
||||
HRESULT CreateMixerCoder(DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const UInt64 *inSizeForReduce);
|
||||
|
||||
bool _constructed;
|
||||
public:
|
||||
CEncoder(const CCompressionMethodMode &options);
|
||||
~CEncoder();
|
||||
HRESULT Encode(ISequentialInStream *inStream,
|
||||
HRESULT EncoderConstr();
|
||||
HRESULT Encode(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
ISequentialInStream *inStream,
|
||||
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
|
||||
CFolder &folderItem,
|
||||
ISequentialOutStream *outStream,
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "7zHandler.h"
|
||||
#include "7zFolderOutStream.h"
|
||||
#include "7zMethods.h"
|
||||
#include "7zDecode.h"
|
||||
// #include "7z1Decode.h"
|
||||
|
||||
@@ -216,6 +215,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
try
|
||||
{
|
||||
HRESULT result = decoder.Decode(
|
||||
EXTERNAL_CODECS_VARS
|
||||
#ifdef _7Z_VOL
|
||||
volume.Stream,
|
||||
#else
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
extern UString ConvertMethodIdToString(UInt64 id);
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
@@ -33,9 +35,6 @@ CHandler::CHandler()
|
||||
#ifndef EXTRACT_ONLY
|
||||
Init();
|
||||
#endif
|
||||
#ifndef EXCLUDE_COM
|
||||
LoadMethodMap();
|
||||
#endif
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
@@ -124,14 +123,9 @@ static UString GetStringForSizeValue(UInt32 value)
|
||||
return result;
|
||||
}
|
||||
|
||||
static CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static CMethodID k_BCJ = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
static CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
|
||||
static CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
|
||||
static CMethodID k_Deflate64 = { { 0x4, 0x1, 0x9 }, 3 };
|
||||
static CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
|
||||
static const UInt64 k_Copy = 0x0;
|
||||
static const UInt64 k_LZMA = 0x030101;
|
||||
static const UInt64 k_PPMD = 0x030401;
|
||||
|
||||
static wchar_t GetHex(Byte value)
|
||||
{
|
||||
@@ -147,7 +141,7 @@ static inline UString GetHex2(Byte value)
|
||||
|
||||
#endif
|
||||
|
||||
static CMethodID k_AES = { { 0x6, 0xF1, 0x7, 0x1}, 4 };
|
||||
static const UInt64 k_AES = 0x06F10701;
|
||||
|
||||
static inline UInt32 GetUInt32FromMemLE(const Byte *p)
|
||||
{
|
||||
@@ -161,12 +155,8 @@ bool CHandler::IsEncrypted(UInt32 index2) const
|
||||
{
|
||||
const CFolder &folderInfo = _database.Folders[folderIndex];
|
||||
for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
for (int j = 0; j < coderInfo.AltCoders.Size(); j++)
|
||||
if (coderInfo.AltCoders[j].MethodID == k_AES)
|
||||
return true;
|
||||
}
|
||||
if (folderInfo.Coders[i].MethodID == k_AES)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -276,81 +266,45 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
if (!methodsString.IsEmpty())
|
||||
methodsString += L' ';
|
||||
CMethodInfo methodInfo;
|
||||
|
||||
bool methodIsKnown;
|
||||
|
||||
for (int j = 0; j < coderInfo.AltCoders.Size(); j++)
|
||||
{
|
||||
if (j > 0)
|
||||
methodsString += L"|";
|
||||
const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders[j];
|
||||
|
||||
UString methodName;
|
||||
#ifdef NO_REGISTRY
|
||||
|
||||
methodIsKnown = true;
|
||||
if (altCoderInfo.MethodID == k_Copy)
|
||||
methodName = L"Copy";
|
||||
else if (altCoderInfo.MethodID == k_LZMA)
|
||||
methodName = L"LZMA";
|
||||
else if (altCoderInfo.MethodID == k_BCJ)
|
||||
methodName = L"BCJ";
|
||||
else if (altCoderInfo.MethodID == k_BCJ2)
|
||||
methodName = L"BCJ2";
|
||||
else if (altCoderInfo.MethodID == k_PPMD)
|
||||
methodName = L"PPMD";
|
||||
else if (altCoderInfo.MethodID == k_Deflate)
|
||||
methodName = L"Deflate";
|
||||
else if (altCoderInfo.MethodID == k_Deflate64)
|
||||
methodName = L"Deflate64";
|
||||
else if (altCoderInfo.MethodID == k_BZip2)
|
||||
methodName = L"BZip2";
|
||||
else if (altCoderInfo.MethodID == k_AES)
|
||||
methodName = L"7zAES";
|
||||
else
|
||||
methodIsKnown = false;
|
||||
|
||||
#else
|
||||
|
||||
methodIsKnown = GetMethodInfo(
|
||||
altCoderInfo.MethodID, methodInfo);
|
||||
methodName = methodInfo.Name;
|
||||
|
||||
#endif
|
||||
bool methodIsKnown = FindMethod(
|
||||
EXTERNAL_CODECS_VARS
|
||||
coderInfo.MethodID, methodName);
|
||||
|
||||
if (methodIsKnown)
|
||||
{
|
||||
methodsString += methodName;
|
||||
if (altCoderInfo.MethodID == k_LZMA)
|
||||
if (coderInfo.MethodID == k_LZMA)
|
||||
{
|
||||
if (altCoderInfo.Properties.GetCapacity() >= 5)
|
||||
if (coderInfo.Properties.GetCapacity() >= 5)
|
||||
{
|
||||
methodsString += L":";
|
||||
UInt32 dicSize = GetUInt32FromMemLE(
|
||||
((const Byte *)altCoderInfo.Properties + 1));
|
||||
((const Byte *)coderInfo.Properties + 1));
|
||||
methodsString += GetStringForSizeValue(dicSize);
|
||||
}
|
||||
}
|
||||
else if (altCoderInfo.MethodID == k_PPMD)
|
||||
else if (coderInfo.MethodID == k_PPMD)
|
||||
{
|
||||
if (altCoderInfo.Properties.GetCapacity() >= 5)
|
||||
if (coderInfo.Properties.GetCapacity() >= 5)
|
||||
{
|
||||
Byte order = *(const Byte *)altCoderInfo.Properties;
|
||||
Byte order = *(const Byte *)coderInfo.Properties;
|
||||
methodsString += L":o";
|
||||
methodsString += ConvertUInt32ToString(order);
|
||||
methodsString += L":mem";
|
||||
UInt32 dicSize = GetUInt32FromMemLE(
|
||||
((const Byte *)altCoderInfo.Properties + 1));
|
||||
((const Byte *)coderInfo.Properties + 1));
|
||||
methodsString += GetStringForSizeValue(dicSize);
|
||||
}
|
||||
}
|
||||
else if (altCoderInfo.MethodID == k_AES)
|
||||
else if (coderInfo.MethodID == k_AES)
|
||||
{
|
||||
if (altCoderInfo.Properties.GetCapacity() >= 1)
|
||||
if (coderInfo.Properties.GetCapacity() >= 1)
|
||||
{
|
||||
methodsString += L":";
|
||||
const Byte *data = (const Byte *)altCoderInfo.Properties;
|
||||
const Byte *data = (const Byte *)coderInfo.Properties;
|
||||
Byte firstByte = *data++;
|
||||
UInt32 numCyclesPower = firstByte & 0x3F;
|
||||
methodsString += ConvertUInt32ToString(numCyclesPower);
|
||||
@@ -361,7 +315,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
return S_OK;
|
||||
UInt32 saltSize = (firstByte >> 7) & 1;
|
||||
UInt32 ivSize = (firstByte >> 6) & 1;
|
||||
if (altCoderInfo.Properties.GetCapacity() >= 2)
|
||||
if (coderInfo.Properties.GetCapacity() >= 2)
|
||||
{
|
||||
Byte secondByte = *data++;
|
||||
saltSize += (secondByte >> 4);
|
||||
@@ -373,18 +327,18 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
}
|
||||
else
|
||||
{
|
||||
if (altCoderInfo.Properties.GetCapacity() > 0)
|
||||
if (coderInfo.Properties.GetCapacity() > 0)
|
||||
{
|
||||
methodsString += L":[";
|
||||
for (size_t bi = 0; bi < altCoderInfo.Properties.GetCapacity(); bi++)
|
||||
for (size_t bi = 0; bi < coderInfo.Properties.GetCapacity(); bi++)
|
||||
{
|
||||
if (bi > 5 && bi + 1 < altCoderInfo.Properties.GetCapacity())
|
||||
if (bi > 5 && bi + 1 < coderInfo.Properties.GetCapacity())
|
||||
{
|
||||
methodsString += L"..";
|
||||
break;
|
||||
}
|
||||
else
|
||||
methodsString += GetHex2(altCoderInfo.Properties[bi]);
|
||||
methodsString += GetHex2(coderInfo.Properties[bi]);
|
||||
}
|
||||
methodsString += L"]";
|
||||
}
|
||||
@@ -392,7 +346,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
}
|
||||
else
|
||||
{
|
||||
methodsString += altCoderInfo.MethodID.ConvertToString();
|
||||
methodsString += ConvertMethodIdToString(coderInfo.MethodID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -655,7 +609,9 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
#else
|
||||
CInArchive archive;
|
||||
RINOK(archive.Open(stream, maxCheckStartPosition));
|
||||
HRESULT result = archive.ReadDatabase(_database
|
||||
HRESULT result = archive.ReadDatabase(
|
||||
EXTERNAL_CODECS_VARS
|
||||
_database
|
||||
#ifndef _NO_CRYPTO
|
||||
, getTextPassword
|
||||
#endif
|
||||
@@ -733,8 +689,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
const CCoderInfo &coder = folder.Coders.Front();
|
||||
if (coder.NumInStreams != 1 || coder.NumOutStreams != 1)
|
||||
return S_FALSE;
|
||||
const CAltCoderInfo &altCoder = coder.AltCoders.Front();
|
||||
if (altCoder.MethodID.IDSize != 1 || altCoder.MethodID.ID[0] != 0)
|
||||
if (coder.MethodID != k_Copy)
|
||||
return S_FALSE;
|
||||
|
||||
pos += file.UnPackSize;
|
||||
@@ -791,4 +746,6 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
#endif
|
||||
#endif
|
||||
|
||||
IMPL_ISetCompressCodecsInfo
|
||||
|
||||
}}
|
||||
|
||||
@@ -3,19 +3,18 @@
|
||||
#ifndef __7Z_HANDLER_H
|
||||
#define __7Z_HANDLER_H
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../IArchive.h"
|
||||
#include "7zIn.h"
|
||||
|
||||
#include "7zCompressionMode.h"
|
||||
|
||||
#ifndef _SFX
|
||||
#include "7zMethods.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
@@ -82,13 +81,12 @@ class CHandler:
|
||||
#ifndef EXTRACT_ONLY
|
||||
public IOutArchive,
|
||||
#endif
|
||||
PUBLIC_ISetCompressCodecsInfo
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
#if !defined(_7Z_VOL) && !defined(__7Z_SET_PROPERTIES) && defined(EXTRACT_ONLY)
|
||||
MY_UNKNOWN_IMP
|
||||
#else
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
#ifdef _7Z_VOL
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
|
||||
#endif
|
||||
@@ -98,9 +96,9 @@ public:
|
||||
#ifndef EXTRACT_ONLY
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
#endif
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
#endif
|
||||
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
@@ -144,6 +142,8 @@ public:
|
||||
HRESULT SetSolidSettings(const PROPVARIANT &value);
|
||||
#endif
|
||||
|
||||
DECL_ISetCompressCodecsInfo
|
||||
|
||||
CHandler();
|
||||
|
||||
private:
|
||||
@@ -155,6 +155,7 @@ private:
|
||||
NArchive::N7z::CArchiveDatabaseEx _database;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 _numThreads;
|
||||
#endif
|
||||
@@ -169,7 +170,6 @@ private:
|
||||
bool _solidExtension;
|
||||
|
||||
bool _compressHeaders;
|
||||
bool _compressHeadersFull;
|
||||
bool _encryptHeaders;
|
||||
|
||||
bool WriteModified;
|
||||
@@ -182,6 +182,7 @@ private:
|
||||
|
||||
bool _volumeMode;
|
||||
|
||||
DECL_EXTERNAL_CODECS_VARS
|
||||
|
||||
HRESULT SetParam(COneMethodInfo &oneMethodInfo, const UString &name, const UString &value);
|
||||
HRESULT SetParams(COneMethodInfo &oneMethodInfo, const UString &srcString);
|
||||
@@ -225,7 +226,6 @@ private:
|
||||
{
|
||||
_removeSfxBlock = false;
|
||||
_compressHeaders = true;
|
||||
_compressHeadersFull = true;
|
||||
_encryptHeaders = false;
|
||||
|
||||
WriteModified = true;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "7zHandler.h"
|
||||
#include "7zOut.h"
|
||||
#include "7zUpdate.h"
|
||||
#include "7zMethods.h"
|
||||
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
|
||||
@@ -22,47 +21,6 @@ using namespace NWindows;
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static CMethodID k_LZMA2 = { { 0x3, 0x1, 0x2 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
static CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
static CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
static CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
#ifndef COMPRESS_DEFLATE_ENCODER
|
||||
#define COMPRESS_DEFLATE_ENCODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_ENCODER
|
||||
static CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2
|
||||
#ifndef COMPRESS_BZIP2_ENCODER
|
||||
#define COMPRESS_BZIP2_ENCODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_ENCODER
|
||||
static CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
|
||||
#endif
|
||||
|
||||
const wchar_t *kCopyMethod = L"Copy";
|
||||
const wchar_t *kLZMAMethodName = L"LZMA";
|
||||
const wchar_t *kLZMA2MethodName = L"LZMA2";
|
||||
@@ -79,8 +37,8 @@ static const UInt32 kLzmaAlgorithmX5 = 1;
|
||||
|
||||
static const UInt32 kLzmaDicSizeX1 = 1 << 16;
|
||||
static const UInt32 kLzmaDicSizeX3 = 1 << 20;
|
||||
static const UInt32 kLzmaDicSizeX5 = 1 << 22;
|
||||
static const UInt32 kLzmaDicSizeX7 = 1 << 24;
|
||||
static const UInt32 kLzmaDicSizeX5 = 1 << 24;
|
||||
static const UInt32 kLzmaDicSizeX7 = 1 << 25;
|
||||
static const UInt32 kLzmaDicSizeX9 = 1 << 26;
|
||||
|
||||
static const UInt32 kLzmaFastBytesX1 = 32;
|
||||
@@ -240,8 +198,6 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
);
|
||||
RINOK(res);
|
||||
methodMode.Binds = _binds;
|
||||
if (_compressHeadersFull)
|
||||
_compressHeaders = true;
|
||||
|
||||
if (_compressHeaders)
|
||||
{
|
||||
@@ -308,15 +264,6 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifndef EXCLUDE_COM
|
||||
/*
|
||||
CObjectVector<CMethodInfo2> methodInfoVector;
|
||||
if (!NRegistryInfo::EnumerateAllMethods(methodInfoVector))
|
||||
return E_FAIL;
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
UInt32 level = _level;
|
||||
|
||||
if (methodsInfo.IsEmpty())
|
||||
@@ -418,93 +365,11 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
|
||||
|
||||
CMethodFull methodFull;
|
||||
methodFull.NumInStreams = 1;
|
||||
methodFull.NumOutStreams = 1;
|
||||
|
||||
bool defined = false;
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"LZMA") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_LZMA;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"PPMD") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_PPMD;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"BCJ") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_BCJ_X86;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"BCJ2") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_BCJ2;
|
||||
methodFull.NumInStreams = 4;
|
||||
methodFull.NumOutStreams = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_ENCODER
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"Deflate") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_Deflate;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_ENCODER
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"BZip2") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_BZip2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"Copy") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_Copy;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
|
||||
if (!defined)
|
||||
{
|
||||
CMethodInfo2 methodInfo;
|
||||
if (!GetMethodInfo(oneMethodInfo.MethodName, methodInfo))
|
||||
return E_INVALIDARG;
|
||||
if (!methodInfo.EncoderIsAssigned)
|
||||
return E_INVALIDARG;
|
||||
|
||||
methodFull.MethodID = methodInfo.MethodID;
|
||||
methodFull.NumInStreams = methodInfo.NumInStreams;
|
||||
methodFull.NumOutStreams = methodInfo.NumOutStreams;
|
||||
|
||||
methodFull.EncoderClassID = methodInfo.Encoder;
|
||||
methodFull.FilePath = methodInfo.FilePath;
|
||||
defined = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (!defined)
|
||||
if (!FindMethod(
|
||||
EXTERNAL_CODECS_VARS
|
||||
oneMethodInfo.MethodName, methodFull.MethodID, methodFull.NumInStreams, methodFull.NumOutStreams))
|
||||
return E_INVALIDARG;
|
||||
|
||||
methodFull.CoderProperties = oneMethodInfo.CoderProperties;
|
||||
methodMode.Methods.Add(methodFull);
|
||||
|
||||
@@ -707,17 +572,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
|
||||
RINOK(SetPassword(methodMode, updateCallback));
|
||||
|
||||
bool useAdditionalHeaderStreams = true;
|
||||
bool compressMainHeader = false;
|
||||
bool compressMainHeader = _compressHeaders; // check it
|
||||
|
||||
if (_compressHeadersFull)
|
||||
{
|
||||
useAdditionalHeaderStreams = false;
|
||||
compressMainHeader = true;
|
||||
}
|
||||
if (methodMode.PasswordIsDefined)
|
||||
{
|
||||
useAdditionalHeaderStreams = false;
|
||||
compressMainHeader = true;
|
||||
if(_encryptHeaders)
|
||||
RINOK(SetPassword(headerMethod, updateCallback));
|
||||
@@ -734,7 +592,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
options.UseFilters = _level != 0 && _autoFilter;
|
||||
options.MaxFilter = _level >= 8;
|
||||
|
||||
options.HeaderOptions.UseAdditionalHeaderStreams = useAdditionalHeaderStreams;
|
||||
options.HeaderOptions.CompressMainHeader = compressMainHeader;
|
||||
options.HeaderOptions.WriteModified = WriteModified;
|
||||
options.HeaderOptions.WriteCreated = WriteCreated;
|
||||
@@ -746,6 +603,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
options.RemoveSfxBlock = _removeSfxBlock;
|
||||
options.VolumeMode = _volumeMode;
|
||||
return Update(
|
||||
EXTERNAL_CODECS_VARS
|
||||
#ifdef _7Z_VOL
|
||||
volume ? volume->Stream: 0,
|
||||
volume ? database: 0,
|
||||
@@ -1050,7 +908,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
}
|
||||
else if (name.CompareNoCase(L"HCF") == 0)
|
||||
{
|
||||
RINOK(SetBoolProperty(_compressHeadersFull, value));
|
||||
bool compressHeadersFull = true;
|
||||
RINOK(SetBoolProperty(compressHeadersFull, value));
|
||||
if (!compressHeadersFull)
|
||||
return E_INVALIDARG;
|
||||
continue;
|
||||
}
|
||||
else if (name.CompareNoCase(L"HE") == 0)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef __7Z_HEADER_H
|
||||
#define __7Z_HEADER_H
|
||||
|
||||
#include "7zMethodID.h"
|
||||
#include "../../../Common/Types.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "7zIn.h"
|
||||
#include "7zMethods.h"
|
||||
#include "7zDecode.h"
|
||||
#include "../../Common/StreamObjects.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
#include "../../../Common/CRC.h"
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/7zCrc.h"
|
||||
}
|
||||
|
||||
// define FORMAT_7Z_RECOVERY if you want to recover multivolume archives with empty StartHeader
|
||||
// #define FORMAT_7Z_RECOVERY
|
||||
@@ -99,7 +101,7 @@ HRESULT CInArchive::SafeReadDirectByte(Byte &b)
|
||||
return SafeReadDirect(&b, 1);
|
||||
}
|
||||
|
||||
HRESULT CInArchive::SafeReadDirectUInt32(UInt32 &value)
|
||||
HRESULT CInArchive::SafeReadDirectUInt32(UInt32 &value, UInt32 &crc)
|
||||
{
|
||||
value = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -107,11 +109,12 @@ HRESULT CInArchive::SafeReadDirectUInt32(UInt32 &value)
|
||||
Byte b;
|
||||
RINOK(SafeReadDirectByte(b));
|
||||
value |= (UInt32(b) << (8 * i));
|
||||
crc = CRC_UPDATE_BYTE(crc, b);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::SafeReadDirectUInt64(UInt64 &value)
|
||||
HRESULT CInArchive::SafeReadDirectUInt64(UInt64 &value, UInt32 &crc)
|
||||
{
|
||||
value = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -119,6 +122,7 @@ HRESULT CInArchive::SafeReadDirectUInt64(UInt64 &value)
|
||||
Byte b;
|
||||
RINOK(SafeReadDirectByte(b));
|
||||
value |= (UInt64(b) << (8 * i));
|
||||
crc = CRC_UPDATE_BYTE(crc, b);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -367,14 +371,19 @@ HRESULT CInArchive::GetNextFolderItem(CFolder &folder)
|
||||
folder.Coders.Add(CCoderInfo());
|
||||
CCoderInfo &coder = folder.Coders.Back();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
coder.AltCoders.Add(CAltCoderInfo());
|
||||
CAltCoderInfo &altCoder = coder.AltCoders.Back();
|
||||
Byte mainByte = 0;
|
||||
RINOK(ReadByte(mainByte));
|
||||
altCoder.MethodID.IDSize = (Byte)(mainByte & 0xF);
|
||||
RINOK(ReadBytes(altCoder.MethodID.ID, altCoder.MethodID.IDSize));
|
||||
int idSize = (mainByte & 0xF);
|
||||
BYTE longID[15];
|
||||
RINOK(ReadBytes(longID, idSize));
|
||||
if (idSize > 8)
|
||||
return S_FALSE;
|
||||
UInt64 id = 0;
|
||||
for (int j = 0; j < idSize; j++)
|
||||
id |= (UInt64)longID[idSize - 1 - j] << (8 * j);
|
||||
coder.MethodID = id;
|
||||
|
||||
if ((mainByte & 0x10) != 0)
|
||||
{
|
||||
RINOK(ReadNum(coder.NumInStreams));
|
||||
@@ -389,11 +398,11 @@ HRESULT CInArchive::GetNextFolderItem(CFolder &folder)
|
||||
{
|
||||
CNum propertiesSize = 0;
|
||||
RINOK(ReadNum(propertiesSize));
|
||||
altCoder.Properties.SetCapacity((size_t)propertiesSize);
|
||||
RINOK(ReadBytes((Byte *)altCoder.Properties, (size_t)propertiesSize));
|
||||
coder.Properties.SetCapacity((size_t)propertiesSize);
|
||||
RINOK(ReadBytes((Byte *)coder.Properties, (size_t)propertiesSize));
|
||||
}
|
||||
if ((mainByte & 0x80) == 0)
|
||||
break;
|
||||
if ((mainByte & 0x80) != 0)
|
||||
return S_FALSE;
|
||||
}
|
||||
numInStreams += coder.NumInStreams;
|
||||
numOutStreams += coder.NumOutStreams;
|
||||
@@ -826,7 +835,9 @@ HRESULT CInArchive::ReadTime(const CObjectVector<CByteBuffer> &dataVector,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
|
||||
HRESULT CInArchive::ReadAndDecodePackedStreams(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 baseOffset,
|
||||
UInt64 &dataOffset, CObjectVector<CByteBuffer> &dataVector
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPassword
|
||||
@@ -881,7 +892,9 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
|
||||
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
|
||||
outStreamSpec->Init(data, (size_t)unPackSize);
|
||||
|
||||
HRESULT result = decoder.Decode(_stream, dataStartPos,
|
||||
HRESULT result = decoder.Decode(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
_stream, dataStartPos,
|
||||
&packSizes[packIndex], folder, outStream, NULL
|
||||
#ifndef _NO_CRYPTO
|
||||
, getTextPassword
|
||||
@@ -893,7 +906,7 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
|
||||
RINOK(result);
|
||||
|
||||
if (folder.UnPackCRCDefined)
|
||||
if (!CCRC::VerifyDigest(folder.UnPackCRC, data, (UInt32)unPackSize))
|
||||
if (CrcCalc(data, (UInt32)unPackSize) != folder.UnPackCRC)
|
||||
throw CInArchiveException(CInArchiveException::kIncorrectHeader);
|
||||
for (int j = 0; j < folder.PackStreams.Size(); j++)
|
||||
dataStartPos += packSizes[packIndex++];
|
||||
@@ -901,7 +914,9 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadHeader(CArchiveDatabaseEx &database
|
||||
HRESULT CInArchive::ReadHeader(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CArchiveDatabaseEx &database
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
@@ -921,6 +936,7 @@ HRESULT CInArchive::ReadHeader(CArchiveDatabaseEx &database
|
||||
if (type == NID::kAdditionalStreamsInfo)
|
||||
{
|
||||
HRESULT result = ReadAndDecodePackedStreams(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
database.ArchiveInfo.StartPositionAfterHeader,
|
||||
database.ArchiveInfo.DataStartPosition2,
|
||||
dataVector
|
||||
@@ -1192,7 +1208,9 @@ void CArchiveDatabaseEx::FillFolderStartFileIndex()
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
HRESULT CInArchive::ReadDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CArchiveDatabaseEx &database
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
@@ -1219,11 +1237,12 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
UInt64 nextHeaderOffset;
|
||||
UInt64 nextHeaderSize;
|
||||
UInt32 nextHeaderCRC;
|
||||
CCRC crc;
|
||||
RINOK(SafeReadDirectUInt32(crcFromArchive));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderOffset));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderSize));
|
||||
RINOK(SafeReadDirectUInt32(nextHeaderCRC));
|
||||
UInt32 crc = CRC_INIT_VAL;
|
||||
UInt32 temp;
|
||||
RINOK(SafeReadDirectUInt32(crcFromArchive, temp));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderOffset, crc));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderSize, crc));
|
||||
RINOK(SafeReadDirectUInt32(nextHeaderCRC, crc));
|
||||
|
||||
#ifdef FORMAT_7Z_RECOVERY
|
||||
if (crcFromArchive == 0 && nextHeaderOffset == 0 && nextHeaderSize == 0 && nextHeaderCRC == 0)
|
||||
@@ -1254,10 +1273,6 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
}
|
||||
#endif
|
||||
|
||||
crc.UpdateUInt64(nextHeaderOffset);
|
||||
crc.UpdateUInt64(nextHeaderSize);
|
||||
crc.UpdateUInt32(nextHeaderCRC);
|
||||
|
||||
#ifdef FORMAT_7Z_RECOVERY
|
||||
crcFromArchive = crc.GetDigest();
|
||||
#endif
|
||||
@@ -1278,7 +1293,7 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
{
|
||||
database.ArchiveInfo.StartPositionAfterHeader = _position;
|
||||
}
|
||||
if (crc.GetDigest() != crcFromArchive)
|
||||
if (CRC_GET_DIGEST(crc) != crcFromArchive)
|
||||
throw CInArchiveException(CInArchiveException::kIncorrectHeader);
|
||||
|
||||
if (nextHeaderSize == 0)
|
||||
@@ -1292,7 +1307,7 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
CByteBuffer buffer2;
|
||||
buffer2.SetCapacity((size_t)nextHeaderSize);
|
||||
RINOK(SafeReadDirect(buffer2, (UInt32)nextHeaderSize));
|
||||
if (!CCRC::VerifyDigest(nextHeaderCRC, buffer2, (UInt32)nextHeaderSize))
|
||||
if (CrcCalc(buffer2, (UInt32)nextHeaderSize) != nextHeaderCRC)
|
||||
throw CInArchiveException(CInArchiveException::kIncorrectHeader);
|
||||
|
||||
CStreamSwitch streamSwitch;
|
||||
@@ -1309,6 +1324,7 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
if (type != NID::kEncodedHeader)
|
||||
throw CInArchiveException(CInArchiveException::kIncorrectHeader);
|
||||
HRESULT result = ReadAndDecodePackedStreams(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
database.ArchiveInfo.StartPositionAfterHeader,
|
||||
database.ArchiveInfo.DataStartPosition2,
|
||||
dataVector
|
||||
@@ -1325,7 +1341,9 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
streamSwitch.Set(this, dataVector.Front());
|
||||
}
|
||||
|
||||
return ReadHeader(database
|
||||
return ReadHeader(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
database
|
||||
#ifndef _NO_CRYPTO
|
||||
, getTextPassword
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
#include "../../IStream.h"
|
||||
#include "../../IPassword.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../Common/InBuffer.h"
|
||||
|
||||
@@ -95,11 +98,9 @@ struct CArchiveDatabaseEx: public CArchiveDatabase
|
||||
UInt64 GetFilePackSize(CNum fileIndex) const
|
||||
{
|
||||
CNum folderIndex = FileIndexToFolderIndexMap[fileIndex];
|
||||
if (folderIndex >= 0)
|
||||
{
|
||||
if (folderIndex != kNumNoIndex)
|
||||
if (FolderStartFileIndex[folderIndex] == fileIndex)
|
||||
return GetFolderFullPackSize(folderIndex);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -182,8 +183,8 @@ private:
|
||||
HRESULT ReadDirect(void *data, UInt32 size, UInt32 *processedSize);
|
||||
HRESULT SafeReadDirect(void *data, UInt32 size);
|
||||
HRESULT SafeReadDirectByte(Byte &b);
|
||||
HRESULT SafeReadDirectUInt32(UInt32 &value);
|
||||
HRESULT SafeReadDirectUInt64(UInt64 &value);
|
||||
HRESULT SafeReadDirectUInt32(UInt32 &value, UInt32 &crc);
|
||||
HRESULT SafeReadDirectUInt64(UInt64 &value, UInt32 &crc);
|
||||
|
||||
HRESULT ReadBytes(void *data, size_t size)
|
||||
{
|
||||
@@ -261,13 +262,17 @@ private:
|
||||
HRESULT ReadBoolVector2(int numItems, CBoolVector &v);
|
||||
HRESULT ReadTime(const CObjectVector<CByteBuffer> &dataVector,
|
||||
CObjectVector<CFileItem> &files, UInt64 type);
|
||||
HRESULT ReadAndDecodePackedStreams(UInt64 baseOffset, UInt64 &dataOffset,
|
||||
HRESULT ReadAndDecodePackedStreams(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 baseOffset, UInt64 &dataOffset,
|
||||
CObjectVector<CByteBuffer> &dataVector
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
);
|
||||
HRESULT ReadHeader(CArchiveDatabaseEx &database
|
||||
HRESULT ReadHeader(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CArchiveDatabaseEx &database
|
||||
#ifndef _NO_CRYPTO
|
||||
,ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
@@ -276,7 +281,9 @@ public:
|
||||
HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
|
||||
void Close();
|
||||
|
||||
HRESULT ReadDatabase(CArchiveDatabaseEx &database
|
||||
HRESULT ReadDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CArchiveDatabaseEx &database
|
||||
#ifndef _NO_CRYPTO
|
||||
,ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
|
||||
@@ -4,27 +4,23 @@
|
||||
#define __7Z_ITEM_H
|
||||
|
||||
#include "../../../Common/Buffer.h"
|
||||
#include "7zMethodID.h"
|
||||
#include "../../../Common/String.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "7zHeader.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
struct CAltCoderInfo
|
||||
{
|
||||
CMethodID MethodID;
|
||||
CByteBuffer Properties;
|
||||
};
|
||||
|
||||
typedef UInt32 CNum;
|
||||
const CNum kNumMax = 0x7FFFFFFF;
|
||||
const CNum kNumNoIndex = 0xFFFFFFFF;
|
||||
|
||||
struct CCoderInfo
|
||||
{
|
||||
CMethodId MethodID;
|
||||
CByteBuffer Properties;
|
||||
CNum NumInStreams;
|
||||
CNum NumOutStreams;
|
||||
CObjectVector<CAltCoderInfo> AltCoders;
|
||||
bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
|
||||
};
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
// 7zMethodID.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "7zMethodID.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
static wchar_t GetHex(Byte value)
|
||||
{
|
||||
return (wchar_t)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
|
||||
}
|
||||
|
||||
static bool HexCharToInt(wchar_t value, Byte &result)
|
||||
{
|
||||
if (value >= '0' && value <= '9')
|
||||
result = (Byte)(value - '0');
|
||||
else if (value >= 'a' && value <= 'f')
|
||||
result = (Byte)(10 + value - 'a');
|
||||
else if (value >= 'A' && value <= 'F')
|
||||
result = (Byte)(10 + value - 'A');
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool TwoHexCharsToInt(wchar_t valueHigh, wchar_t valueLow, Byte &result)
|
||||
{
|
||||
Byte resultHigh, resultLow;
|
||||
if (!HexCharToInt(valueHigh, resultHigh))
|
||||
return false;
|
||||
if (!HexCharToInt(valueLow, resultLow))
|
||||
return false;
|
||||
result = (Byte)((resultHigh << 4) + resultLow);
|
||||
return true;
|
||||
}
|
||||
|
||||
UString CMethodID::ConvertToString() const
|
||||
{
|
||||
UString result;
|
||||
for (int i = 0; i < IDSize; i++)
|
||||
{
|
||||
Byte b = ID[i];
|
||||
result += GetHex((Byte)(b >> 4));
|
||||
result += GetHex((Byte)(b & 0xF));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CMethodID::ConvertFromString(const UString &srcString)
|
||||
{
|
||||
int length = srcString.Length();
|
||||
if ((length & 1) != 0 || (length >> 1) > kMethodIDSize)
|
||||
return false;
|
||||
IDSize = (Byte)(length / 2);
|
||||
UInt32 i;
|
||||
for(i = 0; i < IDSize; i++)
|
||||
if (!TwoHexCharsToInt(srcString[i * 2], srcString[i * 2 + 1], ID[i]))
|
||||
return false;
|
||||
for(; i < kMethodIDSize; i++)
|
||||
ID[i] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const CMethodID &a1, const CMethodID &a2)
|
||||
{
|
||||
if (a1.IDSize != a2.IDSize)
|
||||
return false;
|
||||
for (UInt32 i = 0; i < a1.IDSize; i++)
|
||||
if (a1.ID[i] != a2.ID[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -1,29 +0,0 @@
|
||||
// 7zMethodID.h
|
||||
|
||||
#ifndef __7Z_METHOD_ID_H
|
||||
#define __7Z_METHOD_ID_H
|
||||
|
||||
#include "../../../Common/String.h"
|
||||
#include "../../../Common/Types.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
const int kMethodIDSize = 15;
|
||||
|
||||
struct CMethodID
|
||||
{
|
||||
Byte ID[kMethodIDSize];
|
||||
Byte IDSize;
|
||||
UString ConvertToString() const;
|
||||
bool ConvertFromString(const UString &srcString);
|
||||
};
|
||||
|
||||
bool operator==(const CMethodID &a1, const CMethodID &a2);
|
||||
|
||||
inline bool operator!=(const CMethodID &a1, const CMethodID &a2)
|
||||
{ return !(a1 == a2); }
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,174 +0,0 @@
|
||||
// 7zMethods.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "7zMethods.h"
|
||||
|
||||
#include "../../../Windows/FileFind.h"
|
||||
#include "../../../Windows/DLL.h"
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../Common/CodecsPath.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
static CObjectVector<CMethodInfo2> g_Methods;
|
||||
static bool g_Loaded = false;
|
||||
|
||||
typedef UInt32 (WINAPI *GetNumberOfMethodsFunc)(UInt32 *numMethods);
|
||||
|
||||
typedef UInt32 (WINAPI *GetMethodPropertyFunc)(
|
||||
UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||
|
||||
static void Load(const CSysString &folderPrefix)
|
||||
{
|
||||
NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*")));
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
{
|
||||
if (fileInfo.IsDirectory())
|
||||
continue;
|
||||
CSysString filePath = folderPrefix + fileInfo.Name;
|
||||
{
|
||||
NDLL::CLibrary library;
|
||||
if (!library.LoadEx(filePath, LOAD_LIBRARY_AS_DATAFILE))
|
||||
continue;
|
||||
}
|
||||
NDLL::CLibrary library;
|
||||
if (!library.Load(filePath))
|
||||
continue;
|
||||
GetMethodPropertyFunc getMethodProperty = (GetMethodPropertyFunc)
|
||||
library.GetProcAddress("GetMethodProperty");
|
||||
if (getMethodProperty == NULL)
|
||||
continue;
|
||||
|
||||
UInt32 numMethods = 1;
|
||||
GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)
|
||||
library.GetProcAddress("GetNumberOfMethods");
|
||||
if (getNumberOfMethodsFunc != NULL)
|
||||
if (getNumberOfMethodsFunc(&numMethods) != S_OK)
|
||||
continue;
|
||||
|
||||
for(UInt32 i = 0; i < numMethods; i++)
|
||||
{
|
||||
CMethodInfo2 info;
|
||||
info.FilePath = filePath;
|
||||
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
if (getMethodProperty(i, NMethodPropID::kID, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt != VT_BSTR)
|
||||
continue;
|
||||
info.MethodID.IDSize = (Byte)SysStringByteLen(propVariant.bstrVal);
|
||||
memmove(info.MethodID.ID, propVariant.bstrVal, info.MethodID.IDSize);
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty(i, NMethodPropID::kName, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
{
|
||||
}
|
||||
else if (propVariant.vt == VT_BSTR)
|
||||
info.Name = propVariant.bstrVal;
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty (i, NMethodPropID::kEncoder, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
info.EncoderIsAssigned = false;
|
||||
else if (propVariant.vt == VT_BSTR)
|
||||
{
|
||||
info.EncoderIsAssigned = true;
|
||||
info.Encoder = *(const GUID *)propVariant.bstrVal;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty (i, NMethodPropID::kDecoder, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
info.DecoderIsAssigned = false;
|
||||
else if (propVariant.vt == VT_BSTR)
|
||||
{
|
||||
info.DecoderIsAssigned = true;
|
||||
info.Decoder = *(const GUID *)propVariant.bstrVal;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty (i, NMethodPropID::kInStreams, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
info.NumInStreams = 1;
|
||||
else if (propVariant.vt == VT_UI4)
|
||||
info.NumInStreams = propVariant.ulVal;
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty (i, NMethodPropID::kOutStreams, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
info.NumOutStreams = 1;
|
||||
else if (propVariant.vt == VT_UI4)
|
||||
info.NumOutStreams = propVariant.ulVal;
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
g_Methods.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
|
||||
void LoadMethodMap()
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
|
||||
if (g_Loaded)
|
||||
return;
|
||||
g_Loaded = true;
|
||||
Load(GetCodecsFolderPrefix());
|
||||
}
|
||||
|
||||
bool GetMethodInfo(const CMethodID &methodID, CMethodInfo &methodInfo)
|
||||
{
|
||||
for(int i = 0; i < g_Methods.Size(); i++)
|
||||
{
|
||||
const CMethodInfo2 &method = g_Methods[i];
|
||||
if (method.MethodID == methodID)
|
||||
{
|
||||
methodInfo = (CMethodInfo)method;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetMethodInfo(const UString &name, CMethodInfo2 &methodInfo)
|
||||
{
|
||||
for(int i = 0; i < g_Methods.Size(); i++)
|
||||
{
|
||||
const CMethodInfo2 &method = g_Methods[i];
|
||||
if (method.Name.CompareNoCase(name) == 0)
|
||||
{
|
||||
methodInfo = method;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// 7zMethods.h
|
||||
|
||||
#ifndef __7Z_METHODS_H
|
||||
#define __7Z_METHODS_H
|
||||
|
||||
#include "7zMethodID.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
struct CMethodInfo
|
||||
{
|
||||
UString Name;
|
||||
bool EncoderIsAssigned;
|
||||
bool DecoderIsAssigned;
|
||||
UInt32 NumInStreams;
|
||||
UInt32 NumOutStreams;
|
||||
CLSID Encoder;
|
||||
CLSID Decoder;
|
||||
// UString Description;
|
||||
CSysString FilePath;
|
||||
};
|
||||
|
||||
struct CMethodInfo2: public CMethodInfo
|
||||
{
|
||||
CMethodID MethodID;
|
||||
};
|
||||
|
||||
void LoadMethodMap();
|
||||
bool GetMethodInfo(const CMethodID &methodID, CMethodInfo &methodInfo);
|
||||
bool GetMethodInfo(const UString &name, CMethodInfo2 &methodInfo);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
|
||||
#include "7zOut.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/7zCrc.h"
|
||||
}
|
||||
|
||||
static HRESULT WriteBytes(ISequentialOutStream *stream, const void *data, size_t size)
|
||||
{
|
||||
while (size > 0)
|
||||
@@ -30,6 +35,20 @@ HRESULT COutArchive::WriteDirect(const void *data, UInt32 size)
|
||||
return ::WriteBytes(SeqStream, data, size);
|
||||
}
|
||||
|
||||
UInt32 CrcUpdateUInt32(UInt32 crc, UInt32 value)
|
||||
{
|
||||
for (int i = 0; i < 4; i++, value >>= 8)
|
||||
crc = CRC_UPDATE_BYTE(crc, (Byte)value);
|
||||
return crc;
|
||||
}
|
||||
|
||||
UInt32 CrcUpdateUInt64(UInt32 crc, UInt64 value)
|
||||
{
|
||||
for (int i = 0; i < 8; i++, value >>= 8)
|
||||
crc = CRC_UPDATE_BYTE(crc, (Byte)value);
|
||||
return crc;
|
||||
}
|
||||
|
||||
HRESULT COutArchive::WriteDirectUInt32(UInt32 value)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -71,11 +90,11 @@ HRESULT COutArchive::WriteFinishSignature()
|
||||
|
||||
HRESULT COutArchive::WriteStartHeader(const CStartHeader &h)
|
||||
{
|
||||
CCRC crc;
|
||||
crc.UpdateUInt64(h.NextHeaderOffset);
|
||||
crc.UpdateUInt64(h.NextHeaderSize);
|
||||
crc.UpdateUInt32(h.NextHeaderCRC);
|
||||
RINOK(WriteDirectUInt32(crc.GetDigest()));
|
||||
UInt32 crc = CRC_INIT_VAL;
|
||||
crc = CrcUpdateUInt64(crc, h.NextHeaderOffset);
|
||||
crc = CrcUpdateUInt64(crc, h.NextHeaderSize);
|
||||
crc = CrcUpdateUInt32(crc, h.NextHeaderCRC);
|
||||
RINOK(WriteDirectUInt32(CRC_GET_DIGEST(crc)));
|
||||
RINOK(WriteDirectUInt64(h.NextHeaderOffset));
|
||||
RINOK(WriteDirectUInt64(h.NextHeaderSize));
|
||||
return WriteDirectUInt32(h.NextHeaderCRC);
|
||||
@@ -161,7 +180,7 @@ HRESULT COutArchive::WriteBytes(const void *data, size_t size)
|
||||
_dynamicBuffer.Write(data, size);
|
||||
else
|
||||
_outByte.WriteBytes(data, size);
|
||||
_crc.Update(data, size);
|
||||
_crc = CrcUpdate(_crc, data, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -217,6 +236,7 @@ HRESULT COutArchive::WriteNumber(UInt64 value)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
static UInt32 GetBigNumberSize(UInt64 value)
|
||||
{
|
||||
int i;
|
||||
@@ -226,7 +246,6 @@ static UInt32 GetBigNumberSize(UInt64 value)
|
||||
return 1 + i;
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
UInt32 COutArchive::GetVolHeadersSize(UInt64 dataSize, int nameLength, bool props)
|
||||
{
|
||||
UInt32 result = GetBigNumberSize(dataSize) * 2 + 41;
|
||||
@@ -268,19 +287,24 @@ HRESULT COutArchive::WriteFolder(const CFolder &folder)
|
||||
for (i = 0; i < folder.Coders.Size(); i++)
|
||||
{
|
||||
const CCoderInfo &coder = folder.Coders[i];
|
||||
for (int j = 0; j < coder.AltCoders.Size(); j++)
|
||||
{
|
||||
const CAltCoderInfo &altCoder = coder.AltCoders[j];
|
||||
size_t propertiesSize = altCoder.Properties.GetCapacity();
|
||||
size_t propertiesSize = coder.Properties.GetCapacity();
|
||||
|
||||
UInt64 id = coder.MethodID;
|
||||
int idSize;
|
||||
for (idSize = 1; idSize < sizeof(id); idSize++)
|
||||
if ((id >> (8 * idSize)) == 0)
|
||||
break;
|
||||
BYTE longID[15];
|
||||
for (int t = idSize - 1; t >= 0 ; t--, id >>= 8)
|
||||
longID[t] = (Byte)(id & 0xFF);
|
||||
Byte b;
|
||||
b = (Byte)(altCoder.MethodID.IDSize & 0xF);
|
||||
b = (Byte)(idSize & 0xF);
|
||||
bool isComplex = !coder.IsSimpleCoder();
|
||||
b |= (isComplex ? 0x10 : 0);
|
||||
b |= ((propertiesSize != 0) ? 0x20 : 0 );
|
||||
b |= ((j == coder.AltCoders.Size() - 1) ? 0 : 0x80 );
|
||||
RINOK(WriteByte(b));
|
||||
RINOK(WriteBytes(altCoder.MethodID.ID, altCoder.MethodID.IDSize));
|
||||
RINOK(WriteBytes(longID, idSize));
|
||||
if (isComplex)
|
||||
{
|
||||
RINOK(WriteNumber(coder.NumInStreams));
|
||||
@@ -289,7 +313,7 @@ HRESULT COutArchive::WriteFolder(const CFolder &folder)
|
||||
if (propertiesSize == 0)
|
||||
continue;
|
||||
RINOK(WriteNumber(propertiesSize));
|
||||
RINOK(WriteBytes(altCoder.Properties, propertiesSize));
|
||||
RINOK(WriteBytes(coder.Properties, propertiesSize));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < folder.BindPairs.Size(); i++)
|
||||
@@ -380,10 +404,7 @@ HRESULT COutArchive::WritePackInfo(
|
||||
return WriteByte(NID::kEnd);
|
||||
}
|
||||
|
||||
HRESULT COutArchive::WriteUnPackInfo(
|
||||
bool externalFolders,
|
||||
CNum externalFoldersStreamIndex,
|
||||
const CObjectVector<CFolder> &folders)
|
||||
HRESULT COutArchive::WriteUnPackInfo(const CObjectVector<CFolder> &folders)
|
||||
{
|
||||
if (folders.IsEmpty())
|
||||
return S_OK;
|
||||
@@ -392,12 +413,6 @@ HRESULT COutArchive::WriteUnPackInfo(
|
||||
|
||||
RINOK(WriteByte(NID::kFolder));
|
||||
RINOK(WriteNumber(folders.Size()));
|
||||
if (externalFolders)
|
||||
{
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalFoldersStreamIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(WriteByte(0));
|
||||
for(int i = 0; i < folders.Size(); i++)
|
||||
@@ -484,8 +499,7 @@ HRESULT COutArchive::WriteSubStreamsInfo(
|
||||
}
|
||||
|
||||
HRESULT COutArchive::WriteTime(
|
||||
const CObjectVector<CFileItem> &files, Byte type,
|
||||
bool isExternal, CNum externalDataIndex)
|
||||
const CObjectVector<CFileItem> &files, Byte type)
|
||||
{
|
||||
/////////////////////////////////////////////////
|
||||
// CreationTime
|
||||
@@ -520,9 +534,6 @@ HRESULT COutArchive::WriteTime(
|
||||
return S_OK;
|
||||
RINOK(WriteByte(type));
|
||||
size_t dataSize = 1 + 1;
|
||||
if (isExternal)
|
||||
dataSize += GetBigNumberSize(externalDataIndex);
|
||||
else
|
||||
dataSize += files.Size() * 8;
|
||||
if (allDefined)
|
||||
{
|
||||
@@ -535,12 +546,6 @@ HRESULT COutArchive::WriteTime(
|
||||
WriteByte(0);
|
||||
RINOK(WriteBoolVector(boolVector));
|
||||
}
|
||||
if (isExternal)
|
||||
{
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalDataIndex));
|
||||
return S_OK;
|
||||
}
|
||||
RINOK(WriteByte(0));
|
||||
for(i = 0; i < files.Size(); i++)
|
||||
{
|
||||
@@ -569,7 +574,9 @@ HRESULT COutArchive::WriteTime(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT COutArchive::EncodeStream(CEncoder &encoder, const Byte *data, size_t dataSize,
|
||||
HRESULT COutArchive::EncodeStream(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CEncoder &encoder, const Byte *data, size_t dataSize,
|
||||
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders)
|
||||
{
|
||||
CSequentialInStreamImp *streamSpec = new CSequentialInStreamImp;
|
||||
@@ -577,17 +584,23 @@ HRESULT COutArchive::EncodeStream(CEncoder &encoder, const Byte *data, size_t da
|
||||
streamSpec->Init(data, dataSize);
|
||||
CFolder folderItem;
|
||||
folderItem.UnPackCRCDefined = true;
|
||||
folderItem.UnPackCRC = CCRC::CalculateDigest(data, dataSize);
|
||||
folderItem.UnPackCRC = CrcCalc(data, dataSize);
|
||||
UInt64 dataSize64 = dataSize;
|
||||
RINOK(encoder.Encode(stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL));
|
||||
RINOK(encoder.Encode(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL))
|
||||
folders.Add(folderItem);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT COutArchive::EncodeStream(CEncoder &encoder, const CByteBuffer &data,
|
||||
HRESULT COutArchive::EncodeStream(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CEncoder &encoder, const CByteBuffer &data,
|
||||
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders)
|
||||
{
|
||||
return EncodeStream(encoder, data, data.GetCapacity(), packSizes, folders);
|
||||
return EncodeStream(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
encoder, data, data.GetCapacity(), packSizes, folders);
|
||||
}
|
||||
|
||||
static void WriteUInt32ToBuffer(Byte *data, UInt32 value)
|
||||
@@ -609,62 +622,13 @@ static void WriteUInt64ToBuffer(Byte *data, UInt64 value)
|
||||
}
|
||||
|
||||
|
||||
HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
const CCompressionMethodMode *options,
|
||||
HRESULT COutArchive::WriteHeader(
|
||||
const CArchiveDatabase &database,
|
||||
const CHeaderOptions &headerOptions,
|
||||
UInt64 &headerOffset)
|
||||
{
|
||||
CObjectVector<CFolder> folders;
|
||||
|
||||
bool compressHeaders = (options != NULL);
|
||||
CMyAutoPtr<CEncoder> encoder;
|
||||
if (compressHeaders)
|
||||
{
|
||||
// it's for gcc2.95.2
|
||||
CMyAutoPtr<CEncoder> tmp(new CEncoder(*options));
|
||||
encoder = tmp;
|
||||
}
|
||||
|
||||
CRecordVector<UInt64> packSizes;
|
||||
|
||||
CNum dataIndex = 0;
|
||||
|
||||
//////////////////////////
|
||||
// Folders
|
||||
|
||||
CNum externalFoldersStreamIndex = 0;
|
||||
bool externalFolders = (compressHeaders && database.Folders.Size() > 8);
|
||||
if (externalFolders)
|
||||
{
|
||||
_mainMode = false;
|
||||
_countMode = true;
|
||||
_countSize = 0;
|
||||
int i;
|
||||
for(i = 0; i < database.Folders.Size(); i++)
|
||||
{
|
||||
RINOK(WriteFolder(database.Folders[i]));
|
||||
}
|
||||
|
||||
_countMode = false;
|
||||
|
||||
CByteBuffer foldersData;
|
||||
foldersData.SetCapacity(_countSize);
|
||||
_outByte2.Init(foldersData, foldersData.GetCapacity());
|
||||
|
||||
for(i = 0; i < database.Folders.Size(); i++)
|
||||
{
|
||||
RINOK(WriteFolder(database.Folders[i]));
|
||||
}
|
||||
|
||||
{
|
||||
externalFoldersStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, foldersData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Names
|
||||
|
||||
@@ -679,8 +643,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
}
|
||||
|
||||
CByteBuffer namesData;
|
||||
CNum externalNamesStreamIndex = 0;
|
||||
bool externalNames = (compressHeaders && database.Files.Size() > 8);
|
||||
if (numDefinedNames > 0)
|
||||
{
|
||||
namesData.SetCapacity((size_t)namesDataSize);
|
||||
@@ -697,12 +659,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
namesData[pos++] = 0;
|
||||
namesData[pos++] = 0;
|
||||
}
|
||||
|
||||
if (externalNames)
|
||||
{
|
||||
externalNamesStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, namesData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -719,8 +675,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
}
|
||||
|
||||
CByteBuffer attributesData;
|
||||
CNum externalAttributesStreamIndex = 0;
|
||||
bool externalAttributes = (compressHeaders && numDefinedAttributes > 8);
|
||||
if (numDefinedAttributes > 0)
|
||||
{
|
||||
attributesData.SetCapacity(numDefinedAttributes * 4);
|
||||
@@ -734,11 +688,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
if (externalAttributes)
|
||||
{
|
||||
externalAttributesStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, attributesData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -755,8 +704,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
}
|
||||
|
||||
CByteBuffer startsData;
|
||||
CNum externalStartStreamIndex = 0;
|
||||
bool externalStarts = (compressHeaders && numDefinedStarts > 8);
|
||||
if (numDefinedStarts > 0)
|
||||
{
|
||||
startsData.SetCapacity(numDefinedStarts * 8);
|
||||
@@ -770,24 +717,16 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
pos += 8;
|
||||
}
|
||||
}
|
||||
if (externalStarts)
|
||||
{
|
||||
externalStartStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, startsData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Write Last Write Time
|
||||
CNum externalLastWriteTimeStreamIndex = 0;
|
||||
bool externalLastWriteTime = false;
|
||||
// /*
|
||||
CNum numDefinedLastWriteTimes = 0;
|
||||
for(i = 0; i < database.Files.Size(); i++)
|
||||
if (database.Files[i].IsLastWriteTimeDefined)
|
||||
numDefinedLastWriteTimes++;
|
||||
|
||||
externalLastWriteTime = (compressHeaders && numDefinedLastWriteTimes > 64);
|
||||
if (numDefinedLastWriteTimes > 0)
|
||||
{
|
||||
CByteBuffer lastWriteTimeData;
|
||||
@@ -804,11 +743,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
if (externalLastWriteTime)
|
||||
{
|
||||
externalLastWriteTimeStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, lastWriteTimeData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
// */
|
||||
|
||||
@@ -816,34 +750,20 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
UInt64 packedSize = 0;
|
||||
for(i = 0; i < database.PackSizes.Size(); i++)
|
||||
packedSize += database.PackSizes[i];
|
||||
UInt64 headerPackSize = 0;
|
||||
for (i = 0; i < packSizes.Size(); i++)
|
||||
headerPackSize += packSizes[i];
|
||||
|
||||
headerOffset = packedSize + headerPackSize;
|
||||
headerOffset = packedSize;
|
||||
|
||||
_mainMode = true;
|
||||
|
||||
_outByte.SetStream(SeqStream);
|
||||
_outByte.Init();
|
||||
_crc.Init();
|
||||
_crc = CRC_INIT_VAL;
|
||||
|
||||
|
||||
RINOK(WriteByte(NID::kHeader));
|
||||
|
||||
// Archive Properties
|
||||
|
||||
if (folders.Size() > 0)
|
||||
{
|
||||
RINOK(WriteByte(NID::kAdditionalStreamsInfo));
|
||||
RINOK(WritePackInfo(packedSize, packSizes,
|
||||
CRecordVector<bool>(), CRecordVector<UInt32>()));
|
||||
RINOK(WriteUnPackInfo(false, 0, folders));
|
||||
RINOK(WriteByte(NID::kEnd));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
if (database.Folders.Size() > 0)
|
||||
{
|
||||
RINOK(WriteByte(NID::kMainStreamsInfo));
|
||||
@@ -851,7 +771,7 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
database.PackCRCsDefined,
|
||||
database.PackCRCs));
|
||||
|
||||
RINOK(WriteUnPackInfo(externalFolders, externalFoldersStreamIndex, database.Folders));
|
||||
RINOK(WriteUnPackInfo(database.Folders));
|
||||
|
||||
CRecordVector<UInt64> unPackSizes;
|
||||
CRecordVector<bool> digestsDefined;
|
||||
@@ -938,13 +858,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
{
|
||||
/////////////////////////////////////////////////
|
||||
RINOK(WriteByte(NID::kName));
|
||||
if (externalNames)
|
||||
{
|
||||
RINOK(WriteNumber(1 + GetBigNumberSize(externalNamesStreamIndex)));
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalNamesStreamIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(WriteNumber(1 + namesData.GetCapacity()));
|
||||
RINOK(WriteByte(0));
|
||||
@@ -955,17 +868,15 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
|
||||
if (headerOptions.WriteCreated)
|
||||
{
|
||||
RINOK(WriteTime(database.Files, NID::kCreationTime, false, 0));
|
||||
RINOK(WriteTime(database.Files, NID::kCreationTime));
|
||||
}
|
||||
if (headerOptions.WriteModified)
|
||||
{
|
||||
RINOK(WriteTime(database.Files, NID::kLastWriteTime,
|
||||
// false, 0));
|
||||
externalLastWriteTime, externalLastWriteTimeStreamIndex));
|
||||
RINOK(WriteTime(database.Files, NID::kLastWriteTime));
|
||||
}
|
||||
if (headerOptions.WriteAccessed)
|
||||
{
|
||||
RINOK(WriteTime(database.Files, NID::kLastAccessTime, false, 0));
|
||||
RINOK(WriteTime(database.Files, NID::kLastAccessTime));
|
||||
}
|
||||
|
||||
if (numDefinedAttributes > 0)
|
||||
@@ -974,9 +885,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
size_t size = 2;
|
||||
if (numDefinedAttributes != database.Files.Size())
|
||||
size += (attributesBoolVector.Size() + 7) / 8 + 1;
|
||||
if (externalAttributes)
|
||||
size += GetBigNumberSize(externalAttributesStreamIndex);
|
||||
else
|
||||
size += attributesData.GetCapacity();
|
||||
|
||||
RINOK(WriteNumber(size));
|
||||
@@ -990,12 +898,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
RINOK(WriteBoolVector(attributesBoolVector));
|
||||
}
|
||||
|
||||
if (externalAttributes)
|
||||
{
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalAttributesStreamIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(WriteByte(0));
|
||||
RINOK(WriteBytes(attributesData));
|
||||
@@ -1008,9 +910,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
size_t size = 2;
|
||||
if (numDefinedStarts != database.Files.Size())
|
||||
size += (startsBoolVector.Size() + 7) / 8 + 1;
|
||||
if (externalStarts)
|
||||
size += GetBigNumberSize(externalStartStreamIndex);
|
||||
else
|
||||
size += startsData.GetCapacity();
|
||||
|
||||
RINOK(WriteNumber(size));
|
||||
@@ -1024,12 +923,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
RINOK(WriteBoolVector(startsBoolVector));
|
||||
}
|
||||
|
||||
if (externalAttributes)
|
||||
{
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalStartStreamIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(WriteByte(0));
|
||||
RINOK(WriteBytes(startsData));
|
||||
@@ -1042,7 +935,9 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
return _outByte.Flush();
|
||||
}
|
||||
|
||||
HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
HRESULT COutArchive::WriteDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const CArchiveDatabase &database,
|
||||
const CCompressionMethodMode *options,
|
||||
const CHeaderOptions &headerOptions)
|
||||
{
|
||||
@@ -1053,7 +948,7 @@ HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
{
|
||||
headerSize = 0;
|
||||
headerOffset = 0;
|
||||
headerCRC = CCRC::CalculateDigest(0, 0);
|
||||
headerCRC = CrcCalc(0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1063,17 +958,10 @@ HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
if (options != 0)
|
||||
if (options->IsEmpty())
|
||||
options = 0;
|
||||
const CCompressionMethodMode *additionalStreamsOptions = options;
|
||||
if (!headerOptions.UseAdditionalHeaderStreams)
|
||||
additionalStreamsOptions = 0;
|
||||
/*
|
||||
if (database.Files.Size() < 2)
|
||||
compressMainHeader = false;
|
||||
*/
|
||||
if (options != 0)
|
||||
if (options->PasswordIsDefined || headerOptions.CompressMainHeader)
|
||||
_dynamicMode = true;
|
||||
RINOK(WriteHeader(database, additionalStreamsOptions, headerOptions, headerOffset));
|
||||
RINOK(WriteHeader(database, headerOptions, headerOffset));
|
||||
|
||||
if (_dynamicMode)
|
||||
{
|
||||
@@ -1083,14 +971,16 @@ HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
CEncoder encoder(headerOptions.CompressMainHeader ? *options : encryptOptions);
|
||||
CRecordVector<UInt64> packSizes;
|
||||
CObjectVector<CFolder> folders;
|
||||
RINOK(EncodeStream(encoder, _dynamicBuffer,
|
||||
RINOK(EncodeStream(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
encoder, _dynamicBuffer,
|
||||
_dynamicBuffer.GetSize(), packSizes, folders));
|
||||
_dynamicMode = false;
|
||||
_mainMode = true;
|
||||
|
||||
_outByte.SetStream(SeqStream);
|
||||
_outByte.Init();
|
||||
_crc.Init();
|
||||
_crc = CRC_INIT_VAL;
|
||||
|
||||
if (folders.Size() == 0)
|
||||
throw 1;
|
||||
@@ -1098,13 +988,13 @@ HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
RINOK(WriteID(NID::kEncodedHeader));
|
||||
RINOK(WritePackInfo(headerOffset, packSizes,
|
||||
CRecordVector<bool>(), CRecordVector<UInt32>()));
|
||||
RINOK(WriteUnPackInfo(false, 0, folders));
|
||||
RINOK(WriteUnPackInfo(folders));
|
||||
RINOK(WriteByte(NID::kEnd));
|
||||
for (int i = 0; i < packSizes.Size(); i++)
|
||||
headerOffset += packSizes[i];
|
||||
RINOK(_outByte.Flush());
|
||||
}
|
||||
headerCRC = _crc.GetDigest();
|
||||
headerCRC = CRC_GET_DIGEST(_crc);
|
||||
headerSize = _outByte.GetProcessedSize();
|
||||
}
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "../../Common/OutBuffer.h"
|
||||
#include "../../../Common/DynamicBuffer.h"
|
||||
#include "../../../Common/CRC.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
@@ -62,14 +61,14 @@ public:
|
||||
|
||||
struct CHeaderOptions
|
||||
{
|
||||
bool UseAdditionalHeaderStreams;
|
||||
// bool UseAdditionalHeaderStreams;
|
||||
bool CompressMainHeader;
|
||||
bool WriteModified;
|
||||
bool WriteCreated;
|
||||
bool WriteAccessed;
|
||||
|
||||
CHeaderOptions():
|
||||
UseAdditionalHeaderStreams(false),
|
||||
// UseAdditionalHeaderStreams(false),
|
||||
CompressMainHeader(true),
|
||||
WriteModified(true),
|
||||
WriteCreated(false),
|
||||
@@ -105,10 +104,7 @@ class COutArchive
|
||||
const CRecordVector<bool> &packCRCsDefined,
|
||||
const CRecordVector<UInt32> &packCRCs);
|
||||
|
||||
HRESULT WriteUnPackInfo(
|
||||
bool externalFolders,
|
||||
CNum externalFoldersStreamIndex,
|
||||
const CObjectVector<CFolder> &folders);
|
||||
HRESULT WriteUnPackInfo(const CObjectVector<CFolder> &folders);
|
||||
|
||||
HRESULT WriteSubStreamsInfo(
|
||||
const CObjectVector<CFolder> &folders,
|
||||
@@ -133,15 +129,18 @@ class COutArchive
|
||||
*/
|
||||
|
||||
|
||||
HRESULT WriteTime(const CObjectVector<CFileItem> &files, Byte type,
|
||||
bool isExternal, CNum externalDataIndex);
|
||||
HRESULT WriteTime(const CObjectVector<CFileItem> &files, Byte type);
|
||||
|
||||
HRESULT EncodeStream(CEncoder &encoder, const Byte *data, size_t dataSize,
|
||||
HRESULT EncodeStream(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CEncoder &encoder, const Byte *data, size_t dataSize,
|
||||
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders);
|
||||
HRESULT EncodeStream(CEncoder &encoder, const CByteBuffer &data,
|
||||
HRESULT EncodeStream(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CEncoder &encoder, const CByteBuffer &data,
|
||||
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders);
|
||||
HRESULT WriteHeader(const CArchiveDatabase &database,
|
||||
const CCompressionMethodMode *options,
|
||||
HRESULT WriteHeader(
|
||||
const CArchiveDatabase &database,
|
||||
const CHeaderOptions &headerOptions,
|
||||
UInt64 &headerOffset);
|
||||
|
||||
@@ -154,7 +153,7 @@ class COutArchive
|
||||
COutBuffer _outByte;
|
||||
CWriteBufferLoc _outByte2;
|
||||
CWriteDynamicBuffer _dynamicBuffer;
|
||||
CCRC _crc;
|
||||
UInt32 _crc;
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
bool _endMarker;
|
||||
@@ -176,7 +175,9 @@ public:
|
||||
HRESULT Create(ISequentialOutStream *stream, bool endMarker);
|
||||
void Close();
|
||||
HRESULT SkeepPrefixArchiveHeader();
|
||||
HRESULT WriteDatabase(const CArchiveDatabase &database,
|
||||
HRESULT WriteDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const CArchiveDatabase &database,
|
||||
const CCompressionMethodMode *options,
|
||||
const CHeaderOptions &headerOptions);
|
||||
|
||||
|
||||
18
CPP/7zip/Archive/7z/7zRegister.cpp
Executable file
18
CPP/7zip/Archive/7z/7zRegister.cpp
Executable file
@@ -0,0 +1,18 @@
|
||||
// 7zRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterArc.h"
|
||||
|
||||
#include "7zHandler.h"
|
||||
static IInArchive *CreateArc() { return new NArchive::N7z::CHandler; }
|
||||
#ifndef EXTRACT_ONLY
|
||||
static IOutArchive *CreateArcOut() { return new NArchive::N7z::CHandler; }
|
||||
#else
|
||||
#define CreateArcOut 0
|
||||
#endif
|
||||
|
||||
static CArcInfo g_ArcInfo =
|
||||
{ L"7z", L"7z", 0, 7, {'7' + 1 , 'z', 0xBC, 0xAF, 0x27, 0x1C}, 6, false, CreateArc, CreateArcOut };
|
||||
|
||||
REGISTER_ARC_DEC_SIG(7z)
|
||||
@@ -8,10 +8,6 @@
|
||||
#include "7zHandler.h"
|
||||
#include "7zOut.h"
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
#include "7zMethods.h"
|
||||
#endif
|
||||
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
@@ -108,13 +104,6 @@ struct CFolderRef
|
||||
|
||||
#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
|
||||
|
||||
static int CompareMethodIDs(const CMethodID &a1, const CMethodID &a2)
|
||||
{
|
||||
for (int i = 0; i < a1.IDSize && i < a2.IDSize; i++)
|
||||
RINOZ(MyCompare(a1.ID[i], a2.ID[i]));
|
||||
return MyCompare(a1.IDSize, a2.IDSize);
|
||||
}
|
||||
|
||||
static int CompareBuffers(const CByteBuffer &a1, const CByteBuffer &a2)
|
||||
{
|
||||
size_t c1 = a1.GetCapacity();
|
||||
@@ -125,22 +114,12 @@ static int CompareBuffers(const CByteBuffer &a1, const CByteBuffer &a2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int CompareAltCoders(const CAltCoderInfo &a1, const CAltCoderInfo &a2)
|
||||
{
|
||||
RINOZ(CompareMethodIDs(a1.MethodID, a2.MethodID));
|
||||
return CompareBuffers(a1.Properties, a2.Properties);
|
||||
}
|
||||
|
||||
static int CompareCoders(const CCoderInfo &c1, const CCoderInfo &c2)
|
||||
{
|
||||
RINOZ(MyCompare(c1.NumInStreams, c2.NumInStreams));
|
||||
RINOZ(MyCompare(c1.NumOutStreams, c2.NumOutStreams));
|
||||
int s1 = c1.AltCoders.Size();
|
||||
int s2 = c2.AltCoders.Size();
|
||||
RINOZ(MyCompare(s1, s2));
|
||||
for (int i = 0; i < s1; i++)
|
||||
RINOZ(CompareAltCoders(c1.AltCoders[i], c2.AltCoders[i]));
|
||||
return 0;
|
||||
RINOZ(MyCompare(c1.MethodID, c2.MethodID));
|
||||
return CompareBuffers(c1.Properties, c2.Properties);
|
||||
}
|
||||
|
||||
static int CompareBindPairs(const CBindPair &b1, const CBindPair &b2)
|
||||
@@ -371,28 +350,17 @@ static bool IsExeFile(const UString &ext)
|
||||
return false;
|
||||
}
|
||||
|
||||
static CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static const UInt64 k_Copy = 0x0;
|
||||
static const UInt64 k_LZMA = 0x030101;
|
||||
static const UInt64 k_BCJ = 0x03030103;
|
||||
static const UInt64 k_BCJ2 = 0x0303011B;
|
||||
|
||||
static bool GetMethodFull(const CMethodID &methodID,
|
||||
static bool GetMethodFull(UInt64 methodID,
|
||||
UInt32 numInStreams, CMethodFull &methodResult)
|
||||
{
|
||||
methodResult.MethodID = methodID;
|
||||
methodResult.NumInStreams = numInStreams;
|
||||
methodResult.NumOutStreams = 1;
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
CMethodInfo methodInfo;
|
||||
if (!GetMethodInfo(methodID, methodInfo))
|
||||
return false;
|
||||
if (!methodInfo.EncoderIsAssigned)
|
||||
return false;
|
||||
methodResult.EncoderClassID = methodInfo.Encoder;
|
||||
methodResult.FilePath = methodInfo.FilePath;
|
||||
if (methodInfo.NumOutStreams != 1 || methodInfo.NumInStreams != numInStreams)
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -455,7 +423,7 @@ static bool MakeExeMethod(const CCompressionMethodMode &method,
|
||||
else
|
||||
{
|
||||
CMethodFull methodFull;
|
||||
if (!GetMethodFull(k_BCJ_X86, 1, methodFull))
|
||||
if (!GetMethodFull(k_BCJ, 1, methodFull))
|
||||
return false;
|
||||
exeMethod.Methods.Insert(0, methodFull);
|
||||
CBind bind;
|
||||
@@ -537,6 +505,7 @@ static void FromUpdateItemToFileItem(const CUpdateItem &updateItem,
|
||||
}
|
||||
|
||||
static HRESULT Update2(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
const CArchiveDatabaseEx *database,
|
||||
const CObjectVector<CUpdateItem> &updateItems,
|
||||
@@ -775,8 +744,11 @@ static HRESULT Update2(
|
||||
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
|
||||
localCompressProgressSpec->Init(localProgress, &complexity, NULL);
|
||||
|
||||
RINOK(encoder.Encode(solidInStream, NULL, &inSizeForReduce, folderItem,
|
||||
archive.SeqStream, newDatabase.PackSizes, compressProgress));
|
||||
RINOK(encoder.Encode(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
solidInStream, NULL, &inSizeForReduce, folderItem,
|
||||
archive.SeqStream, newDatabase.PackSizes, compressProgress));
|
||||
|
||||
// for()
|
||||
// newDatabase.PackCRCsDefined.Add(false);
|
||||
// newDatabase.PackCRCs.Add(0);
|
||||
@@ -865,19 +837,17 @@ static HRESULT Update2(
|
||||
return E_FAIL;
|
||||
*/
|
||||
|
||||
return archive.WriteDatabase(newDatabase, options.HeaderMethod, options.HeaderOptions);
|
||||
return archive.WriteDatabase(EXTERNAL_CODECS_LOC_VARS
|
||||
newDatabase, options.HeaderMethod, options.HeaderOptions);
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
static HRESULT WriteVolumeHeader(COutArchive &archive, CFileItem &file, const CUpdateOptions &options)
|
||||
{
|
||||
CAltCoderInfo altCoder;
|
||||
altCoder.MethodID.IDSize = 1;
|
||||
altCoder.MethodID.ID[0] = 0;
|
||||
CCoderInfo coder;
|
||||
coder.NumInStreams = coder.NumOutStreams = 1;
|
||||
coder.AltCoders.Add(altCoder);
|
||||
coder.MethodID = k_Copy;
|
||||
|
||||
CFolder folder;
|
||||
folder.Coders.Add(coder);
|
||||
@@ -1066,6 +1036,7 @@ STDMETHODIMP COutVolumeStream::Write(const void *data, UInt32 size, UInt32 *proc
|
||||
#endif
|
||||
|
||||
HRESULT Update(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
const CArchiveDatabaseEx *database,
|
||||
const CObjectVector<CUpdateItem> &updateItems,
|
||||
@@ -1076,7 +1047,9 @@ HRESULT Update(
|
||||
#ifdef _7Z_VOL
|
||||
if (seqOutStream)
|
||||
#endif
|
||||
return Update2(inStream, database, updateItems,
|
||||
return Update2(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
inStream, database, updateItems,
|
||||
seqOutStream, updateCallback, options);
|
||||
#ifdef _7Z_VOL
|
||||
if (options.VolumeMode)
|
||||
|
||||
@@ -68,6 +68,7 @@ struct CUpdateOptions
|
||||
};
|
||||
|
||||
HRESULT Update(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
const CArchiveDatabaseEx *database,
|
||||
const CObjectVector<CUpdateItem> &updateItems,
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/MyInitGuid.h"
|
||||
#include "../../../Common/ComTry.h"
|
||||
#ifdef _WIN32
|
||||
#include "../../../Common/Alloc.h"
|
||||
#endif
|
||||
|
||||
#include "../../ICoder.h"
|
||||
|
||||
#include "7zHandler.h"
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
// {23170F69-40C1-278B-06F1-070100000100}
|
||||
DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00);
|
||||
#endif
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != NArchive::N7z::CLSID_CFormat7z)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
if (*interfaceID == IID_IInArchive)
|
||||
{
|
||||
CMyComPtr<IInArchive> inArchive = new NArchive::N7z::CHandler;
|
||||
*outObject = inArchive.Detach();
|
||||
}
|
||||
#ifndef EXTRACT_ONLY
|
||||
else if (*interfaceID == IID_IOutArchive)
|
||||
{
|
||||
CMyComPtr<IOutArchive> outArchive = new NArchive::N7z::CHandler;
|
||||
*outObject = outArchive.Detach();
|
||||
}
|
||||
#endif
|
||||
else
|
||||
return E_NOINTERFACE;
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case NArchive::kName:
|
||||
propVariant = L"7z";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&NArchive::N7z::CLSID_CFormat7z, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"7z";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = true;
|
||||
break;
|
||||
case NArchive::kKeepName:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen((const char *)NArchive::N7z::kSignature,
|
||||
NArchive::N7z::kSignatureSize)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
PROG = 7z.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
|
||||
CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DCOMPRESS_MT \
|
||||
-DEXTERNAL_CODECS \
|
||||
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
AR_OBJS = \
|
||||
$O\ArchiveExports.obj \
|
||||
$O\DllExports.obj \
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zCompressionMode.obj \
|
||||
$O\7zDecode.obj \
|
||||
@@ -14,16 +21,13 @@ LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
$O\7zIn.obj \
|
||||
$O\7zMethodID.obj \
|
||||
$O\7zMethods.obj \
|
||||
$O\7zOut.obj \
|
||||
$O\7zProperties.obj \
|
||||
$O\7zSpecStream.obj \
|
||||
$O\7zUpdate.obj \
|
||||
$O\DllExports.obj \
|
||||
$O\7zRegister.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\CRC.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
@@ -41,9 +45,12 @@ WIN_OBJS = \
|
||||
$O\Synchronization.obj
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\CreateCoder.obj \
|
||||
$O\InOutTempBuffer.obj \
|
||||
$O\FilterCoder.obj \
|
||||
$O\LimitedStreams.obj \
|
||||
$O\LockedStream.obj \
|
||||
$O\MethodId.obj \
|
||||
$O\OutBuffer.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamBinder.obj \
|
||||
@@ -51,30 +58,37 @@ WIN_OBJS = \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CodecsPath.obj \
|
||||
$O\CoderLoader.obj \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CoderMixer2MT.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\FilterCoder.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
|
||||
!include "../../Crc2.mak"
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(AR_OBJS) \
|
||||
$(7Z_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$(C_OBJS) \
|
||||
$(CRC_OBJS) \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(AR_OBJS): ../$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7Z_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
@@ -87,3 +101,6 @@ $(AR_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(C_OBJS): ../../../../C/$(*B).c
|
||||
$(COMPL_O2)
|
||||
!include "../../Crc.mak"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
EXPORTS
|
||||
CreateObject PRIVATE
|
||||
GetHandlerProperty PRIVATE
|
||||
GetNumberOfFormats PRIVATE
|
||||
GetHandlerProperty2 PRIVATE
|
||||
CreateObject PRIVATE
|
||||
|
||||
8
CPP/7zip/Archive/Archive2.def
Executable file
8
CPP/7zip/Archive/Archive2.def
Executable file
@@ -0,0 +1,8 @@
|
||||
EXPORTS
|
||||
CreateObject PRIVATE
|
||||
GetHandlerProperty PRIVATE
|
||||
GetNumberOfFormats PRIVATE
|
||||
GetHandlerProperty2 PRIVATE
|
||||
CreateObject PRIVATE
|
||||
GetNumberOfMethods PRIVATE
|
||||
GetMethodProperty PRIVATE
|
||||
130
CPP/7zip/Archive/ArchiveExports.cpp
Executable file
130
CPP/7zip/Archive/ArchiveExports.cpp
Executable file
@@ -0,0 +1,130 @@
|
||||
// ArchiveExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/ComTry.h"
|
||||
#include "../../Common/Types.h"
|
||||
#include "../../Windows/PropVariant.h"
|
||||
#include "../Common/RegisterArc.h"
|
||||
|
||||
#include "IArchive.h"
|
||||
#include "../ICoder.h"
|
||||
#include "../IPassword.h"
|
||||
|
||||
static const unsigned int kNumArcsMax = 32;
|
||||
static unsigned int g_NumArcs = 0;
|
||||
static const CArcInfo *g_Arcs[kNumArcsMax];
|
||||
void RegisterArc(const CArcInfo *arcInfo)
|
||||
{
|
||||
if (g_NumArcs < kNumArcsMax)
|
||||
g_Arcs[g_NumArcs++] = arcInfo;
|
||||
}
|
||||
|
||||
DEFINE_GUID(CLSID_CArchiveHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
|
||||
|
||||
#define CLS_ARC_ID_ITEM(cls) ((cls).Data4[5])
|
||||
|
||||
static inline HRESULT SetPropString(const char *s, unsigned int size, PROPVARIANT *value)
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(s, size)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static inline HRESULT SetPropGUID(const GUID &guid, PROPVARIANT *value)
|
||||
{
|
||||
return SetPropString((const char *)&guid, sizeof(GUID), value);
|
||||
}
|
||||
|
||||
int FindFormatCalssId(const GUID *clsID)
|
||||
{
|
||||
GUID cls = *clsID;
|
||||
CLS_ARC_ID_ITEM(cls) = 0;
|
||||
if (cls != CLSID_CArchiveHandler)
|
||||
return -1;
|
||||
Byte id = CLS_ARC_ID_ITEM(*clsID);
|
||||
for (UInt32 i = 0; i < g_NumArcs; i++)
|
||||
if (g_Arcs[i]->ClassId == id)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
STDAPI CreateArchiver(const GUID *clsid, const GUID *iid, void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
{
|
||||
int needIn = (*iid == IID_IInArchive);
|
||||
int needOut = (*iid == IID_IOutArchive);
|
||||
if (!needIn && !needOut)
|
||||
return E_NOINTERFACE;
|
||||
int formatIndex = FindFormatCalssId(clsid);
|
||||
if (formatIndex < 0)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
|
||||
const CArcInfo &arc = *g_Arcs[formatIndex];
|
||||
if (needIn)
|
||||
{
|
||||
*outObject = arc.CreateInArchive();
|
||||
((IInArchive *)*outObject)->AddRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!arc.CreateOutArchive)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
*outObject = arc.CreateOutArchive();
|
||||
((IOutArchive *)*outObject)->AddRef();
|
||||
}
|
||||
}
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
if (formatIndex >= g_NumArcs)
|
||||
return E_INVALIDARG;
|
||||
const CArcInfo &arc = *g_Arcs[formatIndex];
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case NArchive::kName:
|
||||
propVariant = arc.Name;
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
GUID clsId = CLSID_CArchiveHandler;
|
||||
CLS_ARC_ID_ITEM(clsId) = arc.ClassId;
|
||||
return SetPropGUID(clsId, value);
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
if (arc.Ext != 0)
|
||||
propVariant = arc.Ext;
|
||||
break;
|
||||
case NArchive::kAddExtension:
|
||||
if (arc.AddExt != 0)
|
||||
propVariant = arc.AddExt;
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = (bool)(arc.CreateOutArchive != 0);
|
||||
break;
|
||||
case NArchive::kKeepName:
|
||||
propVariant = arc.KeepName;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
return SetPropString((const char *)arc.Signature, arc.SignatureSize, value);
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
return GetHandlerProperty2(0, propID, value);
|
||||
}
|
||||
|
||||
STDAPI GetNumberOfFormats(UINT32 *numFormats)
|
||||
{
|
||||
*numFormats = g_NumArcs;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1,329 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="arj" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=arj - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "arj.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "arj.mak" CFG="arj - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "arj - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "arj - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "arj - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ARJ_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ARJ_EXPORTS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Formats\arj.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "arj - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ARJ_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ARJ_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Formats\arj.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "arj - Win32 Release"
|
||||
# Name "arj - Win32 Debug"
|
||||
# Begin Group "spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ArjHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ArjHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ArjHeader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ArjIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ArjIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ArjItem.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "Codecs"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Arj\ArjDecoder1.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Arj\ArjDecoder1.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Arj\ArjDecoder2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Arj\ArjDecoder2.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "LZ"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\LZ\LZOutWindow.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\LZ\LZOutWindow.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Copy"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Group "7zip common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\MSBFDecoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OutStreamWithCRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\arj.ico
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "arj"=.\arj.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/CRC.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Buffer.h"
|
||||
#include "Common/CRC.h"
|
||||
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "ArjIn.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/7zCrc.h"
|
||||
}
|
||||
|
||||
namespace NArchive {
|
||||
namespace NArj {
|
||||
|
||||
@@ -47,7 +51,7 @@ inline bool TestMarkerCandidate(const void *testBytes, UInt32 maxSize)
|
||||
if (blockSize == 0 || blockSize > 2600)
|
||||
return false;
|
||||
UInt32 crcFromFile = GetUInt32FromMemLE(block + blockSize);
|
||||
return (CCRC::VerifyDigest(crcFromFile, block, blockSize));
|
||||
return (crcFromFile == CrcCalc(block, blockSize));
|
||||
}
|
||||
|
||||
bool CInArchive::FindAndReadMarker(const UInt64 *searchHeaderSizeLimit)
|
||||
@@ -168,7 +172,7 @@ bool CInArchive::ReadBlock()
|
||||
return false;
|
||||
SafeReadBytes(_block, _blockSize);
|
||||
UInt32 crcFromFile = SafeReadUInt32();
|
||||
if (!CCRC::VerifyDigest(crcFromFile, _block, _blockSize))
|
||||
if (crcFromFile != CrcCalc(_block, _blockSize))
|
||||
throw CInArchiveException(CInArchiveException::kCRCError);
|
||||
return true;
|
||||
}
|
||||
|
||||
13
CPP/7zip/Archive/Arj/ArjRegister.cpp
Executable file
13
CPP/7zip/Archive/Arj/ArjRegister.cpp
Executable file
@@ -0,0 +1,13 @@
|
||||
// ArjRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterArc.h"
|
||||
|
||||
#include "ArjHandler.h"
|
||||
static IInArchive *CreateArc() { return new NArchive::NArj::CHandler; }
|
||||
|
||||
static CArcInfo g_ArcInfo =
|
||||
{ L"Arj", L"arj", 0, 4, { 0x60, 0xEA }, 2, false, CreateArc, 0 };
|
||||
|
||||
REGISTER_ARC(Arj)
|
||||
@@ -1,72 +0,0 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "../../ICoder.h"
|
||||
#include "ArjHandler.h"
|
||||
|
||||
// {23170F69-40C1-278A-1000-000110040000}
|
||||
DEFINE_GUID(CLSID_CArjHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x04, 0x00, 0x00);
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != CLSID_CArjHandler)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
if (*interfaceID != IID_IInArchive)
|
||||
return E_NOINTERFACE;
|
||||
CMyComPtr<IInArchive> inArchive = (IInArchive *)new NArchive::NArj::CHandler;
|
||||
*outObject = inArchive.Detach();
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case NArchive::kName:
|
||||
propVariant = L"Arj";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CArjHandler, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"arj";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kKeepName:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
const unsigned char sig[] = { 0x60, 0xEA };
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen((const char *)sig, 2)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
PROG = arj.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
ARJ_OBJS = \
|
||||
$O\DllExports.obj \
|
||||
$O\ArjHandler.obj \
|
||||
$O\ArjIn.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\CRC.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\Vector.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\PropVariant.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\InBuffer.obj \
|
||||
$O\LimitedStreams.obj \
|
||||
$O\OutBuffer.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
|
||||
COMPRESS_ARJ_OBJS = \
|
||||
$O\ArjDecoder1.obj \
|
||||
$O\ArjDecoder2.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(ARJ_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$(COMPRESS_ARJ_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$O\LZOutWindow.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(ARJ_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AR_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMPRESS_ARJ_OBJS): ../../Compress/Arj/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\LZOutWindow.obj: ../../Compress/LZ/$(*B).cpp
|
||||
$(COMPL)
|
||||
@@ -1,5 +0,0 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("Arj Plugin", "arj")
|
||||
|
||||
101 ICON "arj.ico"
|
||||
@@ -1,281 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="BZip2" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=BZip2 - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "BZip2.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "BZip2.mak" CFG="BZip2 - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BZip2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "BZip2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Formats\bz2.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Formats\bz2.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "BZip2 - Win32 Release"
|
||||
# Name "BZip2 - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"StdAfx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compression"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DummyOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DummyOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Handler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Handler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2HandlerOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Item.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Update.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Update.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7zip common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bz2.ico
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "BZip2"=.\BZip2.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -2,34 +2,25 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "BZip2Handler.h"
|
||||
|
||||
#include "Common/ComTry.h"
|
||||
#include "Common/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../Common/DummyOutStream.h"
|
||||
|
||||
#ifdef COMPRESS_BZIP2
|
||||
#include "../../Compress/BZip2/BZip2Decoder.h"
|
||||
#else
|
||||
// {23170F69-40C1-278B-0402-020000000000}
|
||||
DEFINE_GUID(CLSID_CCompressBZip2Decoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
#include "../Common/CoderLoader.h"
|
||||
extern CSysString GetBZip2CodecPath();
|
||||
#endif
|
||||
#include "BZip2Handler.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
static const CMethodId kMethodId_BZip2 = 0x040202;
|
||||
|
||||
STATPROPSTG kProperties[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
@@ -174,22 +165,15 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
|
||||
extractCallback->PrepareOperation(askMode);
|
||||
|
||||
#ifndef COMPRESS_BZIP2
|
||||
CCoderLibrary lib;
|
||||
#endif
|
||||
CMyComPtr<ICompressCoder> decoder;
|
||||
#ifdef COMPRESS_BZIP2
|
||||
decoder = new NCompress::NBZip2::CDecoder;
|
||||
#else
|
||||
HRESULT loadResult = lib.LoadAndCreateCoder(
|
||||
GetBZip2CodecPath(),
|
||||
CLSID_CCompressBZip2Decoder, &decoder);
|
||||
if (loadResult != S_OK)
|
||||
HRESULT loadResult = CreateCoder(
|
||||
EXTERNAL_CODECS_VARS
|
||||
kMethodId_BZip2, decoder, false);
|
||||
if (loadResult != S_OK || !decoder)
|
||||
{
|
||||
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
{
|
||||
@@ -284,4 +268,6 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
IMPL_ISetCompressCodecsInfo
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "../IArchive.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "BZip2Item.h"
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
@@ -18,6 +19,7 @@ class CHandler:
|
||||
public IInArchive,
|
||||
public IOutArchive,
|
||||
public ISetProperties,
|
||||
PUBLIC_ISetCompressCodecsInfo
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CMyComPtr<IInStream> _stream;
|
||||
@@ -30,6 +32,9 @@ class CHandler:
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 _numThreads;
|
||||
#endif
|
||||
|
||||
DECL_EXTERNAL_CODECS_VARS
|
||||
|
||||
void InitMethodProperties()
|
||||
{
|
||||
_level = 5;
|
||||
@@ -41,11 +46,13 @@ class CHandler:
|
||||
}
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP3(
|
||||
IInArchive,
|
||||
IOutArchive,
|
||||
ISetProperties
|
||||
)
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
@@ -75,6 +82,8 @@ public:
|
||||
// ISetProperties
|
||||
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
|
||||
|
||||
DECL_ISetCompressCodecsInfo
|
||||
|
||||
CHandler() { InitMethodProperties(); }
|
||||
};
|
||||
|
||||
|
||||
@@ -91,11 +91,13 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
(_level >= 7 ? kNumPassesX7 :
|
||||
kNumPassesX1));
|
||||
|
||||
return UpdateArchive(size, outStream, 0, dicSize, numPasses,
|
||||
#ifdef COMPRESS_MT
|
||||
_numThreads,
|
||||
#endif
|
||||
updateCallback);
|
||||
return UpdateArchive(
|
||||
EXTERNAL_CODECS_VARS
|
||||
size, outStream, 0, dicSize, numPasses,
|
||||
#ifdef COMPRESS_MT
|
||||
_numThreads,
|
||||
#endif
|
||||
updateCallback);
|
||||
}
|
||||
if (indexInArchive != 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
@@ -3,24 +3,19 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "BZip2Update.h"
|
||||
|
||||
#ifdef COMPRESS_BZIP2
|
||||
#include "../../Compress/BZip2/BZip2Encoder.h"
|
||||
#else
|
||||
// {23170F69-40C1-278B-0402-020000000100}
|
||||
DEFINE_GUID(CLSID_CCompressBZip2Encoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00);
|
||||
#include "../Common/CoderLoader.h"
|
||||
extern CSysString GetBZip2CodecPath();
|
||||
#endif
|
||||
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
HRESULT UpdateArchive(UInt64 unpackSize,
|
||||
static const CMethodId kMethodId_BZip2 = 0x040202;
|
||||
|
||||
HRESULT UpdateArchive(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
int indexInClient,
|
||||
UInt32 dictionary,
|
||||
@@ -42,17 +37,12 @@ HRESULT UpdateArchive(UInt64 unpackSize,
|
||||
CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
|
||||
localProgressSpec->Init(updateCallback, true);
|
||||
|
||||
#ifndef COMPRESS_BZIP2
|
||||
CCoderLibrary lib;
|
||||
#endif
|
||||
CMyComPtr<ICompressCoder> encoder;
|
||||
#ifdef COMPRESS_BZIP2
|
||||
encoder = new NCompress::NBZip2::CEncoder;
|
||||
#else
|
||||
RINOK(lib.LoadAndCreateCoder(GetBZip2CodecPath(),
|
||||
CLSID_CCompressBZip2Encoder, &encoder));
|
||||
#endif
|
||||
|
||||
RINOK(CreateCoder(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
kMethodId_BZip2, encoder, true));
|
||||
if (!encoder)
|
||||
return E_NOTIMPL;
|
||||
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
|
||||
encoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
|
||||
if (setCoderProperties)
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#define __BZIP2_UPDATE_H
|
||||
|
||||
#include "../IArchive.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
HRESULT UpdateArchive(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
int indexInClient,
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "BZip2Handler.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
// {23170F69-40C1-278B-0402-020000000100}
|
||||
DEFINE_GUID(CLSID_CCompressBZip2Encoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00);
|
||||
|
||||
// {23170F69-40C1-278B-0402-020000000000}
|
||||
DEFINE_GUID(CLSID_CCompressBZip2Decoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
// {23170F69-40C1-278A-1000-000110020000}
|
||||
DEFINE_GUID(CLSID_CBZip2Handler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x02, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COMPRESS_BZIP2
|
||||
#include "../Common/CodecsPath.h"
|
||||
CSysString GetBZip2CodecPath()
|
||||
{
|
||||
return GetCodecsFolderPrefix() + TEXT("BZip2.dll");
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != CLSID_CBZip2Handler)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
int needIn = *interfaceID == IID_IInArchive;
|
||||
int needOut = *interfaceID == IID_IOutArchive;
|
||||
if (needIn || needOut)
|
||||
{
|
||||
NArchive::NBZip2::CHandler *temp = new NArchive::NBZip2::CHandler;
|
||||
if (needIn)
|
||||
{
|
||||
CMyComPtr<IInArchive> inArchive = (IInArchive *)temp;
|
||||
*outObject = inArchive.Detach();
|
||||
}
|
||||
else
|
||||
{
|
||||
CMyComPtr<IOutArchive> outArchive = (IOutArchive *)temp;
|
||||
*outObject = outArchive.Detach();
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_NOINTERFACE;
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case NArchive::kName:
|
||||
propVariant = L"BZip2";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CBZip2Handler, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"bz2 bzip2 tbz2 tbz";
|
||||
break;
|
||||
case NArchive::kAddExtension:
|
||||
propVariant = L"* * .tar .tar";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = true;
|
||||
break;
|
||||
case NArchive::kKeepName:
|
||||
propVariant = true;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
const char sig[] = { 'B', 'Z', 'h' };
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(sig, 3)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
18
CPP/7zip/Archive/BZip2/bz2Register.cpp
Executable file
18
CPP/7zip/Archive/BZip2/bz2Register.cpp
Executable file
@@ -0,0 +1,18 @@
|
||||
// BZip2Register.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterArc.h"
|
||||
|
||||
#include "BZip2Handler.h"
|
||||
static IInArchive *CreateArc() { return new NArchive::NBZip2::CHandler; }
|
||||
#ifndef EXTRACT_ONLY
|
||||
static IOutArchive *CreateArcOut() { return new NArchive::NBZip2::CHandler; }
|
||||
#else
|
||||
#define CreateArcOut 0
|
||||
#endif
|
||||
|
||||
static CArcInfo g_ArcInfo =
|
||||
{ L"BZip2", L"bz2 bzip2 tbz2 tbz", L"* * .tar .tar", 2, { 'B', 'Z', 'h' }, 3, true, CreateArc, CreateArcOut };
|
||||
|
||||
REGISTER_ARC(BZip2)
|
||||
@@ -1,55 +0,0 @@
|
||||
PROG = bz2.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
BZ2_OBJS = \
|
||||
$O\BZip2Handler.obj \
|
||||
$O\BZip2HandlerOut.obj \
|
||||
$O\BZip2Update.obj \
|
||||
$O\DllExports.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\PropVariant.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CodecsPath.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(BZ2_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(BZ2_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AR_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
@@ -1,5 +0,0 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("BZip2 Plugin", "bz2")
|
||||
|
||||
101 ICON "bz2.ico"
|
||||
@@ -1,395 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="Cab" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Cab - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Cab.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Cab.mak" CFG="Cab - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Cab - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Cab - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Cab - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAB_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAB_EXPORTS" /FAs /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Formats\cab.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Cab - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAB_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAB_EXPORTS" /FAcs /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Formats\cab.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Cab - Win32 Release"
|
||||
# Name "Cab - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\UTFConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\UTFConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CabBlockInStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CabBlockInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CabHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CabHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CabHeader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CabHeader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CabIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CabIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CabItem.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LSBFDecoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LSBFDecoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\MSBFDecoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "LZ"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\LZ\LZOutWindow.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\LZ\LZOutWindow.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Lzx"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\Lzx.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\Lzx86Converter.cpp
|
||||
|
||||
!IF "$(CFG)" == "Cab - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Cab - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\Lzx86Converter.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\LzxDecoder.cpp
|
||||
|
||||
!IF "$(CFG)" == "Cab - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Cab - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\LzxDecoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Deflate"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Deflate\DeflateConst.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Deflate\DeflateDecoder.cpp
|
||||
|
||||
!IF "$(CFG)" == "Cab - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Cab - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Deflate\DeflateDecoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Deflate\DeflateExtConst.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Copy"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Quantum"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Quantum\QuantumDecoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Quantum\QuantumDecoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Huffman"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Huffman\HuffmanDecoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cab.ico
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Cab"=.\Cab.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/Alloc.h"
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Alloc.h"
|
||||
}
|
||||
|
||||
#include "Common/Defs.h"
|
||||
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/Alloc.h"
|
||||
#include "Common/UTFConvert.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
13
CPP/7zip/Archive/Cab/CabRegister.cpp
Executable file
13
CPP/7zip/Archive/Cab/CabRegister.cpp
Executable file
@@ -0,0 +1,13 @@
|
||||
// CabRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterArc.h"
|
||||
|
||||
#include "CabHandler.h"
|
||||
static IInArchive *CreateArc() { return new NArchive::NCab::CHandler; }
|
||||
|
||||
static CArcInfo g_ArcInfo =
|
||||
{ L"Cab", L"cab", 0, 8, { 0x4D, 0x53, 0x43, 0x46 }, 4, false, CreateArc, 0 };
|
||||
|
||||
REGISTER_ARC(Cab)
|
||||
@@ -1,72 +0,0 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "CabHandler.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
// {23170F69-40C1-278A-1000-000110080000}
|
||||
DEFINE_GUID(CLSID_CCabHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x08, 0x00, 0x00);
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != CLSID_CCabHandler)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
if (*interfaceID != IID_IInArchive)
|
||||
return E_NOINTERFACE;
|
||||
CMyComPtr<IInArchive> inArchive = (IInArchive *)new NArchive::NCab::CHandler;
|
||||
*outObject = inArchive.Detach();
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case NArchive::kName:
|
||||
propVariant = L"Cab";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CCabHandler, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"cab";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kKeepName:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
const char sig[] = { 0x4D, 0x53, 0x43, 0x46 };
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(sig, 4)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
PROG = cab.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
CAB_OBJS = \
|
||||
$O\DllExports.obj \
|
||||
$O\CabBlockInStream.obj \
|
||||
$O\CabHandler.obj \
|
||||
$O\CabHeader.obj \
|
||||
$O\CabIn.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
$O\UTFConvert.obj \
|
||||
$O\Vector.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\PropVariant.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\InBuffer.obj \
|
||||
$O\LSBFDecoder.obj \
|
||||
$O\OutBuffer.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
COMPRESS_LZX_OBJS = \
|
||||
$O\LzxDecoder.obj \
|
||||
$O\Lzx86Converter.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(CAB_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(COMPRESS_LZX_OBJS) \
|
||||
$O\DeflateDecoder.obj \
|
||||
$O\QuantumDecoder.obj \
|
||||
$O\LZOutWindow.obj \
|
||||
$O\CopyCoder.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(CAB_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMPRESS_LZX_OBJS): ../../Compress/Lzx/$(*B).cpp
|
||||
$(COMPL_O2)
|
||||
$O\DeflateDecoder.obj: ../../Compress/Deflate/$(*B).cpp
|
||||
$(COMPL_O2)
|
||||
$O\QuantumDecoder.obj: ../../Compress/Quantum/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\LZOutWindow.obj: ../../Compress/LZ/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("Cab Plugin", "cab")
|
||||
|
||||
101 ICON "cab.ico"
|
||||
@@ -1,337 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="Chm" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Chm - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Chm.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Chm.mak" CFG="Chm - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Chm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Chm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Chm - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CHM_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CHM_EXPORTS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Formats\chm.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Chm - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CHM_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CHM_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Formats\chm.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Chm - Win32 Release"
|
||||
# Name "Chm - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"StdAfx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChmHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChmHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChmHeader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChmHeader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChmIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChmIn.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Buffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\UTFConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\UTFConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "LZ"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\LZ\LZOutWindow.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\LZ\LZOutWindow.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Lzx"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\Lzx.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\Lzx86Converter.cpp
|
||||
|
||||
!IF "$(CFG)" == "Chm - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Chm - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\Lzx86Converter.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\LzxDecoder.cpp
|
||||
|
||||
!IF "$(CFG)" == "Chm - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Chm - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzx\LzxDecoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Chm"=.\Chm.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
13
CPP/7zip/Archive/Chm/ChmRegister.cpp
Executable file
13
CPP/7zip/Archive/Chm/ChmRegister.cpp
Executable file
@@ -0,0 +1,13 @@
|
||||
// ChmRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterArc.h"
|
||||
|
||||
#include "ChmHandler.h"
|
||||
static IInArchive *CreateArc() { return new NArchive::NChm::CHandler; }
|
||||
|
||||
static CArcInfo g_ArcInfo =
|
||||
{ L"Chm", L"chm chi chq chw hxs hxi hxr hxq hxw lit", 0, 0xE9, { 'I', 'T', 'S', 'F' }, 4, false, CreateArc, 0 };
|
||||
|
||||
REGISTER_ARC(Chm)
|
||||
@@ -1,77 +0,0 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "ChmHandler.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
// {23170F69-40C1-278A-1000-000110E90000}
|
||||
DEFINE_GUID(CLSID_CChmHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE9, 0x00, 0x00);
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != CLSID_CChmHandler)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
if (*interfaceID != IID_IInArchive)
|
||||
return E_NOINTERFACE;
|
||||
CMyComPtr<IInArchive> inArchive = (IInArchive *)new NArchive::NChm::CHandler;
|
||||
*outObject = inArchive.Detach();
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case NArchive::kName:
|
||||
propVariant = L"Chm";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CChmHandler, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"chm chi chq chw hxs hxi hxr hxq hxw lit";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kKeepName:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
const char sig[] = { 'I', 'T', 'S', 'F' };
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(sig, 4)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kAssociate:
|
||||
{
|
||||
propVariant = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
PROG = chm.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
CHM_OBJS = \
|
||||
$O\DllExports.obj \
|
||||
$O\ChmHandler.obj \
|
||||
$O\ChmHeader.obj \
|
||||
$O\ChmIn.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\UTFConvert.obj \
|
||||
$O\Vector.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\PropVariant.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\InBuffer.obj \
|
||||
$O\LimitedStreams.obj \
|
||||
$O\OutBuffer.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\ItemNameUtils.obj \
|
||||
|
||||
COMPRESS_LZX_OBJS = \
|
||||
$O\LzxDecoder.obj \
|
||||
$O\Lzx86Converter.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(CHM_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$(COMPRESS_LZX_OBJS) \
|
||||
$O\LZOutWindow.obj \
|
||||
$O\CopyCoder.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(CHM_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AR_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMPRESS_LZX_OBJS): ../../Compress/Lzx/$(*B).cpp
|
||||
$(COMPL_O2)
|
||||
$O\LZOutWindow.obj: ../../Compress/LZ/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("Chm Plugin", "chm")
|
||||
@@ -1,34 +0,0 @@
|
||||
// CodecsPath.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "../../../Common/String.h"
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
static CSysString GetLibraryPath()
|
||||
{
|
||||
TCHAR fullPath[MAX_PATH + 1];
|
||||
::GetModuleFileName(g_hInstance, fullPath, MAX_PATH);
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
static CSysString GetLibraryFolderPrefix()
|
||||
{
|
||||
CSysString path = GetLibraryPath();
|
||||
int pos = path.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
|
||||
return path.Left(pos + 1);
|
||||
}
|
||||
|
||||
CSysString GetBaseFolderPrefix()
|
||||
{
|
||||
CSysString libPrefix = GetLibraryFolderPrefix();
|
||||
CSysString temp = libPrefix;
|
||||
temp.Delete(temp.Length() - 1);
|
||||
int pos = temp.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
|
||||
return temp.Left(pos + 1);
|
||||
}
|
||||
|
||||
CSysString GetCodecsFolderPrefix()
|
||||
{
|
||||
return GetBaseFolderPrefix() + (CSysString)(TEXT("Codecs")) + (CSysString)(TEXT(STRING_PATH_SEPARATOR));
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// CodecsPath.h
|
||||
|
||||
#ifndef __CODECSPATH_H
|
||||
#define __CODECSPATH_H
|
||||
|
||||
#include "../../../Common/String.h"
|
||||
|
||||
CSysString GetBaseFolderPrefix();
|
||||
CSysString GetCodecsFolderPrefix();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
// CoderLoader.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "CoderLoader.h"
|
||||
#include "FilterCoder.h"
|
||||
|
||||
HRESULT CCoderLibrary::CreateCoderSpec(REFGUID clsID, ICompressCoder **coder)
|
||||
{
|
||||
HRESULT result = CreateObject(clsID, IID_ICompressCoder, (void **)coder);
|
||||
if (result == S_OK || result != E_NOINTERFACE)
|
||||
return result;
|
||||
CMyComPtr<ICompressFilter> filter;
|
||||
RINOK(CreateObject(clsID, IID_ICompressFilter, (void **)&filter));
|
||||
CFilterCoder *filterCoderSpec = new CFilterCoder;
|
||||
CMyComPtr<ICompressCoder> filterCoder = filterCoderSpec;
|
||||
filterCoderSpec->Filter = filter;
|
||||
*coder = filterCoder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CCoderLibrary::LoadAndCreateCoderSpec(LPCTSTR filePath, REFGUID clsID, ICompressCoder **coder)
|
||||
{
|
||||
CCoderLibrary libTemp;
|
||||
if (!libTemp.Load(filePath))
|
||||
return GetLastError();
|
||||
RINOK(libTemp.CreateCoderSpec(clsID, coder));
|
||||
Attach(libTemp.Detach());
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
// CoderLoader.h
|
||||
|
||||
#ifndef __CODERLOADER_H
|
||||
#define __CODERLOADER_H
|
||||
|
||||
#include "../../../Common/String.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../../Windows/DLL.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
typedef UInt32 (WINAPI * CreateObjectPointer)(
|
||||
const GUID *clsID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject);
|
||||
|
||||
class CCoderLibrary: public NWindows::NDLL::CLibrary
|
||||
{
|
||||
public:
|
||||
HRESULT CreateObject(REFGUID clsID, REFGUID iid, void **obj)
|
||||
{
|
||||
CreateObjectPointer createObject = (CreateObjectPointer)
|
||||
GetProcAddress("CreateObject");
|
||||
if (createObject == NULL)
|
||||
return GetLastError();
|
||||
return createObject(&clsID, &iid, obj);
|
||||
}
|
||||
|
||||
HRESULT CreateFilter(REFGUID clsID, ICompressFilter **filter)
|
||||
{
|
||||
return CreateObject(clsID, IID_ICompressFilter, (void **)filter);
|
||||
}
|
||||
|
||||
HRESULT CreateCoder(REFGUID clsID, ICompressCoder **coder)
|
||||
{
|
||||
return CreateObject(clsID, IID_ICompressCoder, (void **)coder);
|
||||
}
|
||||
|
||||
HRESULT CreateCoderSpec(REFGUID clsID, ICompressCoder **coder);
|
||||
|
||||
HRESULT LoadAndCreateFilter(LPCTSTR filePath, REFGUID clsID, ICompressFilter **filter)
|
||||
{
|
||||
CCoderLibrary libTemp;
|
||||
if (!libTemp.Load(filePath))
|
||||
return GetLastError();
|
||||
RINOK(libTemp.CreateFilter(clsID, filter));
|
||||
Attach(libTemp.Detach());
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT LoadAndCreateCoder(LPCTSTR filePath, REFGUID clsID, ICompressCoder **coder)
|
||||
{
|
||||
CCoderLibrary libTemp;
|
||||
if (!libTemp.Load(filePath))
|
||||
return GetLastError();
|
||||
RINOK(libTemp.CreateCoder(clsID, coder));
|
||||
Attach(libTemp.Detach());
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT LoadAndCreateCoderSpec(LPCTSTR filePath, REFGUID clsID, ICompressCoder **coder);
|
||||
HRESULT CreateCoder2(REFGUID clsID, ICompressCoder2 **coder)
|
||||
{
|
||||
CreateObjectPointer createObject = (CreateObjectPointer)
|
||||
GetProcAddress("CreateObject");
|
||||
if (createObject == NULL)
|
||||
return GetLastError();
|
||||
return createObject(&clsID, &IID_ICompressCoder2, (void **)coder);
|
||||
}
|
||||
HRESULT LoadAndCreateCoder2(LPCTSTR filePath, REFGUID clsID, ICompressCoder2 **coder)
|
||||
{
|
||||
CCoderLibrary libTemp;
|
||||
if (!libTemp.Load(filePath))
|
||||
return GetLastError();
|
||||
RINOK(libTemp.CreateCoder2(clsID, coder));
|
||||
Attach(libTemp.Detach());
|
||||
return S_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CCoderLibraries
|
||||
{
|
||||
struct CPathToLibraryPair
|
||||
{
|
||||
CSysString Path;
|
||||
CCoderLibrary Libary;
|
||||
};
|
||||
CObjectVector<CPathToLibraryPair> Pairs;
|
||||
public:
|
||||
int FindPath(LPCTSTR filePath)
|
||||
{
|
||||
for (int i = 0; i < Pairs.Size(); i++)
|
||||
if (Pairs[i].Path.CompareNoCase(filePath) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
HRESULT CreateCoder(LPCTSTR filePath, REFGUID clsID, ICompressCoder **coder)
|
||||
{
|
||||
int index = FindPath(filePath);
|
||||
if (index < 0)
|
||||
{
|
||||
CPathToLibraryPair pair;
|
||||
RINOK(pair.Libary.LoadAndCreateCoder(filePath, clsID, coder));
|
||||
pair.Path = filePath;
|
||||
Pairs.Add(pair);
|
||||
pair.Libary.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
return Pairs[index].Libary.CreateCoder(clsID, coder);
|
||||
}
|
||||
|
||||
HRESULT CreateCoderSpec(LPCTSTR filePath, REFGUID clsID, ICompressCoder **coder)
|
||||
{
|
||||
int index = FindPath(filePath);
|
||||
if (index < 0)
|
||||
{
|
||||
CPathToLibraryPair pair;
|
||||
RINOK(pair.Libary.LoadAndCreateCoderSpec(filePath, clsID, coder));
|
||||
pair.Path = filePath;
|
||||
Pairs.Add(pair);
|
||||
pair.Libary.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
return Pairs[index].Libary.CreateCoderSpec(clsID, coder);
|
||||
}
|
||||
|
||||
HRESULT CreateCoder2(LPCTSTR filePath, REFGUID clsID, ICompressCoder2 **coder)
|
||||
{
|
||||
int index = FindPath(filePath);
|
||||
if (index < 0)
|
||||
{
|
||||
CPathToLibraryPair pair;
|
||||
RINOK(pair.Libary.LoadAndCreateCoder2(filePath, clsID, coder));
|
||||
pair.Path = filePath;
|
||||
Pairs.Add(pair);
|
||||
pair.Libary.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
return Pairs[index].Libary.CreateCoder2(clsID, coder);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -227,8 +227,10 @@ void CCoderMixer2MT::ReInit()
|
||||
STDMETHODIMP CCoderMixer2MT::Init(ISequentialInStream **inStreams,
|
||||
ISequentialOutStream **outStreams)
|
||||
{
|
||||
/*
|
||||
if (_coderInfoVector.Size() != _bindInfo.Coders.Size())
|
||||
throw 0;
|
||||
*/
|
||||
int i;
|
||||
for(i = 0; i < _coderInfoVector.Size(); i++)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ STDMETHODIMP CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *p
|
||||
_size += realProcessedSize;
|
||||
if (size > 0 && realProcessedSize == 0)
|
||||
_wasFinished = true;
|
||||
_crc.Update(data, realProcessedSize);
|
||||
_crc = CrcUpdate(_crc, data, realProcessedSize);
|
||||
if(processedSize != NULL)
|
||||
*processedSize = realProcessedSize;
|
||||
return result;
|
||||
@@ -24,18 +24,17 @@ STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSi
|
||||
if (size > 0 && realProcessedSize == 0)
|
||||
_wasFinished = true;
|
||||
_size += realProcessedSize;
|
||||
_crc.Update(data, realProcessedSize);
|
||||
_crc = CrcUpdate(_crc, data, realProcessedSize);
|
||||
if(processedSize != NULL)
|
||||
*processedSize = realProcessedSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset,
|
||||
UInt32 seekOrigin, UInt64 *newPosition)
|
||||
STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
||||
{
|
||||
if (seekOrigin != STREAM_SEEK_SET || offset != 0)
|
||||
return E_FAIL;
|
||||
_size = 0;
|
||||
_crc.Init();
|
||||
_crc = CRC_INIT_VAL;
|
||||
return _stream->Seek(offset, seekOrigin, newPosition);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
#ifndef __INSTREAMWITHCRC_H
|
||||
#define __INSTREAMWITHCRC_H
|
||||
|
||||
#include "../../../Common/CRC.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../IStream.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/7zCrc.h"
|
||||
}
|
||||
|
||||
class CSequentialInStreamWithCRC:
|
||||
public ISequentialInStream,
|
||||
public CMyUnknownImp
|
||||
@@ -18,7 +22,7 @@ public:
|
||||
private:
|
||||
CMyComPtr<ISequentialInStream> _stream;
|
||||
UInt64 _size;
|
||||
CCRC _crc;
|
||||
UInt32 _crc;
|
||||
bool _wasFinished;
|
||||
public:
|
||||
void SetStream(ISequentialInStream *stream) { _stream = stream; }
|
||||
@@ -26,10 +30,10 @@ public:
|
||||
{
|
||||
_size = 0;
|
||||
_wasFinished = false;
|
||||
_crc.Init();
|
||||
_crc = CRC_INIT_VAL;
|
||||
}
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
UInt32 GetCRC() const { return _crc.GetDigest(); }
|
||||
UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
|
||||
UInt64 GetSize() const { return _size; }
|
||||
bool WasFinished() const { return _wasFinished; }
|
||||
};
|
||||
@@ -46,7 +50,7 @@ public:
|
||||
private:
|
||||
CMyComPtr<IInStream> _stream;
|
||||
UInt64 _size;
|
||||
CCRC _crc;
|
||||
UInt32 _crc;
|
||||
bool _wasFinished;
|
||||
public:
|
||||
void SetStream(IInStream *stream) { _stream = stream; }
|
||||
@@ -54,10 +58,10 @@ public:
|
||||
{
|
||||
_size = 0;
|
||||
_wasFinished = false;
|
||||
_crc.Init();
|
||||
_crc = CRC_INIT_VAL;
|
||||
}
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
UInt32 GetCRC() const { return _crc.GetDigest(); }
|
||||
UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
|
||||
UInt64 GetSize() const { return _size; }
|
||||
bool WasFinished() const { return _wasFinished; }
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *pr
|
||||
else
|
||||
result = _stream->Write(data, size, &realProcessedSize);
|
||||
if (_calculateCrc)
|
||||
_crc.Update(data, realProcessedSize);
|
||||
_crc = CrcUpdate(_crc, data, realProcessedSize);
|
||||
_size += realProcessedSize;
|
||||
if(processedSize != NULL)
|
||||
*processedSize = realProcessedSize;
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
#ifndef __OUTSTREAMWITHCRC_H
|
||||
#define __OUTSTREAMWITHCRC_H
|
||||
|
||||
#include "../../../Common/CRC.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../IStream.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/7zCrc.h"
|
||||
}
|
||||
|
||||
class COutStreamWithCRC:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
@@ -18,7 +22,7 @@ public:
|
||||
private:
|
||||
CMyComPtr<ISequentialOutStream> _stream;
|
||||
UInt64 _size;
|
||||
CCRC _crc;
|
||||
UInt32 _crc;
|
||||
bool _calculateCrc;
|
||||
public:
|
||||
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
|
||||
@@ -26,12 +30,12 @@ public:
|
||||
{
|
||||
_size = 0;
|
||||
_calculateCrc = calculateCrc;
|
||||
_crc.Init();
|
||||
_crc = CRC_INIT_VAL;
|
||||
}
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
UInt64 GetSize() const { return _size; }
|
||||
UInt32 GetCRC() const { return _crc.GetDigest(); }
|
||||
void InitCRC() { _crc.Init(); }
|
||||
UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
|
||||
void InitCRC() { _crc = CRC_INIT_VAL; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user