9.09 beta

This commit is contained in:
Igor Pavlov
2009-12-14 00:00:00 +00:00
committed by Kornel Lesiński
parent 2fed872194
commit 1fbaf0aac5
179 changed files with 3365 additions and 2136 deletions

View File

@@ -2,10 +2,11 @@
#include "StdAfx.h"
#include "../../Windows/Defs.h"
#include "../../Windows/PropVariant.h"
#include "CreateCoder.h"
#include "../../Windows/PropVariant.h"
#include "../../Windows/Defs.h"
#include "FilterCoder.h"
#include "RegisterCodec.h"

View File

@@ -1,10 +1,10 @@
// CreateCoder.h
#ifndef __CREATECODER_H
#define __CREATECODER_H
#ifndef __CREATE_CODER_H
#define __CREATE_CODER_H
#include "Common/MyCom.h"
#include "Common/MyString.h"
#include "../../Common/MyCom.h"
#include "../../Common/MyString.h"
#include "../ICoder.h"
#include "MethodId.h"

View File

@@ -14,6 +14,8 @@ static const UInt32 kBufferSize = 1 << 17;
CFilterCoder::CFilterCoder()
{
_buffer = (Byte *)::MidAlloc(kBufferSize);
if (_buffer == 0)
throw 1;
}
CFilterCoder::~CFilterCoder()
@@ -34,10 +36,8 @@ HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 siz
return S_OK;
}
STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
{
RINOK(Init());
UInt32 bufferPos = 0;
@@ -45,7 +45,7 @@ STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
if (_outSizeIsDefined)
_outSize = *outSize;
while(NeedMore())
while (!_outSizeIsDefined || _nowPos64 < _outSize)
{
size_t processedSize = kBufferSize - bufferPos;
@@ -57,16 +57,16 @@ STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
bufferPos = Filter->Filter(_buffer, endPos);
if (bufferPos > endPos)
{
for (; endPos< bufferPos; endPos++)
for (; endPos < bufferPos; endPos++)
_buffer[endPos] = 0;
bufferPos = Filter->Filter(_buffer, endPos);
}
if (bufferPos == 0)
{
if (endPos > 0)
return WriteWithLimit(outStream, endPos);
return S_OK;
if (endPos == 0)
return S_OK;
return WriteWithLimit(outStream, endPos);
}
RINOK(WriteWithLimit(outStream, bufferPos));
if (progress != NULL)
@@ -74,14 +74,13 @@ STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
RINOK(progress->SetRatioInfo(&_nowPos64, &_nowPos64));
}
UInt32 i = 0;
while(bufferPos < endPos)
while (bufferPos < endPos)
_buffer[i++] = _buffer[bufferPos++];
bufferPos = i;
}
return S_OK;
}
// #ifdef _ST_MODE
STDMETHODIMP CFilterCoder::SetOutStream(ISequentialOutStream *outStream)
{
_bufferPos = 0;
@@ -98,16 +97,15 @@ STDMETHODIMP CFilterCoder::ReleaseOutStream()
STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processedSize)
{
UInt32 processedSizeTotal = 0;
while(size > 0)
if (processedSize != NULL)
*processedSize = 0;
while (size > 0)
{
UInt32 sizeMax = kBufferSize - _bufferPos;
UInt32 sizeTemp = size;
if (sizeTemp > sizeMax)
sizeTemp = sizeMax;
memmove(_buffer + _bufferPos, data, sizeTemp);
UInt32 sizeTemp = MyMin(size, kBufferSize - _bufferPos);
memcpy(_buffer + _bufferPos, data, sizeTemp);
size -= sizeTemp;
processedSizeTotal += sizeTemp;
if (processedSize != NULL)
*processedSize += sizeTemp;
data = (const Byte *)data + sizeTemp;
UInt32 endPos = _bufferPos + sizeTemp;
_bufferPos = Filter->Filter(_buffer, endPos);
@@ -124,12 +122,10 @@ STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processe
}
RINOK(WriteWithLimit(_outStream, _bufferPos));
UInt32 i = 0;
while(_bufferPos < endPos)
while (_bufferPos < endPos)
_buffer[i++] = _buffer[_bufferPos++];
_bufferPos = i;
}
if (processedSize != NULL)
*processedSize = processedSizeTotal;
return S_OK;
}
@@ -137,6 +133,7 @@ STDMETHODIMP CFilterCoder::Flush()
{
if (_bufferPos != 0)
{
// _buffer contains only data refused by previous Filter->Filter call.
UInt32 endPos = Filter->Filter(_buffer, _bufferPos);
if (endPos > _bufferPos)
{
@@ -145,13 +142,13 @@ STDMETHODIMP CFilterCoder::Flush()
if (Filter->Filter(_buffer, endPos) != endPos)
return E_FAIL;
}
RINOK(WriteStream(_outStream, _buffer, _bufferPos));
RINOK(WriteWithLimit(_outStream, _bufferPos));
_bufferPos = 0;
}
CMyComPtr<IOutStreamFlush> flush;
_outStream.QueryInterface(IID_IOutStreamFlush, &flush);
if (flush)
return flush->Flush();
return flush->Flush();
return S_OK;
}
@@ -171,37 +168,36 @@ STDMETHODIMP CFilterCoder::ReleaseInStream()
STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
{
UInt32 processedSizeTotal = 0;
while(size > 0)
if (processedSize != NULL)
*processedSize = 0;
while (size > 0)
{
if (_convertedPosBegin != _convertedPosEnd)
{
UInt32 sizeTemp = MyMin(size, _convertedPosEnd - _convertedPosBegin);
memmove(data, _buffer + _convertedPosBegin, sizeTemp);
memcpy(data, _buffer + _convertedPosBegin, sizeTemp);
_convertedPosBegin += sizeTemp;
data = (void *)((Byte *)data + sizeTemp);
size -= sizeTemp;
processedSizeTotal += sizeTemp;
if (processedSize != NULL)
*processedSize += sizeTemp;
break;
}
int i;
UInt32 i;
for (i = 0; _convertedPosEnd + i < _bufferPos; i++)
_buffer[i] = _buffer[i + _convertedPosEnd];
_buffer[i] = _buffer[_convertedPosEnd + i];
_bufferPos = i;
_convertedPosBegin = _convertedPosEnd = 0;
size_t processedSizeTemp = kBufferSize - _bufferPos;
RINOK(ReadStream(_inStream, _buffer + _bufferPos, &processedSizeTemp));
_bufferPos = _bufferPos + (UInt32)processedSizeTemp;
_bufferPos += (UInt32)processedSizeTemp;
_convertedPosEnd = Filter->Filter(_buffer, _bufferPos);
if (_convertedPosEnd == 0)
{
if (_bufferPos == 0)
break;
else
{
_convertedPosEnd = _bufferPos; // check it
continue;
}
_convertedPosEnd = _bufferPos; // check it
continue;
}
if (_convertedPosEnd > _bufferPos)
{
@@ -210,13 +206,9 @@ STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
_convertedPosEnd = Filter->Filter(_buffer, _bufferPos);
}
}
if (processedSize != NULL)
*processedSize = processedSizeTotal;
return S_OK;
}
// #endif // _ST_MODE
#ifndef _NO_CRYPTO
STDMETHODIMP CFilterCoder::CryptoSetPassword(const Byte *data, UInt32 size)
{

View File

@@ -1,7 +1,7 @@
// FilterCoder.h
#ifndef __FILTERCODER_H
#define __FILTERCODER_H
#ifndef __FILTER_CODER_H
#define __FILTER_CODER_H
#include "../../Common/MyCom.h"
#include "../ICoder.h"
@@ -13,13 +13,11 @@
class CFilterCoder:
public ICompressCoder,
// #ifdef _ST_MODE
public ICompressSetInStream,
public ISequentialInStream,
public ICompressSetOutStream,
public ISequentialOutStream,
public IOutStreamFlush,
// #endif
#ifndef _NO_CRYPTO
public ICryptoSetPassword,
@@ -35,13 +33,11 @@ class CFilterCoder:
{
protected:
Byte *_buffer;
// #ifdef _ST_MODE
CMyComPtr<ISequentialInStream> _inStream;
CMyComPtr<ISequentialOutStream> _outStream;
UInt32 _bufferPos;
UInt32 _convertedPosBegin;
UInt32 _convertedPosEnd;
// #endif
bool _outSizeIsDefined;
UInt64 _outSize;
UInt64 _nowPos64;
@@ -67,20 +63,14 @@ public:
CFilterCoder();
~CFilterCoder();
HRESULT WriteWithLimit(ISequentialOutStream *outStream, UInt32 size);
bool NeedMore() const
{ return (!_outSizeIsDefined || (_nowPos64 < _outSize)); }
public:
MY_QUERYINTERFACE_BEGIN
MY_QUERYINTERFACE_ENTRY(ICompressCoder)
// #ifdef _ST_MODE
MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
MY_QUERYINTERFACE_ENTRY(ISequentialInStream)
MY_QUERYINTERFACE_ENTRY(ICompressSetOutStream)
MY_QUERYINTERFACE_ENTRY(ISequentialOutStream)
MY_QUERYINTERFACE_ENTRY(IOutStreamFlush)
// #endif
#ifndef _NO_CRYPTO
MY_QUERYINTERFACE_ENTRY_AG(ICryptoSetPassword, Filter, _setPassword)
@@ -96,10 +86,8 @@ public:
MY_QUERYINTERFACE_ENTRY_AG(ICompressSetDecoderProperties2, Filter, _setDecoderProperties)
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
// #ifdef _ST_MODE
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(ReleaseInStream)();
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); \
@@ -107,7 +95,6 @@ public:
STDMETHOD(ReleaseOutStream)();
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Flush)();
// #endif
#ifndef _NO_CRYPTO
STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
@@ -122,7 +109,6 @@ public:
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
};
// #ifdef _ST_MODE
class CInStreamReleaser
{
public:
@@ -138,6 +124,5 @@ public:
COutStreamReleaser(): FilterCoder(0) {}
~COutStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseOutStream(); }
};
// #endif
#endif

View File

@@ -24,12 +24,12 @@ struct CMethod
struct CMethodsMode
{
CObjectVector<CMethod> Methods;
#ifdef COMPRESS_MT
#ifndef _7ZIP_ST
UInt32 NumThreads;
#endif
CMethodsMode()
#ifdef COMPRESS_MT
#ifndef _7ZIP_ST
: NumThreads(1)
#endif
{}

View File

@@ -1,7 +1,7 @@
// RegisterArc.h
#ifndef __REGISTERARC_H
#define __REGISTERARC_H
#ifndef __REGISTER_ARC_H
#define __REGISTER_ARC_H
#include "../Archive/IArchive.h"
@@ -25,10 +25,6 @@ void RegisterArc(const CArcInfo *arcInfo);
#define REGISTER_ARC_NAME(x) CRegister ## x
#define REGISTER_ARC_DEC_SIG(x) struct REGISTER_ARC_NAME(x) { \
REGISTER_ARC_NAME(x)() { g_ArcInfo.Signature[0]--; RegisterArc(&g_ArcInfo); }}; \
static REGISTER_ARC_NAME(x) g_RegisterArc;
#define REGISTER_ARC(x) struct REGISTER_ARC_NAME(x) { \
REGISTER_ARC_NAME(x)() { RegisterArc(&g_ArcInfo); }}; \
static REGISTER_ARC_NAME(x) g_RegisterArc;