4.48 beta

This commit is contained in:
Igor Pavlov
2007-06-26 00:00:00 +00:00
committed by Kornel Lesiński
parent 0b33f700a6
commit fd8b1d78b4
249 changed files with 3224 additions and 2157 deletions

View File

@@ -4,7 +4,7 @@
#define __CREATECODER_H
#include "Common/MyCom.h"
#include "Common/String.h"
#include "Common/MyString.h"
#include "../ICoder.h"
#include "MethodId.h"

View File

@@ -3,7 +3,7 @@
#ifndef __FILEPATHAUTORENAME_H
#define __FILEPATHAUTORENAME_H
#include "Common/String.h"
#include "Common/MyString.h"
bool AutoRenamePath(UString &fullProcessedPath);

View File

@@ -238,6 +238,18 @@ STDMETHODIMP CFilterCoder::WriteCoderProperties(ISequentialOutStream *outStream)
{
return _writeCoderProperties->WriteCoderProperties(outStream);
}
/*
STDMETHODIMP CFilterCoder::ResetSalt()
{
return _CryptoResetSalt->ResetSalt();
}
*/
STDMETHODIMP CFilterCoder::ResetInitVector()
{
return _CryptoResetInitVector->ResetInitVector();
}
#endif
STDMETHODIMP CFilterCoder::SetDecoderProperties2(const Byte *data, UInt32 size)

View File

@@ -26,6 +26,8 @@ class CFilterCoder:
#endif
#ifndef EXTRACT_ONLY
public ICompressWriteCoderProperties,
// public ICryptoResetSalt,
public ICryptoResetInitVector,
#endif
public ICompressSetDecoderProperties2,
public CMyUnknownImp
@@ -53,6 +55,8 @@ protected:
CMyComPtr<ICryptoSetPassword> _setPassword;
#ifndef EXTRACT_ONLY
CMyComPtr<ICompressWriteCoderProperties> _writeCoderProperties;
// CMyComPtr<ICryptoResetSalt> _CryptoResetSalt;
CMyComPtr<ICryptoResetInitVector> _CryptoResetInitVector;
#endif
CMyComPtr<ICompressSetDecoderProperties2> _setDecoderProperties;
public:
@@ -82,6 +86,8 @@ public:
#ifndef EXTRACT_ONLY
MY_QUERYINTERFACE_ENTRY_AG(ICompressWriteCoderProperties, Filter, _writeCoderProperties)
// MY_QUERYINTERFACE_ENTRY_AG(ICryptoResetSalt, Filter, _CryptoResetSalt)
MY_QUERYINTERFACE_ENTRY_AG(ICryptoResetInitVector, Filter, _CryptoResetInitVector)
#endif
MY_QUERYINTERFACE_ENTRY_AG(ICompressSetDecoderProperties2, Filter, _setDecoderProperties)
@@ -105,6 +111,8 @@ public:
#endif
#ifndef EXTRACT_ONLY
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
// STDMETHOD(ResetSalt)();
STDMETHOD(ResetInitVector)();
#endif
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
};

View File

@@ -5,13 +5,12 @@
#include "../IStream.h"
#include "../../Common/MyCom.h"
#include "../../Common/MyException.h"
#ifndef _NO_EXCEPTIONS
class CInBufferException
struct CInBufferException: public CSystemException
{
public:
HRESULT ErrorCode;
CInBufferException(HRESULT errorCode): ErrorCode(errorCode) {}
CInBufferException(HRESULT errorCode): CSystemException(errorCode) {}
};
#endif

View File

@@ -9,7 +9,7 @@ extern "C"
}
#include "Common/Types.h"
#include "Common/Vector.h"
#include "Common/MyVector.h"
#include "Windows/Synchronization.h"

View File

@@ -3,7 +3,7 @@
#include "StdAfx.h"
#include "MethodId.h"
#include "../../Common/String.h"
#include "../../Common/MyString.h"
static inline wchar_t GetHex(Byte value)
{

96
CPP/7zip/Common/MethodProps.cpp Executable file
View File

@@ -0,0 +1,96 @@
// MethodProps.cpp
#include "StdAfx.h"
#include "MethodProps.h"
#include "../../Common/MyCom.h"
static UInt64 k_LZMA = 0x030101;
// static UInt64 k_LZMA2 = 0x030102;
HRESULT SetMethodProperties(const CMethod &method, const UInt64 *inSizeForReduce, IUnknown *coder)
{
bool tryReduce = false;
UInt32 reducedDictionarySize = 1 << 10;
if (inSizeForReduce != 0 && (method.Id == k_LZMA /* || methodFull.MethodID == k_LZMA2 */))
{
for (;;)
{
const UInt32 step = (reducedDictionarySize >> 1);
if (reducedDictionarySize >= *inSizeForReduce)
{
tryReduce = true;
break;
}
reducedDictionarySize += step;
if (reducedDictionarySize >= *inSizeForReduce)
{
tryReduce = true;
break;
}
if (reducedDictionarySize >= ((UInt32)3 << 30))
break;
reducedDictionarySize += step;
}
}
{
int numProperties = method.Properties.Size();
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
coder->QueryInterface(IID_ICompressSetCoderProperties, (void **)&setCoderProperties);
if (setCoderProperties == NULL)
{
if (numProperties != 0)
return E_INVALIDARG;
}
else
{
CRecordVector<PROPID> propIDs;
NWindows::NCOM::CPropVariant *values = new NWindows::NCOM::CPropVariant[numProperties];
HRESULT res = S_OK;
try
{
for (int i = 0; i < numProperties; i++)
{
const CProp &prop = method.Properties[i];
propIDs.Add(prop.Id);
NWindows::NCOM::CPropVariant &value = values[i];
value = prop.Value;
// if (tryReduce && prop.Id == NCoderPropID::kDictionarySize && value.vt == VT_UI4 && reducedDictionarySize < value.ulVal)
if (tryReduce)
if (prop.Id == NCoderPropID::kDictionarySize)
if (value.vt == VT_UI4)
if (reducedDictionarySize < value.ulVal)
value.ulVal = reducedDictionarySize;
}
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
coder->QueryInterface(IID_ICompressSetCoderProperties, (void **)&setCoderProperties);
res = setCoderProperties->SetCoderProperties(&propIDs.Front(), values, numProperties);
}
catch(...)
{
delete []values;
throw;
}
delete []values;
RINOK(res);
}
}
/*
CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
coder->QueryInterface(IID_ICompressWriteCoderProperties, (void **)&writeCoderProperties);
if (writeCoderProperties != NULL)
{
CSequentialOutStreamImp *outStreamSpec = new CSequentialOutStreamImp;
CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
outStreamSpec->Init();
RINOK(writeCoderProperties->WriteCoderProperties(outStream));
size_t size = outStreamSpec->GetSize();
filterProps.SetCapacity(size);
memmove(filterProps, outStreamSpec->GetBuffer(), size);
}
*/
return S_OK;
}

41
CPP/7zip/Common/MethodProps.h Executable file
View File

@@ -0,0 +1,41 @@
// MethodProps.h
#ifndef __7Z_METHOD_PROPS_H
#define __7Z_METHOD_PROPS_H
#include "MethodId.h"
#include "../../Windows/PropVariant.h"
#include "../../Common/MyVector.h"
#include "../ICoder.h"
struct CProp
{
PROPID Id;
NWindows::NCOM::CPropVariant Value;
};
struct CMethod
{
CMethodId Id;
CObjectVector<CProp> Properties;
};
struct CMethodsMode
{
CObjectVector<CMethod> Methods;
#ifdef COMPRESS_MT
UInt32 NumThreads;
#endif
CMethodsMode()
#ifdef COMPRESS_MT
: NumThreads(1)
#endif
{}
bool IsEmpty() const { return Methods.IsEmpty() ; }
};
HRESULT SetMethodProperties(const CMethod &method, const UInt64 *inSizeForReduce, IUnknown *coder);
#endif

View File

@@ -5,12 +5,12 @@
#include "../IStream.h"
#include "../../Common/MyCom.h"
#include "../../Common/MyException.h"
#ifndef _NO_EXCEPTIONS
struct COutBufferException
{
HRESULT ErrorCode;
COutBufferException(HRESULT errorCode): ErrorCode(errorCode) {}
struct COutBufferException: public CSystemException
{
COutBufferException(HRESULT errorCode): CSystemException(errorCode) {}
};
#endif
@@ -28,7 +28,6 @@ protected:
bool _overDict;
HRESULT FlushPart();
void FlushWithCheck();
public:
#ifdef _NO_EXCEPTIONS
HRESULT ErrorCode;
@@ -44,6 +43,7 @@ public:
void SetStream(ISequentialOutStream *stream);
void Init();
HRESULT Flush();
void FlushWithCheck();
void ReleaseStream() { _stream.Release(); }
void WriteByte(Byte b)

View File

@@ -4,13 +4,12 @@
#define __PROGRESSMT_H
#include "../../Common/MyCom.h"
#include "../../Common/MyVector.h"
#include "../../Windows/Synchronization.h"
#include "../ICoder.h"
#include "../IProgress.h"
#include "Windows/Synchronization.h"
#include "../../Common/Vector.h"
class CMtCompressProgressMixer
{
CMyComPtr<ICompressProgressInfo> _progress;

45
CPP/7zip/Common/VirtThread.cpp Executable file
View File

@@ -0,0 +1,45 @@
// VirtThread.cpp
#include "StdAfx.h"
#include "VirtThread.h"
static THREAD_FUNC_DECL CoderThread(void *p)
{
for (;;)
{
CVirtThread *t = (CVirtThread *)p;
t->StartEvent.Lock();
if (t->ExitEvent)
return 0;
t->Execute();
t->FinishedEvent.Set();
}
}
HRes CVirtThread::Create()
{
RINOK(StartEvent.CreateIfNotCreated());
RINOK(FinishedEvent.CreateIfNotCreated());
StartEvent.Reset();
FinishedEvent.Reset();
ExitEvent = false;
if (Thread.IsCreated())
return S_OK;
return Thread.Create(CoderThread, this);
}
void CVirtThread::Start()
{
ExitEvent = false;
StartEvent.Set();
}
CVirtThread::~CVirtThread()
{
ExitEvent = true;
if (StartEvent.IsCreated())
StartEvent.Set();
Thread.Wait();
}

23
CPP/7zip/Common/VirtThread.h Executable file
View File

@@ -0,0 +1,23 @@
// VirtThread.h
#ifndef __VIRTTHREAD_H
#define __VIRTTHREAD_H
#include "../../Windows/Synchronization.h"
#include "../../Windows/Thread.h"
struct CVirtThread
{
NWindows::NSynchronization::CAutoResetEvent StartEvent;
NWindows::NSynchronization::CAutoResetEvent FinishedEvent;
NWindows::CThread Thread;
bool ExitEvent;
~CVirtThread();
HRes Create();
void Start();
void WaitFinish() { FinishedEvent.Lock(); }
virtual void Execute() = 0;
};
#endif