4.46 beta

This commit is contained in:
Igor Pavlov
2007-05-25 00:00:00 +00:00
committed by Kornel Lesiński
parent a145bfc7cf
commit c574fc0f4b
191 changed files with 1318 additions and 854 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/* 7zCrc.c */ /* 7zCrcT8.c */
#include "7zCrc.h" #include "7zCrc.h"
+2 -2
View File
@@ -1,4 +1,4 @@
// Common/Alloc.c /* Alloc.c */
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
@@ -7,7 +7,7 @@
#include "Alloc.h" #include "Alloc.h"
// #define _SZ_ALLOC_DEBUG /* #define _SZ_ALLOC_DEBUG */
/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
#ifdef _SZ_ALLOC_DEBUG #ifdef _SZ_ALLOC_DEBUG
+1 -1
View File
@@ -1,4 +1,4 @@
// Common/Alloc.h /* Alloc.h */
#ifndef __COMMON_ALLOC_H #ifndef __COMMON_ALLOC_H
#define __COMMON_ALLOC_H #define __COMMON_ALLOC_H
+8 -6
View File
@@ -46,10 +46,12 @@ void ConvertNumberToString(CFileSize value, char *s)
#ifdef USE_WINDOWS_FUNCTIONS #ifdef USE_WINDOWS_FUNCTIONS
// ReadFile and WriteFile functions in Windows have BUG: /*
// If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1) ReadFile and WriteFile functions in Windows have BUG:
// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
// (Insufficient system resources exist to complete the requested service). from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
(Insufficient system resources exist to complete the requested service).
*/
#define kChunkSizeMax (1 << 24) #define kChunkSizeMax (1 << 24)
#endif #endif
@@ -161,7 +163,7 @@ SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
value.LowPart = (DWORD)pos; value.LowPart = (DWORD)pos;
value.HighPart = (LONG)((UInt64)pos >> 32); value.HighPart = (LONG)((UInt64)pos >> 32);
#ifdef _SZ_FILE_SIZE_32 #ifdef _SZ_FILE_SIZE_32
// VC 6.0 has bug with >> 32 shifts. /* VC 6.0 has bug with >> 32 shifts. */
value.HighPart = 0; value.HighPart = 0;
#endif #endif
value.LowPart = SetFilePointer(s->File, value.LowPart, &value.HighPart, FILE_BEGIN); value.LowPart = SetFilePointer(s->File, value.LowPart, &value.HighPart, FILE_BEGIN);
@@ -354,7 +356,7 @@ int main(int numargs, char *args[])
printf("\nEverything is Ok\n"); printf("\nEverything is Ok\n");
return 0; return 0;
} }
if (res == SZE_OUTOFMEMORY) if (res == (SZ_RESULT)SZE_OUTOFMEMORY)
PrintError("can not allocate memory"); PrintError("can not allocate memory");
else else
printf("\nERROR #%d\n", res); printf("\nERROR #%d\n", res);
+1 -1
View File
@@ -1,4 +1,4 @@
// BranchARM.h /* BranchARM.h */
#ifndef __BRANCH_ARM_H #ifndef __BRANCH_ARM_H
#define __BRANCH_ARM_H #define __BRANCH_ARM_H
+1 -1
View File
@@ -1,4 +1,4 @@
// BranchARMThumb.h /* BranchARMThumb.h */
#ifndef __BRANCH_ARM_THUMB_H #ifndef __BRANCH_ARM_THUMB_H
#define __BRANCH_ARM_THUMB_H #define __BRANCH_ARM_THUMB_H
+1 -1
View File
@@ -1,4 +1,4 @@
// BranchIA64.h /* BranchIA64.h */
#ifndef __BRANCH_IA64_H #ifndef __BRANCH_IA64_H
#define __BRANCH_IA64_H #define __BRANCH_IA64_H
+1 -1
View File
@@ -1,4 +1,4 @@
// BranchPPC.h /* BranchPPC.h */
#ifndef __BRANCH_PPC_H #ifndef __BRANCH_PPC_H
#define __BRANCH_PPC_H #define __BRANCH_PPC_H
+1 -1
View File
@@ -1,4 +1,4 @@
// BranchSPARC.h /* BranchSPARC.h */
#ifndef __BRANCH_SPARC_H #ifndef __BRANCH_SPARC_H
#define __BRANCH_SPARC_H #define __BRANCH_SPARC_H
+4 -4
View File
@@ -1,4 +1,4 @@
// Compression/HuffmanEncode.c /* Compress/HuffmanEncode.c */
#include "HuffmanEncode.h" #include "HuffmanEncode.h"
#include "../../Sort.h" #include "../../Sort.h"
@@ -9,13 +9,13 @@
#define NUM_COUNTERS 64 #define NUM_COUNTERS 64
// use BLOCK_SORT_EXTERNAL_FLAGS if blockSize > 1M /* use BLOCK_SORT_EXTERNAL_FLAGS if blockSize > 1M */
#define HUFFMAN_SPEED_OPT #define HUFFMAN_SPEED_OPT
void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymbols, UInt32 maxLen) void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymbols, UInt32 maxLen)
{ {
UInt32 num = 0; UInt32 num = 0;
// if (maxLen > 10) maxLen = 10; /* if (maxLen > 10) maxLen = 10; */
{ {
UInt32 i; UInt32 i;
@@ -133,7 +133,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
for (len = 1; len <= kMaxLen; len++) for (len = 1; len <= kMaxLen; len++)
nextCodes[len] = code = (code + lenCounters[len - 1]) << 1; nextCodes[len] = code = (code + lenCounters[len - 1]) << 1;
} }
// if (code + lenCounters[kMaxLen] - 1 != (1 << kMaxLen) - 1) throw 1; /* if (code + lenCounters[kMaxLen] - 1 != (1 << kMaxLen) - 1) throw 1; */
{ {
UInt32 i; UInt32 i;
+1 -1
View File
@@ -1,4 +1,4 @@
// Compress/HuffmanEncode.h /* Compress/HuffmanEncode.h */
#ifndef __COMPRESS_HUFFMANENCODE_H #ifndef __COMPRESS_HUFFMANENCODE_H
#define __COMPRESS_HUFFMANENCODE_H #define __COMPRESS_HUFFMANENCODE_H
+28 -1
View File
@@ -163,7 +163,7 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
sizeReserv = historySize >> 1; sizeReserv = historySize >> 1;
if (historySize > ((UInt32)2 << 30)) if (historySize > ((UInt32)2 << 30))
sizeReserv = historySize >> 2; sizeReserv = historySize >> 2;
sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 12); sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
p->keepSizeBefore = historySize + keepAddBufferBefore + 1; p->keepSizeBefore = historySize + keepAddBufferBefore + 1;
p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
@@ -622,6 +622,19 @@ UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
MOVE_POS_RET MOVE_POS_RET
} }
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
{
UInt32 offset;
GET_MATCHES_HEADER(3)
HASH_ZIP_CALC;
curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos;
offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, p->pos, p->buffer, p->son,
p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
distances, 2) - (distances));
MOVE_POS_RET
}
void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
{ {
do do
@@ -696,6 +709,20 @@ void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
while (--num != 0); while (--num != 0);
} }
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
{
do
{
SKIP_HEADER(3)
HASH_ZIP_CALC;
curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos;
p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS
}
while (--num != 0);
}
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
{ {
vTable->Init = (Mf_Init_Func)MatchFinder_Init; vTable->Init = (Mf_Init_Func)MatchFinder_Init;
+2
View File
@@ -98,6 +98,8 @@ void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
void MatchFinder_Init(CMatchFinder *p); void MatchFinder_Init(CMatchFinder *p);
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
#endif #endif
+19 -1
View File
@@ -1,6 +1,17 @@
/* MatchFinderMt.c */ /* MatchFinderMt.c */
#ifdef _WIN32
#define USE_ALLOCA
#endif
#ifdef USE_ALLOCA
#ifdef _WIN32
#include <malloc.h> #include <malloc.h>
#else
#include <stdlib.h>
#endif
#endif
#include "../../7zCrc.h" #include "../../7zCrc.h"
#include "LzHash.h" #include "LzHash.h"
@@ -460,7 +471,14 @@ void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc)
#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks) #define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)
static unsigned StdCall HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; } static unsigned StdCall HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
static unsigned StdCall BtThreadFunc2(void *p) { alloca(0x180); BtThreadFunc((CMatchFinderMt *)p); return 0; } static unsigned StdCall BtThreadFunc2(void *p)
{
#ifdef USE_ALLOCA
alloca(0x180);
#endif
BtThreadFunc((CMatchFinderMt *)p);
return 0;
}
HRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, HRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc) UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc)
+2 -2
View File
@@ -71,9 +71,9 @@ typedef struct _CMatchFinderMt
UInt32 matchMaxLen; UInt32 matchMaxLen;
UInt32 numHashBytes; UInt32 numHashBytes;
UInt32 pos; UInt32 pos;
Byte *buffer; // Pointer to virtual Buffer begin Byte *buffer; /* Pointer to virtual Buffer begin */
UInt32 cyclicBufferPos; UInt32 cyclicBufferPos;
UInt32 cyclicBufferSize; // it must be historySize + 1 UInt32 cyclicBufferSize; /* it must be historySize + 1 */
UInt32 cutValue; UInt32 cutValue;
/* BT + Hash */ /* BT + Hash */
+1 -1
View File
@@ -1,4 +1,4 @@
// IStream.h /* IStream.h */
#ifndef __C_ISTREAM_H #ifndef __C_ISTREAM_H
#define __C_ISTREAM_H #define __C_ISTREAM_H
+18 -9
View File
@@ -21,12 +21,12 @@ HRes MyCloseHandle(HANDLE *h)
return SZ_OK; return SZ_OK;
} }
HRes Thread_Create(CThread *thread, unsigned (StdCall *startAddress)(void *), LPVOID parameter) HRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
{ {
/* DWORD threadId; */ unsigned threadId; /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */
thread->handle = thread->handle =
/* CreateThread(0, 0, startAddress, parameter, 0, &threadId); */ /* CreateThread(0, 0, startAddress, parameter, 0, &threadId); */
(HANDLE)_beginthreadex(NULL, 0, startAddress, parameter, 0, NULL); (HANDLE)_beginthreadex(NULL, 0, startAddress, parameter, 0, &threadId);
/* maybe we must use errno here, but probably GetLastError() is also OK. */ /* maybe we must use errno here, but probably GetLastError() is also OK. */
return BoolToHRes(thread->handle != 0); return BoolToHRes(thread->handle != 0);
} }
@@ -48,13 +48,22 @@ HRes Thread_Close(CThread *thread)
return MyCloseHandle(&thread->handle); return MyCloseHandle(&thread->handle);
} }
HRes AutoResetEvent_Create(CAutoResetEvent *p, int initialSignaled) HRes Event_Create(CEvent *p, BOOL manualReset, int initialSignaled)
{ {
p->handle = CreateEvent(NULL, FALSE, (initialSignaled ? TRUE : FALSE), NULL); p->handle = CreateEvent(NULL, manualReset, (initialSignaled ? TRUE : FALSE), NULL);
return BoolToHRes(p->handle != 0); return BoolToHRes(p->handle != 0);
} }
HRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) { return AutoResetEvent_Create(p, 0); } HRes ManualResetEvent_Create(CManualResetEvent *p, int initialSignaled)
{ return Event_Create(p, TRUE, initialSignaled); }
HRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p)
{ return ManualResetEvent_Create(p, 0); }
HRes AutoResetEvent_Create(CAutoResetEvent *p, int initialSignaled)
{ return Event_Create(p, FALSE, initialSignaled); }
HRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p)
{ return AutoResetEvent_Create(p, 0); }
HRes Event_Set(CEvent *p) { return BOOLToHRes(SetEvent(p->handle)); } HRes Event_Set(CEvent *p) { return BOOLToHRes(SetEvent(p->handle)); }
HRes Event_Reset(CEvent *p) { return BOOLToHRes(ResetEvent(p->handle)); } HRes Event_Reset(CEvent *p) { return BOOLToHRes(ResetEvent(p->handle)); }
HRes Event_Wait(CEvent *p) { return WaitObject(p->handle); } HRes Event_Wait(CEvent *p) { return WaitObject(p->handle); }
@@ -71,9 +80,9 @@ HRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount)
{ {
return BOOLToHRes(ReleaseSemaphore(p->handle, releaseCount, previousCount)); return BOOLToHRes(ReleaseSemaphore(p->handle, releaseCount, previousCount));
} }
HRes Semaphore_ReleaseN(CSemaphore *p, LONG releaseCount) HRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount)
{ {
return Semaphore_Release(p, releaseCount, NULL); return Semaphore_Release(p, (LONG)releaseCount, NULL);
} }
HRes Semaphore_Release1(CSemaphore *p) HRes Semaphore_Release1(CSemaphore *p)
{ {
@@ -89,7 +98,7 @@ HRes CriticalSection_Init(CCriticalSection *p)
__try __try
{ {
InitializeCriticalSection(p); InitializeCriticalSection(p);
// InitializeCriticalSectionAndSpinCount(p, 0); /* InitializeCriticalSectionAndSpinCount(p, 0); */
} }
__except (EXCEPTION_EXECUTE_HANDLER) { return SZE_OUTOFMEMORY; } __except (EXCEPTION_EXECUTE_HANDLER) { return SZE_OUTOFMEMORY; }
return SZ_OK; return SZ_OK;
+11 -2
View File
@@ -1,4 +1,4 @@
/* Thresds.h */ /* Threads.h */
#ifndef __7Z_THRESDS_H #ifndef __7Z_THRESDS_H
#define __7Z_THRESDS_H #define __7Z_THRESDS_H
@@ -15,7 +15,11 @@ typedef struct _CThread
#define Thread_Construct(thread) (thread)->handle = NULL #define Thread_Construct(thread) (thread)->handle = NULL
#define Thread_WasCreated(thread) ((thread)->handle != NULL) #define Thread_WasCreated(thread) ((thread)->handle != NULL)
HRes Thread_Create(CThread *thread, unsigned (StdCall *startAddress)(void *), LPVOID parameter); typedef unsigned THREAD_FUNC_RET_TYPE;
#define THREAD_FUNC_CALL_TYPE StdCall
#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE
HRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter);
HRes Thread_Wait(CThread *thread); HRes Thread_Wait(CThread *thread);
HRes Thread_Close(CThread *thread); HRes Thread_Close(CThread *thread);
@@ -25,9 +29,13 @@ typedef struct _CEvent
} CEvent; } CEvent;
typedef CEvent CAutoResetEvent; typedef CEvent CAutoResetEvent;
typedef CEvent CManualResetEvent;
#define Event_Construct(event) (event)->handle = NULL #define Event_Construct(event) (event)->handle = NULL
#define Event_IsCreated(event) ((event)->handle != NULL)
HRes ManualResetEvent_Create(CManualResetEvent *event, int initialSignaled);
HRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *event);
HRes AutoResetEvent_Create(CAutoResetEvent *event, int initialSignaled); HRes AutoResetEvent_Create(CAutoResetEvent *event, int initialSignaled);
HRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *event); HRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *event);
HRes Event_Set(CEvent *event); HRes Event_Set(CEvent *event);
@@ -44,6 +52,7 @@ typedef struct _CSemaphore
#define Semaphore_Construct(p) (p)->handle = NULL #define Semaphore_Construct(p) (p)->handle = NULL
HRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount); HRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount);
HRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num);
HRes Semaphore_Release1(CSemaphore *p); HRes Semaphore_Release1(CSemaphore *p);
HRes Semaphore_Wait(CSemaphore *p); HRes Semaphore_Wait(CSemaphore *p);
HRes Semaphore_Close(CSemaphore *p); HRes Semaphore_Close(CSemaphore *p);
+1 -1
View File
@@ -7,7 +7,7 @@
#include "../../../Windows/PropVariant.h" #include "../../../Windows/PropVariant.h"
#include "../../Common/MethodID.h" #include "../../Common/MethodId.h"
namespace NArchive { namespace NArchive {
namespace N7z { namespace N7z {
+1 -1
View File
@@ -157,7 +157,7 @@ HRESULT CDecoder::Decode(
_mixerCoderCommon = _mixerCoderSTSpec; _mixerCoderCommon = _mixerCoderSTSpec;
#endif #endif
} }
_mixerCoderCommon->SetBindInfo(bindInfo); RINOK(_mixerCoderCommon->SetBindInfo(bindInfo));
for (i = 0; i < numCoders; i++) for (i = 0; i < numCoders; i++)
{ {
+1 -1
View File
@@ -56,7 +56,7 @@ HRESULT CEncoder::CreateMixerCoder(
{ {
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT; _mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
_mixerCoder = _mixerCoderSpec; _mixerCoder = _mixerCoderSpec;
_mixerCoderSpec->SetBindInfo(_bindInfo); RINOK(_mixerCoderSpec->SetBindInfo(_bindInfo));
for (int i = 0; i < _options.Methods.Size(); i++) for (int i = 0; i < _options.Methods.Size(); i++)
{ {
const CMethodFull &methodFull = _options.Methods[i]; const CMethodFull &methodFull = _options.Methods[i];
+4 -2
View File
@@ -143,10 +143,12 @@ static inline UString GetHex2(Byte value)
static const UInt64 k_AES = 0x06F10701; static const UInt64 k_AES = 0x06F10701;
#ifndef _SFX
static inline UInt32 GetUInt32FromMemLE(const Byte *p) static inline UInt32 GetUInt32FromMemLE(const Byte *p)
{ {
return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24); return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
} }
#endif
bool CHandler::IsEncrypted(UInt32 index2) const bool CHandler::IsEncrypted(UInt32 index2) const
{ {
@@ -393,11 +395,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
COM_TRY_END COM_TRY_END
} }
#ifdef _7Z_VOL
static const wchar_t *kExt = L"7z"; static const wchar_t *kExt = L"7z";
static const wchar_t *kAfterPart = L".7z"; static const wchar_t *kAfterPart = L".7z";
#ifdef _7Z_VOL
class CVolumeName class CVolumeName
{ {
bool _first; bool _first;
+1 -2
View File
@@ -85,8 +85,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_QUERYINTERFACE_BEGIN MY_QUERYINTERFACE_BEGIN2(IInArchive)
MY_QUERYINTERFACE_ENTRY(IInArchive)
#ifdef _7Z_VOL #ifdef _7Z_VOL
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream) MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
#endif #endif
+7
View File
@@ -54,6 +54,9 @@ static const UInt32 kPpmdOrderX5 = 6;
static const UInt32 kPpmdOrderX7 = 16; static const UInt32 kPpmdOrderX7 = 16;
static const UInt32 kPpmdOrderX9 = 32; static const UInt32 kPpmdOrderX9 = 32;
static const UInt32 kDeflateAlgoX1 = 0;
static const UInt32 kDeflateAlgoX5 = 1;
static const UInt32 kDeflateFastBytesX1 = 32; static const UInt32 kDeflateFastBytesX1 = 32;
static const UInt32 kDeflateFastBytesX7 = 64; static const UInt32 kDeflateFastBytesX7 = 64;
static const UInt32 kDeflateFastBytesX9 = 128; static const UInt32 kDeflateFastBytesX9 = 128;
@@ -323,7 +326,11 @@ HRESULT CHandler::SetCompressionMethod(
(level >= 9 ? kDeflatePassesX9 : (level >= 9 ? kDeflatePassesX9 :
(level >= 7 ? kDeflatePassesX7 : (level >= 7 ? kDeflatePassesX7 :
kDeflatePassesX1)); kDeflatePassesX1));
UInt32 algo =
(level >= 5 ? kDeflateAlgoX5 :
kDeflateAlgoX1);
SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo);
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes); SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses); SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
} }
+1 -1
View File
@@ -1238,7 +1238,7 @@ HRESULT CInArchive::ReadDatabase(
UInt64 nextHeaderSize; UInt64 nextHeaderSize;
UInt32 nextHeaderCRC; UInt32 nextHeaderCRC;
UInt32 crc = CRC_INIT_VAL; UInt32 crc = CRC_INIT_VAL;
UInt32 temp; UInt32 temp = 0;
RINOK(SafeReadDirectUInt32(crcFromArchive, temp)); RINOK(SafeReadDirectUInt32(crcFromArchive, temp));
RINOK(SafeReadDirectUInt64(nextHeaderOffset, crc)); RINOK(SafeReadDirectUInt64(nextHeaderOffset, crc));
RINOK(SafeReadDirectUInt64(nextHeaderSize, crc)); RINOK(SafeReadDirectUInt64(nextHeaderSize, crc));
+1 -1
View File
@@ -5,7 +5,7 @@
#include "../../../Common/Buffer.h" #include "../../../Common/Buffer.h"
#include "../../../Common/String.h" #include "../../../Common/String.h"
#include "../../Common/MethodID.h" #include "../../Common/MethodId.h"
#include "7zHeader.h" #include "7zHeader.h"
namespace NArchive { namespace NArchive {
+2 -2
View File
@@ -8,13 +8,13 @@
namespace NArchive { namespace NArchive {
namespace N7z { namespace N7z {
enum // PropID enum
{ {
kpidPackedSize0 = kpidUserDefined, kpidPackedSize0 = kpidUserDefined,
kpidPackedSize1, kpidPackedSize1,
kpidPackedSize2, kpidPackedSize2,
kpidPackedSize3, kpidPackedSize3,
kpidPackedSize4, kpidPackedSize4
}; };
}} }}
+2 -1
View File
@@ -350,7 +350,6 @@ static bool IsExeFile(const UString &ext)
return false; return false;
} }
static const UInt64 k_Copy = 0x0;
static const UInt64 k_LZMA = 0x030101; static const UInt64 k_LZMA = 0x030101;
static const UInt64 k_BCJ = 0x03030103; static const UInt64 k_BCJ = 0x03030103;
static const UInt64 k_BCJ2 = 0x0303011B; static const UInt64 k_BCJ2 = 0x0303011B;
@@ -843,6 +842,8 @@ static HRESULT Update2(
#ifdef _7Z_VOL #ifdef _7Z_VOL
static const UInt64 k_Copy = 0x0;
static HRESULT WriteVolumeHeader(COutArchive &archive, CFileItem &file, const CUpdateOptions &options) static HRESULT WriteVolumeHeader(COutArchive &archive, CFileItem &file, const CUpdateOptions &options)
{ {
CCoderInfo coder; CCoderInfo coder;
+1 -1
View File
@@ -35,7 +35,7 @@ struct CUpdateItem
bool IsLastAccessTimeDefined; bool IsLastAccessTimeDefined;
bool AttributesAreDefined; bool AttributesAreDefined;
const bool HasStream() const bool HasStream() const
{ return !IsDirectory && !IsAnti && Size != 0; } { return !IsDirectory && !IsAnti && Size != 0; }
CUpdateItem(): CUpdateItem():
IsAnti(false), IsAnti(false),
+1 -1
View File
@@ -15,7 +15,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *inStream, STDMETHOD(Open)(IInStream *inStream,
const UInt64 *maxCheckStartPosition, const UInt64 *maxCheckStartPosition,
+2 -2
View File
@@ -51,7 +51,7 @@ namespace NFileHeader
kCompressed1c = 3, kCompressed1c = 3,
kCompressed2 = 4, kCompressed2 = 4,
kNoDataNoCRC = 8, kNoDataNoCRC = 8,
kNoData = 9, kNoData = 9
}; };
} }
namespace NFileType namespace NFileType
@@ -62,7 +62,7 @@ namespace NFileHeader
k7BitText = 1, k7BitText = 1,
kDirectory = 3, kDirectory = 3,
kVolumeLablel = 4, kVolumeLablel = 4,
kChapterLabel = 5, kChapterLabel = 5
}; };
} }
namespace NFlags namespace NFlags
+1 -2
View File
@@ -46,8 +46,7 @@ class CHandler:
} }
public: public:
MY_QUERYINTERFACE_BEGIN MY_QUERYINTERFACE_BEGIN2(IInArchive)
MY_QUERYINTERFACE_ENTRY(IInArchive)
MY_QUERYINTERFACE_ENTRY(IOutArchive) MY_QUERYINTERFACE_ENTRY(IOutArchive)
MY_QUERYINTERFACE_ENTRY(ISetProperties) MY_QUERYINTERFACE_ENTRY(ISetProperties)
QUERY_ENTRY_ISetCompressCodecsInfo QUERY_ENTRY_ISetCompressCodecsInfo
-2
View File
@@ -54,8 +54,6 @@ STATPROPSTG kProperties[] =
#endif #endif
}; };
static const int kNumProperties = sizeof(kProperties) / sizeof(kProperties[0]);
static const wchar_t *kMethods[] = static const wchar_t *kMethods[] =
{ {
L"None", L"None",
+1 -1
View File
@@ -15,7 +15,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream, STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition, const UInt64 *maxCheckStartPosition,
+1 -1
View File
@@ -18,7 +18,7 @@ public:
{ {
kUnexpectedEndOfArchive = 0, kUnexpectedEndOfArchive = 0,
kIncorrectArchive, kIncorrectArchive,
kUnsupported, kUnsupported
} Cause; } Cause;
CInArchiveException(CCauseType cause) : Cause(cause) {} CInArchiveException(CCauseType cause) : Cause(cause) {}
}; };
-2
View File
@@ -55,8 +55,6 @@ STATPROPSTG kProperties[] =
#endif #endif
}; };
static const int kNumProperties = sizeof(kProperties) / sizeof(kProperties[0]);
STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value) STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value)
{ {
value->vt = VT_EMPTY; value->vt = VT_EMPTY;
+1 -1
View File
@@ -15,7 +15,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream, STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition, const UInt64 *maxCheckStartPosition,
+1 -1
View File
@@ -158,7 +158,7 @@ struct CCoderInfo
class CCoderMixer2 class CCoderMixer2
{ {
public: public:
virtual void SetBindInfo(const CBindInfo &bindInfo) = 0; virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) = 0;
virtual void ReInit() = 0; virtual void ReInit() = 0;
virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0; virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0;
}; };
+20 -32
View File
@@ -12,8 +12,6 @@ namespace NCoderMixer2 {
CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams): CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams):
ExitEvent(NULL), ExitEvent(NULL),
CompressEvent(NULL),
CompressionCompletedEvent(NULL),
CCoderInfo(numInStreams, numOutStreams) CCoderInfo(numInStreams, numOutStreams)
{ {
InStreams.Reserve(NumInStreams); InStreams.Reserve(NumInStreams);
@@ -22,20 +20,6 @@ CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams):
OutStreamPointers.Reserve(NumOutStreams); OutStreamPointers.Reserve(NumOutStreams);
} }
void CThreadCoderInfo::CreateEvents()
{
CompressEvent = new CAutoResetEvent(false);
CompressionCompletedEvent = new CAutoResetEvent(false);
}
CThreadCoderInfo::~CThreadCoderInfo()
{
if (CompressEvent != NULL)
delete CompressEvent;
if (CompressionCompletedEvent != NULL)
delete CompressionCompletedEvent;
}
class CCoderInfoFlusher2 class CCoderInfoFlusher2
{ {
CThreadCoderInfo *m_CoderInfo; CThreadCoderInfo *m_CoderInfo;
@@ -48,13 +32,13 @@ public:
m_CoderInfo->InStreams[i].Release(); m_CoderInfo->InStreams[i].Release();
for (i = 0; i < m_CoderInfo->OutStreams.Size(); i++) for (i = 0; i < m_CoderInfo->OutStreams.Size(); i++)
m_CoderInfo->OutStreams[i].Release(); m_CoderInfo->OutStreams[i].Release();
m_CoderInfo->CompressionCompletedEvent->Set(); m_CoderInfo->CompressionCompletedEvent.Set();
} }
}; };
bool CThreadCoderInfo::WaitAndCode() bool CThreadCoderInfo::WaitAndCode()
{ {
HANDLE events[2] = { ExitEvent, *CompressEvent }; HANDLE events[2] = { ExitEvent, CompressEvent };
DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE); DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
if (waitResult == WAIT_OBJECT_0 + 0) if (waitResult == WAIT_OBJECT_0 + 0)
return false; return false;
@@ -123,7 +107,7 @@ void CThreadCoderInfo::SetCoderInfo(const UInt64 **inSizes,
SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams); SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
} }
static DWORD WINAPI CoderThread(void *threadCoderInfo) static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
{ {
for (;;) for (;;)
{ {
@@ -135,7 +119,7 @@ static DWORD WINAPI CoderThread(void *threadCoderInfo)
////////////////////////////////////// //////////////////////////////////////
// CCoderMixer2MT // CCoderMixer2MT
static DWORD WINAPI MainCoderThread(void *threadCoderInfo) static THREAD_FUNC_DECL MainCoderThread(void *threadCoderInfo)
{ {
for (;;) for (;;)
{ {
@@ -146,7 +130,9 @@ static DWORD WINAPI MainCoderThread(void *threadCoderInfo)
CCoderMixer2MT::CCoderMixer2MT() CCoderMixer2MT::CCoderMixer2MT()
{ {
if (!_mainThread.Create(MainCoderThread, this)) if (CreateEvents() != S_OK)
throw 271824;
if (_mainThread.Create(MainCoderThread, this) != S_OK)
throw 271825; throw 271825;
} }
@@ -161,15 +147,16 @@ CCoderMixer2MT::~CCoderMixer2MT()
} }
} }
void CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo) HRESULT CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
{ {
_bindInfo = bindInfo; _bindInfo = bindInfo;
_streamBinders.Clear(); _streamBinders.Clear();
for(int i = 0; i < _bindInfo.BindPairs.Size(); i++) for(int i = 0; i < _bindInfo.BindPairs.Size(); i++)
{ {
_streamBinders.Add(CStreamBinder()); _streamBinders.Add(CStreamBinder());
_streamBinders.Back().CreateEvents(); RINOK(_streamBinders.Back().CreateEvents());
} }
return S_OK;
} }
void CCoderMixer2MT::AddCoderCommon() void CCoderMixer2MT::AddCoderCommon()
@@ -180,13 +167,13 @@ void CCoderMixer2MT::AddCoderCommon()
CThreadCoderInfo threadCoderInfo(CoderStreamsInfo.NumInStreams, CThreadCoderInfo threadCoderInfo(CoderStreamsInfo.NumInStreams,
CoderStreamsInfo.NumOutStreams); CoderStreamsInfo.NumOutStreams);
_coderInfoVector.Add(threadCoderInfo); _coderInfoVector.Add(threadCoderInfo);
_coderInfoVector.Back().CreateEvents(); CThreadCoderInfo *tci = &_coderInfoVector.Back();
_coderInfoVector.Back().ExitEvent = _exitEvent; tci->CreateEvents();
_compressingCompletedEvents.Add(*_coderInfoVector.Back().CompressionCompletedEvent); tci->ExitEvent = _exitEvent;
NWindows::CThread newThread; NWindows::CThread newThread;
_threads.Add(newThread); _threads.Add(newThread);
if (!_threads.Back().Create(CoderThread, &_coderInfoVector.Back())) if (_threads.Back().Create(CoderThread, tci) != S_OK)
throw 271824; throw 271824;
} }
@@ -282,13 +269,13 @@ bool CCoderMixer2MT::MyCode()
if (waitResult == WAIT_OBJECT_0 + 0) if (waitResult == WAIT_OBJECT_0 + 0)
return false; return false;
for(int i = 0; i < _coderInfoVector.Size(); i++) int i;
_coderInfoVector[i].CompressEvent->Set(); for(i = 0; i < _coderInfoVector.Size(); i++)
/* DWORD result = */ ::WaitForMultipleObjects(_compressingCompletedEvents.Size(), _coderInfoVector[i].CompressEvent.Set();
&_compressingCompletedEvents.Front(), TRUE, INFINITE); for (i = 0; i < _coderInfoVector.Size(); i++)
_coderInfoVector[i].CompressionCompletedEvent.Lock();
_compressingFinishedEvent.Set(); _compressingFinishedEvent.Set();
return true; return true;
} }
@@ -311,6 +298,7 @@ STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams,
CCrossThreadProgress *progressSpec = new CCrossThreadProgress; CCrossThreadProgress *progressSpec = new CCrossThreadProgress;
CMyComPtr<ICompressProgressInfo> crossProgress = progressSpec; CMyComPtr<ICompressProgressInfo> crossProgress = progressSpec;
RINOK(progressSpec->Create());
progressSpec->Init(); progressSpec->Init();
_coderInfoVector[_progressCoderIndex].Progress = crossProgress; _coderInfoVector[_progressCoderIndex].Progress = crossProgress;
+15 -6
View File
@@ -20,9 +20,9 @@ namespace NCoderMixer2 {
struct CThreadCoderInfo: public CCoderInfo struct CThreadCoderInfo: public CCoderInfo
{ {
NWindows::NSynchronization::CAutoResetEvent *CompressEvent; NWindows::NSynchronization::CAutoResetEvent CompressEvent;
HANDLE ExitEvent; HANDLE ExitEvent;
NWindows::NSynchronization::CAutoResetEvent *CompressionCompletedEvent; NWindows::NSynchronization::CAutoResetEvent CompressionCompletedEvent;
CObjectVector< CMyComPtr<ISequentialInStream> > InStreams; CObjectVector< CMyComPtr<ISequentialInStream> > InStreams;
CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams; CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams;
@@ -35,9 +35,12 @@ struct CThreadCoderInfo: public CCoderInfo
CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams); CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams);
void SetCoderInfo(const UInt64 **inSizes, void SetCoderInfo(const UInt64 **inSizes,
const UInt64 **outSizes, ICompressProgressInfo *progress); const UInt64 **outSizes, ICompressProgressInfo *progress);
~CThreadCoderInfo();
bool WaitAndCode(); bool WaitAndCode();
void CreateEvents(); HRes CreateEvents()
{
RINOK(CompressEvent.CreateIfNotCreated());
return CompressionCompletedEvent.CreateIfNotCreated();
}
}; };
@@ -105,14 +108,20 @@ private:
NWindows::CThread _mainThread; NWindows::CThread _mainThread;
NWindows::NSynchronization::CAutoResetEvent _startCompressingEvent; NWindows::NSynchronization::CAutoResetEvent _startCompressingEvent;
CRecordVector<HANDLE> _compressingCompletedEvents;
NWindows::NSynchronization::CAutoResetEvent _compressingFinishedEvent; NWindows::NSynchronization::CAutoResetEvent _compressingFinishedEvent;
NWindows::NSynchronization::CManualResetEvent _exitEvent; NWindows::NSynchronization::CManualResetEvent _exitEvent;
UInt32 _progressCoderIndex; UInt32 _progressCoderIndex;
HRes CreateEvents()
{
RINOK(_startCompressingEvent.CreateIfNotCreated());
RINOK(_compressingFinishedEvent.CreateIfNotCreated());
return _exitEvent.CreateIfNotCreated();
}
public: public:
void SetBindInfo(const CBindInfo &bindInfo); HRESULT SetBindInfo(const CBindInfo &bindInfo);
}; };
+2 -1
View File
@@ -10,9 +10,10 @@ CCoderMixer2ST::CCoderMixer2ST() {}
CCoderMixer2ST::~CCoderMixer2ST(){ } CCoderMixer2ST::~CCoderMixer2ST(){ }
void CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo) HRESULT CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo)
{ {
_bindInfo = bindInfo; _bindInfo = bindInfo;
return S_OK;
} }
void CCoderMixer2ST::AddCoderCommon(bool isMain) void CCoderMixer2ST::AddCoderCommon(bool isMain)
+1 -1
View File
@@ -79,7 +79,7 @@ private:
CObjectVector<CSTCoderInfo> _coders; CObjectVector<CSTCoderInfo> _coders;
int _mainCoderIndex; int _mainCoderIndex;
public: public:
void SetBindInfo(const CBindInfo &bindInfo); HRESULT SetBindInfo(const CBindInfo &bindInfo);
}; };
@@ -17,6 +17,12 @@ public:
HRESULT Result; HRESULT Result;
NWindows::NSynchronization::CAutoResetEvent ProgressEvent; NWindows::NSynchronization::CAutoResetEvent ProgressEvent;
NWindows::NSynchronization::CAutoResetEvent WaitEvent; NWindows::NSynchronization::CAutoResetEvent WaitEvent;
HRes Create()
{
RINOK(ProgressEvent.CreateIfNotCreated());
return WaitEvent.CreateIfNotCreated();
}
void Init() void Init()
{ {
ProgressEvent.Reset(); ProgressEvent.Reset();
+1 -1
View File
@@ -16,7 +16,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream, STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition, const UInt64 *maxCheckStartPosition,
+1 -1
View File
@@ -16,7 +16,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream, STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition, const UInt64 *maxCheckStartPosition,
+4
View File
@@ -19,6 +19,7 @@ extern "C"
HINSTANCE g_hInstance; HINSTANCE g_hInstance;
#ifndef _UNICODE #ifndef _UNICODE
#ifdef _WIN32
bool g_IsNT = false; bool g_IsNT = false;
static bool IsItWindowsNT() static bool IsItWindowsNT()
{ {
@@ -29,6 +30,7 @@ static bool IsItWindowsNT()
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
} }
#endif #endif
#endif
extern "C" extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
@@ -37,8 +39,10 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
g_hInstance = hInstance; g_hInstance = hInstance;
#ifndef _UNICODE #ifndef _UNICODE
#ifdef _WIN32
g_IsNT = IsItWindowsNT(); g_IsNT = IsItWindowsNT();
#endif #endif
#endif
#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES) #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
SetLargePageSize(); SetLargePageSize();
#endif #endif
+3 -3
View File
@@ -23,8 +23,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_QUERYINTERFACE_BEGIN MY_QUERYINTERFACE_BEGIN2(IInArchive)
MY_QUERYINTERFACE_ENTRY(IInArchive)
MY_QUERYINTERFACE_ENTRY(IOutArchive) MY_QUERYINTERFACE_ENTRY(IOutArchive)
MY_QUERYINTERFACE_ENTRY(ISetProperties) MY_QUERYINTERFACE_ENTRY(ISetProperties)
QUERY_ENTRY_ISetCompressCodecsInfo QUERY_ENTRY_ISetCompressCodecsInfo
@@ -79,7 +78,8 @@ private:
void InitMethodProperties() void InitMethodProperties()
{ {
m_Method.NumMatchFinderCyclesDefined = false; m_Method.NumMatchFinderCyclesDefined = false;
m_Level = m_Method.NumPasses = m_Method.NumFastBytes = m_Method.NumMatchFinderCycles = 0xFFFFFFFF; m_Level = m_Method.NumPasses = m_Method.NumFastBytes =
m_Method.NumMatchFinderCycles = m_Method.Algo = 0xFFFFFFFF;
} }
}; };
+13
View File
@@ -21,6 +21,9 @@ using namespace NTime;
namespace NArchive { namespace NArchive {
namespace NGZip { namespace NGZip {
static const UInt32 kAlgoX1 = 0;
static const UInt32 kAlgoX5 = 1;
static const UInt32 kNumPassesX1 = 1; static const UInt32 kNumPassesX1 = 1;
static const UInt32 kNumPassesX7 = 3; static const UInt32 kNumPassesX7 = 3;
static const UInt32 kNumPassesX9 = 10; static const UInt32 kNumPassesX9 = 10;
@@ -137,6 +140,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
m_Method.NumFastBytes = (level >= 9 ? kNumFastBytesX9 : m_Method.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
(level >= 7 ? kNumFastBytesX7 : (level >= 7 ? kNumFastBytesX7 :
kNumFastBytesX1)); kNumFastBytesX1));
if (m_Method.Algo == 0xFFFFFFFF)
m_Method.Algo =
(level >= 5 ? kAlgoX5 :
kAlgoX1);
return UpdateArchive( return UpdateArchive(
EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS
@@ -193,6 +200,12 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
m_Method.NumMatchFinderCycles = num; m_Method.NumMatchFinderCycles = num;
m_Method.NumMatchFinderCyclesDefined = true; m_Method.NumMatchFinderCyclesDefined = true;
} }
else if (name.Left(1) == L"A")
{
UInt32 num = kAlgoX5;
RINOK(ParsePropValue(name.Mid(1), prop, num));
m_Method.Algo = num;
}
else else
return E_INVALIDARG; return E_INVALIDARG;
} }
+2 -2
View File
@@ -30,9 +30,9 @@ HRESULT CInArchive::ReadBytes(ISequentialInStream *inStream, void *data, UInt32
HRESULT CInArchive::ReadByte(ISequentialInStream *inStream, Byte &value, UInt32 &crc) HRESULT CInArchive::ReadByte(ISequentialInStream *inStream, Byte &value, UInt32 &crc)
{ {
HRESULT res = ReadBytes(inStream, &value, 1); RINOK(ReadBytes(inStream, &value, 1));
crc = CRC_UPDATE_BYTE(crc, value); crc = CRC_UPDATE_BYTE(crc, value);
return res; return S_OK;
} }
HRESULT CInArchive::ReadUInt16(ISequentialInStream *inStream, UInt16 &value, UInt32 &crc) HRESULT CInArchive::ReadUInt16(ISequentialInStream *inStream, UInt16 &value, UInt32 &crc)
+2
View File
@@ -83,12 +83,14 @@ HRESULT UpdateArchive(
NWindows::NCOM::CPropVariant properties[] = NWindows::NCOM::CPropVariant properties[] =
{ {
compressionMethod.Algo,
compressionMethod.NumPasses, compressionMethod.NumPasses,
compressionMethod.NumFastBytes, compressionMethod.NumFastBytes,
compressionMethod.NumMatchFinderCycles compressionMethod.NumMatchFinderCycles
}; };
PROPID propIDs[] = PROPID propIDs[] =
{ {
NCoderPropID::kAlgorithm,
NCoderPropID::kNumPasses, NCoderPropID::kNumPasses,
NCoderPropID::kNumFastBytes, NCoderPropID::kNumFastBytes,
NCoderPropID::kMatchFinderCycles NCoderPropID::kMatchFinderCycles
+1
View File
@@ -17,6 +17,7 @@ struct CCompressionMethodMode
{ {
UInt32 NumPasses; UInt32 NumPasses;
UInt32 NumFastBytes; UInt32 NumFastBytes;
UInt32 Algo;
bool NumMatchFinderCyclesDefined; bool NumMatchFinderCyclesDefined;
UInt32 NumMatchFinderCycles; UInt32 NumMatchFinderCycles;
}; };
+3 -3
View File
@@ -48,7 +48,7 @@ namespace NArchive
{ {
kExtract = 0, kExtract = 0,
kTest, kTest,
kSkip, kSkip
}; };
} }
namespace NOperationResult namespace NOperationResult
@@ -58,7 +58,7 @@ namespace NArchive
kOK = 0, kOK = 0,
kUnSupportedMethod, kUnSupportedMethod,
kDataError, kDataError,
kCRCError, kCRCError
}; };
} }
} }
@@ -69,7 +69,7 @@ namespace NArchive
enum enum
{ {
kOK = 0, kOK = 0,
kError, kError
}; };
} }
} }
+1 -1
View File
@@ -1,4 +1,4 @@
// Tar/Handler.h // Iso/Handler.h
#ifndef __ISO_HANDLER_H #ifndef __ISO_HANDLER_H
#define __ISO_HANDLER_H #define __ISO_HANDLER_H
+1 -1
View File
@@ -15,7 +15,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *inStream, STDMETHOD(Open)(IInStream *inStream,
const UInt64 *maxCheckStartPosition, const UInt64 *maxCheckStartPosition,
+1 -2
View File
@@ -27,8 +27,7 @@ class CHandler:
bool GetCompressedSize(int index, UInt32 &size); bool GetCompressedSize(int index, UInt32 &size);
public: public:
MY_QUERYINTERFACE_BEGIN MY_QUERYINTERFACE_BEGIN2(IInArchive)
MY_QUERYINTERFACE_ENTRY(IInArchive)
QUERY_ENTRY_ISetCompressCodecsInfo QUERY_ENTRY_ISetCompressCodecsInfo
MY_QUERYINTERFACE_END MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE MY_ADDREF_RELEASE
+4
View File
@@ -23,7 +23,9 @@ public:
SignatureInitializer() { kSignature[0]--; }; SignatureInitializer() { kSignature[0]--; };
} g_SignatureInitializer; } g_SignatureInitializer;
#ifdef NSIS_SCRIPT
static const char *kCrLf = "\x0D\x0A"; static const char *kCrLf = "\x0D\x0A";
#endif
UInt32 GetUInt32FromMemLE(const Byte *p) UInt32 GetUInt32FromMemLE(const Byte *p)
{ {
@@ -245,6 +247,7 @@ enum
EW_LOCKWINDOW EW_LOCKWINDOW
}; };
#ifdef NSIS_SCRIPT
static CCommandPair kCommandPairs[] = static CCommandPair kCommandPairs[] =
{ {
{ 0, "Invalid" }, { 0, "Invalid" },
@@ -324,6 +327,7 @@ static CCommandPair kCommandPairs[] =
{ 6, "LockWindow" } { 6, "LockWindow" }
}; };
#endif
static const char *kShellStrings[] = static const char *kShellStrings[] =
{ {
+1 -1
View File
@@ -14,7 +14,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream, STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition, const UInt64 *maxCheckStartPosition,
+1 -1
View File
@@ -14,7 +14,7 @@
#include "../../IPassword.h" #include "../../IPassword.h"
#include "../../Common/ProgressUtils.h" #include "../../Common/ProgressUtils.h"
#include "../../Common/CreateCoder.h" #include "../../Common/CreateCoder.h"
#include "../../Common/MethodID.h" #include "../../Common/MethodId.h"
#include "../../Common/FilterCoder.h" #include "../../Common/FilterCoder.h"
#include "../../Compress/Copy/CopyCoder.h" #include "../../Compress/Copy/CopyCoder.h"
#include "../../Crypto/Rar20/Rar20Cipher.h" #include "../../Crypto/Rar20/Rar20Cipher.h"
+1 -1
View File
@@ -18,7 +18,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_QUERYINTERFACE_BEGIN MY_QUERYINTERFACE_BEGIN2(IInArchive)
QUERY_ENTRY_ISetCompressCodecsInfo QUERY_ENTRY_ISetCompressCodecsInfo
MY_QUERYINTERFACE_END MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE MY_ADDREF_RELEASE
-2
View File
@@ -17,8 +17,6 @@ extern "C"
namespace NArchive { namespace NArchive {
namespace NRar { namespace NRar {
static const char kEndOfString = '\0';
void CInArchive::ThrowExceptionWithCode( void CInArchive::ThrowExceptionWithCode(
CInArchiveException::CCauseType cause) CInArchiveException::CCauseType cause)
{ {
+1 -1
View File
@@ -24,7 +24,7 @@ public:
kUnexpectedEndOfArchive = 0, kUnexpectedEndOfArchive = 0,
kArchiveHeaderCRCError, kArchiveHeaderCRCError,
kFileHeaderCRCError, kFileHeaderCRCError,
kIncorrectArchive, kIncorrectArchive
} }
Cause; Cause;
CInArchiveException(CCauseType cause) : Cause(cause) {} CInArchiveException(CCauseType cause) : Cause(cause) {}
+1 -1
View File
@@ -17,7 +17,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP1(IInArchiveGetStream) MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
STDMETHOD(Open)(IInStream *stream, STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition, const UInt64 *maxCheckStartPosition,
+1 -1
View File
@@ -14,7 +14,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream, STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition, const UInt64 *maxCheckStartPosition,
+2
View File
@@ -166,12 +166,14 @@ HRESULT CAddCommon::Compress(
{ {
NWindows::NCOM::CPropVariant properties[] = NWindows::NCOM::CPropVariant properties[] =
{ {
_options.Algo,
_options.NumPasses, _options.NumPasses,
_options.NumFastBytes, _options.NumFastBytes,
_options.NumMatchFinderCycles _options.NumMatchFinderCycles
}; };
PROPID propIDs[] = PROPID propIDs[] =
{ {
NCoderPropID::kAlgorithm,
NCoderPropID::kNumPasses, NCoderPropID::kNumPasses,
NCoderPropID::kNumFastBytes, NCoderPropID::kNumFastBytes,
NCoderPropID::kMatchFinderCycles NCoderPropID::kMatchFinderCycles
@@ -13,6 +13,7 @@ struct CCompressionMethodMode
{ {
CRecordVector<Byte> MethodSequence; CRecordVector<Byte> MethodSequence;
// bool MaximizeRatio; // bool MaximizeRatio;
UInt32 Algo;
UInt32 NumPasses; UInt32 NumPasses;
UInt32 NumFastBytes; UInt32 NumFastBytes;
bool NumMatchFinderCyclesDefined; bool NumMatchFinderCyclesDefined;
+1 -1
View File
@@ -37,7 +37,7 @@ using namespace NTime;
namespace NArchive { namespace NArchive {
namespace NZip { namespace NZip {
static const CMethodId kMethodId_Store = 0; // static const CMethodId kMethodId_Store = 0;
static const CMethodId kMethodId_ZipBase = 0x040100; static const CMethodId kMethodId_ZipBase = 0x040100;
static const CMethodId kMethodId_BZip2 = 0x040202; static const CMethodId kMethodId_BZip2 = 0x040202;
+3 -2
View File
@@ -27,8 +27,7 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_QUERYINTERFACE_BEGIN MY_QUERYINTERFACE_BEGIN2(IInArchive)
MY_QUERYINTERFACE_ENTRY(IInArchive)
MY_QUERYINTERFACE_ENTRY(IOutArchive) MY_QUERYINTERFACE_ENTRY(IOutArchive)
MY_QUERYINTERFACE_ENTRY(ISetProperties) MY_QUERYINTERFACE_ENTRY(ISetProperties)
QUERY_ENTRY_ISetCompressCodecsInfo QUERY_ENTRY_ISetCompressCodecsInfo
@@ -73,6 +72,7 @@ private:
int m_Level; int m_Level;
int m_MainMethod; int m_MainMethod;
UInt32 m_DicSize; UInt32 m_DicSize;
UInt32 m_Algo;
UInt32 m_NumPasses; UInt32 m_NumPasses;
UInt32 m_NumFastBytes; UInt32 m_NumFastBytes;
UInt32 m_NumMatchFinderCycles; UInt32 m_NumMatchFinderCycles;
@@ -91,6 +91,7 @@ private:
{ {
m_Level = -1; m_Level = -1;
m_MainMethod = -1; m_MainMethod = -1;
m_Algo =
m_DicSize = m_DicSize =
m_NumPasses = m_NumPasses =
m_NumFastBytes = m_NumFastBytes =
+14
View File
@@ -24,6 +24,9 @@ using namespace NTime;
namespace NArchive { namespace NArchive {
namespace NZip { namespace NZip {
static const UInt32 kDeflateAlgoX1 = 0;
static const UInt32 kDeflateAlgoX5 = 1;
static const UInt32 kDeflateNumPassesX1 = 1; static const UInt32 kDeflateNumPassesX1 = 1;
static const UInt32 kDeflateNumPassesX7 = 3; static const UInt32 kDeflateNumPassesX7 = 3;
static const UInt32 kDeflateNumPassesX9 = 10; static const UInt32 kDeflateNumPassesX9 = 10;
@@ -238,6 +241,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
options.NumFastBytes = m_NumFastBytes; options.NumFastBytes = m_NumFastBytes;
options.NumMatchFinderCycles = m_NumMatchFinderCycles; options.NumMatchFinderCycles = m_NumMatchFinderCycles;
options.NumMatchFinderCyclesDefined = m_NumMatchFinderCyclesDefined; options.NumMatchFinderCyclesDefined = m_NumMatchFinderCyclesDefined;
options.Algo = m_Algo;
#ifdef COMPRESS_MT #ifdef COMPRESS_MT
options.NumThreads = _numThreads; options.NumThreads = _numThreads;
#endif #endif
@@ -251,6 +255,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
options.NumFastBytes = (level >= 9 ? kNumFastBytesX9 : options.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
(level >= 7 ? kNumFastBytesX7 : (level >= 7 ? kNumFastBytesX7 :
kNumFastBytesX1)); kNumFastBytesX1));
if (options.Algo == 0xFFFFFFFF)
options.Algo =
(level >= 5 ? kDeflateAlgoX5 :
kDeflateAlgoX1);
} }
if (isBZip2) if (isBZip2)
{ {
@@ -386,6 +394,12 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads)); RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
#endif #endif
} }
else if (name.Left(1) == L"A")
{
UInt32 num = kDeflateAlgoX5;
RINOK(ParsePropValue(name.Mid(1), prop, num));
m_Algo = num;
}
else else
return E_INVALIDARG; return E_INVALIDARG;
} }
-2
View File
@@ -38,8 +38,6 @@ bool CLocalItem::IsImplodeLiteralsOn() const
return (Flags & NFileHeader::NFlags::kImplodeLiteralsOnMask) != 0; return (Flags & NFileHeader::NFlags::kImplodeLiteralsOnMask) != 0;
} }
static const char *kUnknownAttributes = "Unknown file attributes";
bool CLocalItem::IsDirectory() const bool CLocalItem::IsDirectory() const
{ {
return NItemName::HasTailSlash(Name, GetCodePage()); return NItemName::HasTailSlash(Name, GetCodePage());
+18 -40
View File
@@ -30,16 +30,6 @@ using namespace NSynchronization;
namespace NArchive { namespace NArchive {
namespace NZip { namespace NZip {
class CCriticalSectionLock2
{
CCriticalSection *_object;
void Unlock() { if (_object != 0) _object->Leave(); }
public:
CCriticalSectionLock2(): _object(0) {}
void Set(CCriticalSection &object) { _object = &object; _object->Enter(); }
~CCriticalSectionLock2() { Unlock(); }
};
static const Byte kMadeByHostOS = NFileHeader::NHostOS::kFAT; static const Byte kMadeByHostOS = NFileHeader::NHostOS::kFAT;
static const Byte kExtractHostOS = NFileHeader::NHostOS::kFAT; static const Byte kExtractHostOS = NFileHeader::NHostOS::kFAT;
@@ -135,7 +125,7 @@ static void SetItemInfoFromCompressingResult(const CCompressingResult &compressi
#ifdef COMPRESS_MT #ifdef COMPRESS_MT
static DWORD WINAPI CoderThread(void *threadCoderInfo); static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo);
struct CThreadInfo struct CThreadInfo
{ {
@@ -145,8 +135,8 @@ struct CThreadInfo
#endif #endif
NWindows::CThread Thread; NWindows::CThread Thread;
CAutoResetEvent *CompressEvent; NWindows::NSynchronization::CAutoResetEvent CompressEvent;
CAutoResetEvent *CompressionCompletedEvent; NWindows::NSynchronization::CAutoResetEvent CompressionCompletedEvent;
bool ExitThread; bool ExitThread;
CMtCompressProgress *ProgressSpec; CMtCompressProgress *ProgressSpec;
@@ -164,21 +154,18 @@ struct CThreadInfo
UInt32 UpdateIndex; UInt32 UpdateIndex;
CThreadInfo(const CCompressionMethodMode &options): CThreadInfo(const CCompressionMethodMode &options):
CompressEvent(NULL),
CompressionCompletedEvent(NULL),
ExitThread(false), ExitThread(false),
ProgressSpec(0), ProgressSpec(0),
OutStreamSpec(0), OutStreamSpec(0),
Coder(options) Coder(options)
{} {}
void CreateEvents() HRESULT CreateEvents()
{ {
CompressEvent = new CAutoResetEvent(false); RINOK(CompressEvent.CreateIfNotCreated());
CompressionCompletedEvent = new CAutoResetEvent(false); return CompressionCompletedEvent.CreateIfNotCreated();
} }
bool CreateThread() { return Thread.Create(CoderThread, this); } HRes CreateThread() { return Thread.Create(CoderThread, this); }
~CThreadInfo();
void WaitAndCode(); void WaitAndCode();
void StopWaitClose() void StopWaitClose()
@@ -186,27 +173,19 @@ struct CThreadInfo
ExitThread = true; ExitThread = true;
if (OutStreamSpec != 0) if (OutStreamSpec != 0)
OutStreamSpec->StopWriting(E_ABORT); OutStreamSpec->StopWriting(E_ABORT);
if (CompressEvent != NULL) if (CompressEvent.IsCreated())
CompressEvent->Set(); CompressEvent.Set();
Thread.Wait(); Thread.Wait();
Thread.Close(); Thread.Close();
} }
}; };
CThreadInfo::~CThreadInfo()
{
if (CompressEvent != NULL)
delete CompressEvent;
if (CompressionCompletedEvent != NULL)
delete CompressionCompletedEvent;
}
void CThreadInfo::WaitAndCode() void CThreadInfo::WaitAndCode()
{ {
for (;;) for (;;)
{ {
CompressEvent->Lock(); CompressEvent.Lock();
if (ExitThread) if (ExitThread)
return; return;
Result = Coder.Compress( Result = Coder.Compress(
@@ -216,11 +195,11 @@ void CThreadInfo::WaitAndCode()
InStream, OutStream, Progress, CompressingResult); InStream, OutStream, Progress, CompressingResult);
if (Result == S_OK && Progress) if (Result == S_OK && Progress)
Result = Progress->SetRatioInfo(&CompressingResult.UnpackSize, &CompressingResult.PackSize); Result = Progress->SetRatioInfo(&CompressingResult.UnpackSize, &CompressingResult.PackSize);
CompressionCompletedEvent->Set(); CompressionCompletedEvent.Set();
} }
} }
static DWORD WINAPI CoderThread(void *threadCoderInfo) static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
{ {
((CThreadInfo *)threadCoderInfo)->WaitAndCode(); ((CThreadInfo *)threadCoderInfo)->WaitAndCode();
return 0; return 0;
@@ -518,8 +497,7 @@ static HRESULT Update2(
CRecordVector<int> threadIndices; // list threads in order of updateItems CRecordVector<int> threadIndices; // list threads in order of updateItems
{ {
if (!memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize))) RINOK(memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize)));
return E_OUTOFMEMORY;
for(i = 0; i < updateItems.Size(); i++) for(i = 0; i < updateItems.Size(); i++)
refs.Refs.Add(CMemBlocks2()); refs.Refs.Add(CMemBlocks2());
@@ -534,15 +512,15 @@ static HRESULT Update2(
threadInfo._codecsInfo = codecsInfo; threadInfo._codecsInfo = codecsInfo;
threadInfo._externalCodecs = externalCodecs; threadInfo._externalCodecs = externalCodecs;
#endif #endif
threadInfo.CreateEvents(); RINOK(threadInfo.CreateEvents());
threadInfo.OutStreamSpec = new COutMemStream(&memManager); threadInfo.OutStreamSpec = new COutMemStream(&memManager);
RINOK(threadInfo.OutStreamSpec->CreateEvents());
threadInfo.OutStream = threadInfo.OutStreamSpec; threadInfo.OutStream = threadInfo.OutStreamSpec;
threadInfo.IsFree = true; threadInfo.IsFree = true;
threadInfo.ProgressSpec = new CMtCompressProgress(); threadInfo.ProgressSpec = new CMtCompressProgress();
threadInfo.Progress = threadInfo.ProgressSpec; threadInfo.Progress = threadInfo.ProgressSpec;
threadInfo.ProgressSpec->Init(&mtCompressProgressMixer, (int)i); threadInfo.ProgressSpec->Init(&mtCompressProgressMixer, (int)i);
if (!threadInfo.CreateThread()) RINOK(threadInfo.CreateThread());
return ::GetLastError();
} }
} }
int mtItemIndex = 0; int mtItemIndex = 0;
@@ -601,10 +579,10 @@ static HRESULT Update2(
threadInfo.OutStreamSpec->Init(); threadInfo.OutStreamSpec->Init();
threadInfo.ProgressSpec->Reinit(); threadInfo.ProgressSpec->Reinit();
threadInfo.CompressEvent->Set(); threadInfo.CompressEvent.Set();
threadInfo.UpdateIndex = mtItemIndex - 1; threadInfo.UpdateIndex = mtItemIndex - 1;
compressingCompletedEvents.Add(*threadInfo.CompressionCompletedEvent); compressingCompletedEvents.Add(threadInfo.CompressionCompletedEvent);
threadIndices.Add(i); threadIndices.Add(i);
break; break;
} }
@@ -126,6 +126,7 @@ CRYPTO_HASH_OBJS = \
C_OBJS = \ C_OBJS = \
$O\Alloc.obj \ $O\Alloc.obj \
$O\Threads.obj \
C_BRANCH_OBJS = \ C_BRANCH_OBJS = \
$O\BranchARM.obj \ $O\BranchARM.obj \
+2 -1
View File
@@ -95,7 +95,8 @@ LZMA_OPT_OBJS = \
C_OBJS = \ C_OBJS = \
$O\Alloc.obj \ $O\Alloc.obj \
$O\7zCrc.obj $O\7zCrc.obj \
$O\Threads.obj \
C_BRANCH_OBJS = \ C_BRANCH_OBJS = \
$O\BranchARM.obj \ $O\BranchARM.obj \
+60 -8
View File
@@ -236,6 +236,10 @@ SOURCE=..\..\..\Windows\Synchronization.cpp
SOURCE=..\..\..\Windows\Synchronization.h SOURCE=..\..\..\Windows\Synchronization.h
# End Source File # End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Thread.h
# End Source File
# End Group # End Group
# Begin Group "Compress" # Begin Group "Compress"
@@ -785,14 +789,6 @@ SOURCE=..\..\Compress\Quantum\QuantumDecoder.h
# PROP Default_Filter "" # PROP Default_Filter ""
# Begin Source File # Begin Source File
SOURCE=..\..\Compress\Lzh\Lzh1Decoder.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Compress\Lzh\Lzh1Decoder.h
# End Source File
# Begin Source File
SOURCE=..\..\Compress\Lzh\LzhDecoder.cpp SOURCE=..\..\Compress\Lzh\LzhDecoder.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -2346,5 +2342,61 @@ SOURCE=..\..\IPassword.h
SOURCE=..\..\IProgress.h SOURCE=..\..\IProgress.h
# End Source File # End Source File
# End Group # End Group
# Begin Source File
SOURCE=..\..\Archive\Arj\arj.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\BZip2\bz2.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Cab\cab.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Cpio\cpio.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Deb\deb.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\GZip\gz.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Iso\Iso.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Lzh\lzh.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Rar\rar.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\RPM\rpm.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Split\Split.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Tar\tar.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Z\Z.ico
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Zip\zip.ico
# End Source File
# End Target # End Target
# End Project # End Project
+7 -3
View File
@@ -123,9 +123,7 @@ static const NRecursedType::EEnum kCommandRecursedDefault[kNumCommandForms] =
// static const bool kTestExtractRecursedDefault = true; // static const bool kTestExtractRecursedDefault = true;
// static const bool kAddRecursedDefault = false; // static const bool kAddRecursedDefault = false;
static const int kMaxCmdLineSize = 1000;
static const wchar_t *kUniversalWildcard = L"*"; static const wchar_t *kUniversalWildcard = L"*";
// static const int kMinNonSwitchWords = 1;
static const int kCommandIndex = 0; static const int kCommandIndex = 0;
static const char *kHelpString = static const char *kHelpString =
@@ -416,13 +414,19 @@ int Main2(
} }
else else
{ {
UInt64 numErrors = 0;
HRESULT result = ListArchives( HRESULT result = ListArchives(
codecs, codecs,
v1, v2, v1, v2,
wildcardCensorHead, wildcardCensorHead,
true, false, true, false,
passwordEnabled, passwordEnabled,
password); password, numErrors);
if (numErrors > 0)
{
g_StdOut << endl << "Errors: " << numErrors;
return NExitCode::kFatalError;
}
if (result != S_OK) if (result != S_OK)
throw CSystemException(result); throw CSystemException(result);
} }
+10 -9
View File
@@ -67,7 +67,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "_SFX" /D "NO_READ_FROM_CODER" /Yu"StdAfx.h" /FD /GZ /c # ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "_SFX" /D "NO_READ_FROM_CODER" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -125,14 +125,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2MT.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\Archive\Common\CoderMixer2ST.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Common\CoderMixer2ST.h
# End Source File
# Begin Source File
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -801,6 +793,15 @@ SOURCE=..\..\..\..\C\Alloc.c
SOURCE=..\..\..\..\C\Alloc.h SOURCE=..\..\..\..\C\Alloc.h
# End Source File # End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.h
# End Source File
# End Group # End Group
# Begin Source File # Begin Source File
+1
View File
@@ -118,6 +118,7 @@ CRYPTO_HASH_OBJS = \
C_OBJS = \ C_OBJS = \
$O\Alloc.obj \ $O\Alloc.obj \
$O\Threads.obj \
C_BRANCH_OBJS = \ C_BRANCH_OBJS = \
$O\BranchX86.obj \ $O\BranchX86.obj \
+3 -4
View File
@@ -40,7 +40,7 @@ struct CThreadExtracting
ExtractCallbackSpec->ProgressDialog.MyClose(); ExtractCallbackSpec->ProgressDialog.MyClose();
return 0; return 0;
} }
static DWORD WINAPI MyThreadFunction(void *param) static THREAD_FUNC_DECL MyThreadFunction(void *param)
{ {
return ((CThreadExtracting *)param)->Process(); return ((CThreadExtracting *)param)->Process();
} }
@@ -115,9 +115,8 @@ HRESULT ExtractArchive(
if (showProgress) if (showProgress)
{ {
CThread thread; NWindows::CThread thread;
if (!thread.Create(CThreadExtracting::MyThreadFunction, &extracter)) RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &extracter));
throw 271824;
UString title; UString title;
#ifdef LANG #ifdef LANG
+9
View File
@@ -710,6 +710,15 @@ SOURCE=..\..\..\..\C\Alloc.c
SOURCE=..\..\..\..\C\Alloc.h SOURCE=..\..\..\..\C\Alloc.h
# End Source File # End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.h
# End Source File
# End Group # End Group
# Begin Source File # Begin Source File
+1
View File
@@ -100,6 +100,7 @@ LZMA_OPT_OBJS = \
C_OBJS = \ C_OBJS = \
$O\Alloc.obj \ $O\Alloc.obj \
$O\Threads.obj \
C_BRANCH_OBJS = \ C_BRANCH_OBJS = \
$O\BranchX86.obj \ $O\BranchX86.obj \
+37 -9
View File
@@ -15,6 +15,7 @@
#include "../../IPassword.h" #include "../../IPassword.h"
#include "../../Archive/IArchive.h" #include "../../Archive/IArchive.h"
#include "../../UI/Common/Extract.h" #include "../../UI/Common/Extract.h"
#include "../../UI/Common/ExitCode.h"
#include "../../UI/Explorer/MyMessages.h" #include "../../UI/Explorer/MyMessages.h"
#include "../../UI/GUI/ExtractGUI.h" #include "../../UI/GUI/ExtractGUI.h"
@@ -31,13 +32,11 @@ static inline bool IsItWindowsNT()
} }
#endif #endif
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */) static const wchar_t *kMemoryExceptionMessage = L"ERROR: Can't allocate required memory!";
{ static const wchar_t *kUnknownExceptionMessage = L"ERROR: Unknown Error!";
g_hInstance = (HINSTANCE)hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
int APIENTRY WinMain2()
{
UString password; UString password;
bool assumeYes = false; bool assumeYes = false;
bool outputFolderDefined = false; bool outputFolderDefined = false;
@@ -116,9 +115,38 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
outputFolderDefined ? outputFolder : outputFolderDefined ? outputFolder :
fullPath.Left(fileNamePartStartIndex)); fullPath.Left(fileNamePartStartIndex));
*/ */
if (result == S_OK)
{
return 0;
}
if (result == E_ABORT)
return NExitCode::kUserBreak;
if (result == S_FALSE) if (result == S_FALSE)
MyMessageBox(L"Archive is not supported"); MyMessageBox(L"Error in archive");
else if (result != S_OK && result != E_ABORT) else
ShowErrorMessage(0, result); ShowErrorMessage(0, result);
return 0; return NExitCode::kFatalError;
} }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */)
{
g_hInstance = (HINSTANCE)hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
try
{
return WinMain2();
}
catch(const CNewException &)
{
MyMessageBox(kMemoryExceptionMessage);
return (NExitCode::kMemoryError);
}
catch(...)
{
MyMessageBox(kUnknownExceptionMessage);
return NExitCode::kFatalError;
}
}
+18 -1
View File
@@ -71,7 +71,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_SFXWIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "NO_REGISTRY" /D "NO_READ_FROM_CODER" /D "_SFX" /Yu"StdAfx.h" /FD /GZ /c # ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_SFXWIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "NO_REGISTRY" /D "NO_READ_FROM_CODER" /D "_SFX" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -712,6 +712,14 @@ SOURCE=..\..\..\Common\IntToString.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\..\Common\String.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -881,6 +889,15 @@ SOURCE=..\..\..\..\C\Alloc.c
SOURCE=..\..\..\..\C\Alloc.h SOURCE=..\..\..\..\C\Alloc.h
# End Source File # End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.h
# End Source File
# End Group # End Group
# Begin Source File # Begin Source File
+1
View File
@@ -123,6 +123,7 @@ CRYPTO_HASH_OBJS = \
C_OBJS = \ C_OBJS = \
$O\Alloc.obj \ $O\Alloc.obj \
$O\Threads.obj \
C_BRANCH_OBJS = \ C_BRANCH_OBJS = \
$O\BranchX86.obj \ $O\BranchX86.obj \
+21 -7
View File
@@ -25,7 +25,7 @@ bool CInFileStream::Open(LPCTSTR fileName)
return File.Open(fileName); return File.Open(fileName);
} }
#ifdef _WIN32 #ifdef USE_WIN_FILE
#ifndef _UNICODE #ifndef _UNICODE
bool CInFileStream::Open(LPCWSTR fileName) bool CInFileStream::Open(LPCWSTR fileName)
{ {
@@ -34,9 +34,23 @@ bool CInFileStream::Open(LPCWSTR fileName)
#endif #endif
#endif #endif
bool CInFileStream::OpenShared(LPCTSTR fileName, bool shareForWrite)
{
return File.OpenShared(fileName, shareForWrite);
}
#ifdef USE_WIN_FILE
#ifndef _UNICODE
bool CInFileStream::OpenShared(LPCWSTR fileName, bool shareForWrite)
{
return File.OpenShared(fileName, shareForWrite);
}
#endif
#endif
STDMETHODIMP CInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize) STDMETHODIMP CInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{ {
#ifdef _WIN32 #ifdef USE_WIN_FILE
UInt32 realProcessedSize; UInt32 realProcessedSize;
bool result = File.ReadPart(data, size, realProcessedSize); bool result = File.ReadPart(data, size, realProcessedSize);
@@ -98,7 +112,7 @@ STDMETHODIMP CInFileStream::Seek(Int64 offset, UInt32 seekOrigin,
if(seekOrigin >= 3) if(seekOrigin >= 3)
return STG_E_INVALIDFUNCTION; return STG_E_INVALIDFUNCTION;
#ifdef _WIN32 #ifdef USE_WIN_FILE
UInt64 realNewPosition; UInt64 realNewPosition;
bool result = File.Seek(offset, seekOrigin, realNewPosition); bool result = File.Seek(offset, seekOrigin, realNewPosition);
@@ -132,7 +146,7 @@ bool COutFileStream::Create(LPCTSTR fileName, bool createAlways)
return File.Create(fileName, createAlways); return File.Create(fileName, createAlways);
} }
#ifdef _WIN32 #ifdef USE_WIN_FILE
#ifndef _UNICODE #ifndef _UNICODE
bool COutFileStream::Create(LPCWSTR fileName, bool createAlways) bool COutFileStream::Create(LPCWSTR fileName, bool createAlways)
{ {
@@ -143,7 +157,7 @@ bool COutFileStream::Create(LPCWSTR fileName, bool createAlways)
STDMETHODIMP COutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize) STDMETHODIMP COutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
{ {
#ifdef _WIN32 #ifdef USE_WIN_FILE
UInt32 realProcessedSize; UInt32 realProcessedSize;
bool result = File.WritePart(data, size, realProcessedSize); bool result = File.WritePart(data, size, realProcessedSize);
@@ -170,7 +184,7 @@ STDMETHODIMP COutFileStream::Seek(Int64 offset, UInt32 seekOrigin,
{ {
if(seekOrigin >= 3) if(seekOrigin >= 3)
return STG_E_INVALIDFUNCTION; return STG_E_INVALIDFUNCTION;
#ifdef _WIN32 #ifdef USE_WIN_FILE
UInt64 realNewPosition; UInt64 realNewPosition;
bool result = File.Seek(offset, seekOrigin, realNewPosition); bool result = File.Seek(offset, seekOrigin, realNewPosition);
@@ -192,7 +206,7 @@ STDMETHODIMP COutFileStream::Seek(Int64 offset, UInt32 seekOrigin,
STDMETHODIMP COutFileStream::SetSize(Int64 newSize) STDMETHODIMP COutFileStream::SetSize(Int64 newSize)
{ {
#ifdef _WIN32 #ifdef USE_WIN_FILE
UInt64 currentPos; UInt64 currentPos;
if(!File.Seek(0, FILE_CURRENT, currentPos)) if(!File.Seek(0, FILE_CURRENT, currentPos))
return E_FAIL; return E_FAIL;
+15 -4
View File
@@ -4,6 +4,10 @@
#define __FILESTREAMS_H #define __FILESTREAMS_H
#ifdef _WIN32 #ifdef _WIN32
#define USE_WIN_FILE
#endif
#ifdef USE_WIN_FILE
#include "../../Windows/FileIO.h" #include "../../Windows/FileIO.h"
#else #else
#include "../../Common/C_FileIO.h" #include "../../Common/C_FileIO.h"
@@ -18,7 +22,7 @@ class CInFileStream:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
#ifdef _WIN32 #ifdef USE_WIN_FILE
NWindows::NFile::NIO::CInFile File; NWindows::NFile::NIO::CInFile File;
#else #else
NC::NFile::NIO::CInFile File; NC::NFile::NIO::CInFile File;
@@ -27,12 +31,19 @@ public:
virtual ~CInFileStream() {} virtual ~CInFileStream() {}
bool Open(LPCTSTR fileName); bool Open(LPCTSTR fileName);
#ifdef _WIN32 #ifdef USE_WIN_FILE
#ifndef _UNICODE #ifndef _UNICODE
bool Open(LPCWSTR fileName); bool Open(LPCWSTR fileName);
#endif #endif
#endif #endif
bool OpenShared(LPCTSTR fileName, bool shareForWrite);
#ifdef USE_WIN_FILE
#ifndef _UNICODE
bool OpenShared(LPCWSTR fileName, bool shareForWrite);
#endif
#endif
MY_UNKNOWN_IMP2(IInStream, IStreamGetSize) MY_UNKNOWN_IMP2(IInStream, IStreamGetSize)
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
@@ -62,14 +73,14 @@ class COutFileStream:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
#ifdef _WIN32 #ifdef USE_WIN_FILE
NWindows::NFile::NIO::COutFile File; NWindows::NFile::NIO::COutFile File;
#else #else
NC::NFile::NIO::COutFile File; NC::NFile::NIO::COutFile File;
#endif #endif
virtual ~COutFileStream() {} virtual ~COutFileStream() {}
bool Create(LPCTSTR fileName, bool createAlways); bool Create(LPCTSTR fileName, bool createAlways);
#ifdef _WIN32 #ifdef USE_WIN_FILE
#ifndef _UNICODE #ifndef _UNICODE
bool Create(LPCWSTR fileName, bool createAlways); bool Create(LPCWSTR fileName, bool createAlways);
#endif #endif
+2 -2
View File
@@ -108,13 +108,13 @@ HRESULT CInMemStreamMt::Read()
} }
} }
static DWORD WINAPI CoderThread(void *threadCoderInfo) static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
{ {
((CInMemStreamMt *)threadCoderInfo)->ReadResult = ((CInMemStreamMt *)threadCoderInfo)->Read(); ((CInMemStreamMt *)threadCoderInfo)->ReadResult = ((CInMemStreamMt *)threadCoderInfo)->Read();
return 0; return 0;
} }
bool CInMemStreamMt::StartReadThread() HRes CInMemStreamMt::StartReadThread()
{ {
// _stopReading = false; // _stopReading = false;
NWindows::CThread Thread; NWindows::CThread Thread;
+9 -10
View File
@@ -82,11 +82,12 @@ class CResourceListMt: public CResourceList
public: public:
NWindows::NSynchronization::CSemaphore Semaphore; NWindows::NSynchronization::CSemaphore Semaphore;
bool AllocateList(int numItems) HRes AllocateList(int numItems)
{ {
if (!CResourceList::AllocateList(numItems)) if (!CResourceList::AllocateList(numItems))
return false; return false;
return Semaphore.Create((LONG)numItems, (LONG)numItems); Semaphore.Close();
return Semaphore.Create(numItems, numItems);
} }
int AllocateItem() int AllocateItem()
@@ -118,15 +119,15 @@ public:
CIntQueueMt(): _numItems(0), _head(0), _cur(0) {} CIntQueueMt(): _numItems(0), _head(0), _cur(0) {}
NWindows::NSynchronization::CSemaphore Semaphore; NWindows::NSynchronization::CSemaphore Semaphore;
bool AllocateList(int numItems) HRes AllocateList(int numItems)
{ {
FreeList(); FreeList();
if (numItems == 0) if (numItems == 0)
return true; return S_OK;
if (!CIntListCheck::AllocateList(numItems)) if (!CIntListCheck::AllocateList(numItems))
return false; return E_OUTOFMEMORY;
_numItems = numItems; _numItems = numItems;
return Semaphore.Create((LONG)0, (LONG)numItems); return Semaphore.Create(0, numItems);
} }
void FreeList() void FreeList()
@@ -142,10 +143,8 @@ public:
_data[_head++] = value; _data[_head++] = value;
if (_head == _numItems) if (_head == _numItems)
_head = 0; _head = 0;
LONG previousCount; Semaphore.Release();
Semaphore.Release(1, &previousCount);
// printf("\nRelease prev = %d\n", previousCount); // printf("\nRelease prev = %d\n", previousCount);
} }
int GetItem() int GetItem()
@@ -253,7 +252,7 @@ public:
// to stop reading you must implement // to stop reading you must implement
// returning Error in IInMemStreamMtCallback::AllocateBlock // returning Error in IInMemStreamMtCallback::AllocateBlock
// and then you must free at least one substream // and then you must free at least one substream
bool StartReadThread(); HRes StartReadThread();
void Free(); void Free();
-18
View File
@@ -8,22 +8,4 @@
namespace NStream { namespace NStream {
namespace NLSBF { namespace NLSBF {
void CEncoder::WriteBits(UInt32 value, int numBits)
{
while(numBits > 0)
{
if (numBits < m_BitPos)
{
m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos);
m_BitPos -= numBits;
return;
}
numBits -= m_BitPos;
m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos))));
value >>= m_BitPos;
m_BitPos = 8;
m_CurByte = 0;
}
}
}} }}
+17 -1
View File
@@ -38,7 +38,23 @@ public:
m_CurByte = 0; m_CurByte = 0;
} }
void WriteBits(UInt32 value, int numBits); void WriteBits(UInt32 value, int numBits)
{
while(numBits > 0)
{
if (numBits < m_BitPos)
{
m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos);
m_BitPos -= numBits;
return;
}
numBits -= m_BitPos;
m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos))));
value >>= m_BitPos;
m_BitPos = 8;
m_CurByte = 0;
}
}
UInt32 GetBitPosition() const { return (8 - m_BitPos); } UInt32 GetBitPosition() const { return (8 - m_BitPos); }
UInt64 GetProcessedSize() const { UInt64 GetProcessedSize() const {
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; } return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
+14 -12
View File
@@ -51,26 +51,27 @@ void CMemBlockManager::FreeBlock(void *p)
} }
bool CMemBlockManagerMt::AllocateSpace(size_t numBlocks, size_t numNoLockBlocks) HRes CMemBlockManagerMt::AllocateSpace(size_t numBlocks, size_t numNoLockBlocks)
{ {
if (numNoLockBlocks > numBlocks) if (numNoLockBlocks > numBlocks)
return false; return E_INVALIDARG;
if (!CMemBlockManager::AllocateSpace(numBlocks)) if (!CMemBlockManager::AllocateSpace(numBlocks))
return false; return E_OUTOFMEMORY;
size_t numLockBlocks = numBlocks - numNoLockBlocks; size_t numLockBlocks = numBlocks - numNoLockBlocks;
Semaphore.Close();
return Semaphore.Create((LONG)numLockBlocks, (LONG)numLockBlocks); return Semaphore.Create((LONG)numLockBlocks, (LONG)numLockBlocks);
} }
bool CMemBlockManagerMt::AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks) HRes CMemBlockManagerMt::AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks)
{ {
if (numNoLockBlocks > desiredNumberOfBlocks) if (numNoLockBlocks > desiredNumberOfBlocks)
return false; return E_INVALIDARG;
for (;;) for (;;)
{ {
if (AllocateSpace(desiredNumberOfBlocks, numNoLockBlocks)) if (AllocateSpace(desiredNumberOfBlocks, numNoLockBlocks) == 0)
return true; return 0;
if (desiredNumberOfBlocks == numNoLockBlocks) if (desiredNumberOfBlocks == numNoLockBlocks)
return false; return E_OUTOFMEMORY;
desiredNumberOfBlocks = numNoLockBlocks + ((desiredNumberOfBlocks - numNoLockBlocks) >> 1); desiredNumberOfBlocks = numNoLockBlocks + ((desiredNumberOfBlocks - numNoLockBlocks) >> 1);
} }
} }
@@ -152,16 +153,17 @@ void CMemLockBlocks::Free(CMemBlockManagerMt *memManager)
TotalSize = 0; TotalSize = 0;
} }
bool CMemLockBlocks::SwitchToNoLockMode(CMemBlockManagerMt *memManager) HRes CMemLockBlocks::SwitchToNoLockMode(CMemBlockManagerMt *memManager)
{ {
if (LockMode) if (LockMode)
{ {
if (Blocks.Size() > 0) if (Blocks.Size() > 0)
if (!memManager->ReleaseLockedBlocks(Blocks.Size())) {
return false; RINOK(memManager->ReleaseLockedBlocks(Blocks.Size()));
}
LockMode = false; LockMode = false;
} }
return true; return 0;
} }
void CMemLockBlocks::Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager) void CMemLockBlocks::Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager)
+4 -4
View File
@@ -41,12 +41,12 @@ public:
CMemBlockManagerMt(size_t blockSize = (1 << 20)): CMemBlockManager(blockSize) {} CMemBlockManagerMt(size_t blockSize = (1 << 20)): CMemBlockManager(blockSize) {}
~CMemBlockManagerMt() { FreeSpace(); } ~CMemBlockManagerMt() { FreeSpace(); }
bool AllocateSpace(size_t numBlocks, size_t numNoLockBlocks = 0); HRes AllocateSpace(size_t numBlocks, size_t numNoLockBlocks = 0);
bool AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks = 0); HRes AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks = 0);
void FreeSpace(); void FreeSpace();
void *AllocateBlock(); void *AllocateBlock();
void FreeBlock(void *p, bool lockMode = true); void FreeBlock(void *p, bool lockMode = true);
bool ReleaseLockedBlocks(int number) { return Semaphore.Release(number); } HRes ReleaseLockedBlocks(int number) { return Semaphore.Release(number); }
}; };
@@ -70,7 +70,7 @@ struct CMemLockBlocks: public CMemBlocks
CMemLockBlocks(): LockMode(true) {}; CMemLockBlocks(): LockMode(true) {};
void Free(CMemBlockManagerMt *memManager); void Free(CMemBlockManagerMt *memManager);
void FreeBlock(int index, CMemBlockManagerMt *memManager); void FreeBlock(int index, CMemBlockManagerMt *memManager);
bool SwitchToNoLockMode(CMemBlockManagerMt *memManager); HRes SwitchToNoLockMode(CMemBlockManagerMt *memManager);
void Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager); void Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager);
}; };
+2 -2
View File
@@ -1,8 +1,8 @@
// MethodID.cpp // MethodId.cpp
#include "StdAfx.h" #include "StdAfx.h"
#include "MethodID.h" #include "MethodId.h"
#include "../../Common/String.h" #include "../../Common/String.h"
static inline wchar_t GetHex(Byte value) static inline wchar_t GetHex(Byte value)
+1 -1
View File
@@ -1,4 +1,4 @@
// MethodID.h // MethodId.h
#ifndef __7Z_METHOD_ID_H #ifndef __7Z_METHOD_ID_H
#define __7Z_METHOD_ID_H #define __7Z_METHOD_ID_H
+6
View File
@@ -30,6 +30,12 @@ class COutMemStream:
public: public:
HRes CreateEvents()
{
RINOK(StopWritingEvent.CreateIfNotCreated());
return WriteToRealStreamEvent.CreateIfNotCreated();
}
void SetOutStream(IOutStream *outStream) void SetOutStream(IOutStream *outStream)
{ {
OutStream = outStream; OutStream = outStream;
+1 -1
View File
@@ -3,7 +3,7 @@
#ifndef __REGISTERCODEC_H #ifndef __REGISTERCODEC_H
#define __REGISTERCODEC_H #define __REGISTERCODEC_H
#include "../Common/MethodID.h" #include "../Common/MethodId.h"
typedef void * (*CreateCodecP)(); typedef void * (*CreateCodecP)();
struct CCodecInfo struct CCodecInfo
+15 -27
View File
@@ -51,31 +51,20 @@ STDMETHODIMP CSequentialOutStreamForBinder::Write(const void *data, UInt32 size,
// CStreamBinder // CStreamBinder
// (_thereAreBytesToReadEvent && _bufferSize == 0) means that stream is finished. // (_thereAreBytesToReadEvent && _bufferSize == 0) means that stream is finished.
void CStreamBinder::CreateEvents() HRes CStreamBinder::CreateEvents()
{ {
_allBytesAreWritenEvent = new CManualResetEvent(true); RINOK(_allBytesAreWritenEvent.Create(true));
_thereAreBytesToReadEvent = new CManualResetEvent(false); RINOK(_thereAreBytesToReadEvent.Create());
_readStreamIsClosedEvent = new CManualResetEvent(false); return _readStreamIsClosedEvent.Create();
} }
void CStreamBinder::ReInit() void CStreamBinder::ReInit()
{ {
_thereAreBytesToReadEvent->Reset(); _thereAreBytesToReadEvent.Reset();
_readStreamIsClosedEvent->Reset(); _readStreamIsClosedEvent.Reset();
ProcessedSize = 0; ProcessedSize = 0;
} }
CStreamBinder::~CStreamBinder()
{
if (_allBytesAreWritenEvent != NULL)
delete _allBytesAreWritenEvent;
if (_thereAreBytesToReadEvent != NULL)
delete _thereAreBytesToReadEvent;
if (_readStreamIsClosedEvent != NULL)
delete _readStreamIsClosedEvent;
}
void CStreamBinder::CreateStreams(ISequentialInStream **inStream, void CStreamBinder::CreateStreams(ISequentialInStream **inStream,
@@ -103,8 +92,7 @@ HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
UInt32 sizeToRead = size; UInt32 sizeToRead = size;
if (size > 0) if (size > 0)
{ {
if(!_thereAreBytesToReadEvent->Lock()) RINOK(_thereAreBytesToReadEvent.Lock());
return E_FAIL;
sizeToRead = MyMin(_bufferSize, size); sizeToRead = MyMin(_bufferSize, size);
if (_bufferSize > 0) if (_bufferSize > 0)
{ {
@@ -113,8 +101,8 @@ HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
_bufferSize -= sizeToRead; _bufferSize -= sizeToRead;
if (_bufferSize == 0) if (_bufferSize == 0)
{ {
_thereAreBytesToReadEvent->Reset(); _thereAreBytesToReadEvent.Reset();
_allBytesAreWritenEvent->Set(); _allBytesAreWritenEvent.Set();
} }
} }
} }
@@ -126,7 +114,7 @@ HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
void CStreamBinder::CloseRead() void CStreamBinder::CloseRead()
{ {
_readStreamIsClosedEvent->Set(); _readStreamIsClosedEvent.Set();
} }
HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSize) HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSize)
@@ -135,12 +123,12 @@ HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSiz
{ {
_buffer = data; _buffer = data;
_bufferSize = size; _bufferSize = size;
_allBytesAreWritenEvent->Reset(); _allBytesAreWritenEvent.Reset();
_thereAreBytesToReadEvent->Set(); _thereAreBytesToReadEvent.Set();
HANDLE events[2]; HANDLE events[2];
events[0] = *_allBytesAreWritenEvent; events[0] = _allBytesAreWritenEvent;
events[1] = *_readStreamIsClosedEvent; events[1] = _readStreamIsClosedEvent;
DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE); DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
if (waitResult != WAIT_OBJECT_0 + 0) if (waitResult != WAIT_OBJECT_0 + 0)
{ {
@@ -158,5 +146,5 @@ HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSiz
void CStreamBinder::CloseWrite() void CStreamBinder::CloseWrite()
{ {
// _bufferSize must be = 0 // _bufferSize must be = 0
_thereAreBytesToReadEvent->Set(); _thereAreBytesToReadEvent.Set();
} }
+5 -10
View File
@@ -8,21 +8,16 @@
class CStreamBinder class CStreamBinder
{ {
NWindows::NSynchronization::CManualResetEvent *_allBytesAreWritenEvent; NWindows::NSynchronization::CManualResetEvent _allBytesAreWritenEvent;
NWindows::NSynchronization::CManualResetEvent *_thereAreBytesToReadEvent; NWindows::NSynchronization::CManualResetEvent _thereAreBytesToReadEvent;
NWindows::NSynchronization::CManualResetEvent *_readStreamIsClosedEvent; NWindows::NSynchronization::CManualResetEvent _readStreamIsClosedEvent;
UInt32 _bufferSize; UInt32 _bufferSize;
const void *_buffer; const void *_buffer;
public: public:
// bool ReadingWasClosed; // bool ReadingWasClosed;
UInt64 ProcessedSize; UInt64 ProcessedSize;
CStreamBinder(): CStreamBinder() {}
_allBytesAreWritenEvent(NULL), HRes CreateEvents();
_thereAreBytesToReadEvent(NULL),
_readStreamIsClosedEvent(NULL)
{}
~CStreamBinder();
void CreateEvents();
void CreateStreams(ISequentialInStream **inStream, void CreateStreams(ISequentialInStream **inStream,
ISequentialOutStream **outStream); ISequentialOutStream **outStream);
+1 -1
View File
@@ -14,7 +14,7 @@ static const UInt32 kHistorySize = 26624;
static const UInt32 kMatchMaxLen = 256; static const UInt32 kMatchMaxLen = 256;
static const UInt32 kMatchMinLen = 3; static const UInt32 kMatchMinLen = 3;
static const UInt32 kNC = 255 + kMatchMaxLen + 2 - kMatchMinLen; // static const UInt32 kNC = 255 + kMatchMaxLen + 2 - kMatchMinLen;
void CCoder::MakeTable(int nchar, Byte *bitlen, int tablebits, void CCoder::MakeTable(int nchar, Byte *bitlen, int tablebits,
UInt32 *table, int tablesize) UInt32 *table, int tablesize)
+1 -1
View File
@@ -9,7 +9,7 @@ namespace NArj {
namespace NDecoder2 { namespace NDecoder2 {
static const UInt32 kHistorySize = 26624; static const UInt32 kHistorySize = 26624;
static const UInt32 kMatchMaxLen = 256; // static const UInt32 kMatchMaxLen = 256;
static const UInt32 kMatchMinLen = 3; static const UInt32 kMatchMinLen = 3;
STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream, STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
+31 -26
View File
@@ -420,7 +420,7 @@ static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UIn
#ifdef COMPRESS_BZIP2_MT #ifdef COMPRESS_BZIP2_MT
static DWORD WINAPI MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; } static THREAD_FUNC_DECL MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; }
CDecoder::CDecoder(): CDecoder::CDecoder():
m_States(0) m_States(0)
@@ -434,35 +434,40 @@ CDecoder::~CDecoder()
Free(); Free();
} }
bool CDecoder::Create() HRes CDecoder::Create()
{ {
RINOK(CanProcessEvent.CreateIfNotCreated());
RINOK(CanStartWaitingEvent.CreateIfNotCreated());
if (m_States != 0 && m_NumThreadsPrev == NumThreads)
return true;
Free();
MtMode = (NumThreads > 1);
m_NumThreadsPrev = NumThreads;
try try
{ {
if (m_States != 0 && m_NumThreadsPrev == NumThreads)
return true;
Free();
MtMode = (NumThreads > 1);
m_NumThreadsPrev = NumThreads;
m_States = new CState[NumThreads]; m_States = new CState[NumThreads];
if (m_States == 0) if (m_States == 0)
return false; return E_OUTOFMEMORY;
#ifdef COMPRESS_BZIP2_MT
for (UInt32 t = 0; t < NumThreads; t++)
{
CState &ti = m_States[t];
ti.Decoder = this;
if (MtMode)
if (!ti.Thread.Create(MFThread, &ti))
{
NumThreads = t;
Free();
return false;
}
}
#endif
} }
catch(...) { return false; } catch(...) { return E_OUTOFMEMORY; }
return true; #ifdef COMPRESS_BZIP2_MT
for (UInt32 t = 0; t < NumThreads; t++)
{
CState &ti = m_States[t];
ti.Decoder = this;
if (MtMode)
{
HRes res = ti.Thread.Create(MFThread, &ti);
if (res != S_OK)
{
NumThreads = t;
Free();
return res;
}
}
}
#endif
return S_OK;
} }
void CDecoder::Free() void CDecoder::Free()
@@ -517,13 +522,13 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
{ {
#ifdef COMPRESS_BZIP2_MT #ifdef COMPRESS_BZIP2_MT
Progress = progress; Progress = progress;
if (!Create()) RINOK(Create());
return E_FAIL;
for (UInt32 t = 0; t < NumThreads; t++) for (UInt32 t = 0; t < NumThreads; t++)
{ {
CState &s = m_States[t]; CState &s = m_States[t];
if (!s.Alloc()) if (!s.Alloc())
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
RINOK(s.Create());
s.StreamWasFinishedEvent.Reset(); s.StreamWasFinishedEvent.Reset();
s.WaitingWasStartedEvent.Reset(); s.WaitingWasStartedEvent.Reset();
s.CanWriteEvent.Reset(); s.CanWriteEvent.Reset();
+7 -1
View File
@@ -53,6 +53,12 @@ struct CState
void FinishStream(); void FinishStream();
void ThreadFunc(); void ThreadFunc();
HRes Create()
{
RINOK(StreamWasFinishedEvent.CreateIfNotCreated());
RINOK(WaitingWasStartedEvent.CreateIfNotCreated());
return CanWriteEvent.CreateIfNotCreated();
}
#endif #endif
CState(): Counters(0) {} CState(): Counters(0) {}
@@ -125,7 +131,7 @@ public:
UInt32 BlockSizeMax; UInt32 BlockSizeMax;
CDecoder(); CDecoder();
~CDecoder(); ~CDecoder();
bool Create(); HRes Create();
void Free(); void Free();
#else #else

Some files were not shown because too many files have changed in this diff Show More