mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-09 12:07:07 -06:00
4.20
This commit is contained in:
committed by
Kornel Lesiński
parent
8c1b5c7b7e
commit
3c510ba80b
@@ -1,78 +1,72 @@
|
||||
// LZOutWindow.h
|
||||
|
||||
// #pragma once
|
||||
|
||||
#ifndef __LZ_OUT_WINDOW_H
|
||||
#define __LZ_OUT_WINDOW_H
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
// m_KeepSizeBefore: how mach BYTEs must be in buffer before _pos;
|
||||
// m_KeepSizeAfter: how mach BYTEs must be in buffer after _pos;
|
||||
// m_KeepSizeReserv: how mach BYTEs must be in buffer for Moving Reserv;
|
||||
// must be >= aKeepSizeAfter; // test it
|
||||
|
||||
#ifndef _NO_EXCEPTIONS
|
||||
class CLZOutWindowException
|
||||
{
|
||||
public:
|
||||
HRESULT ErrorCode;
|
||||
CLZOutWindowException(HRESULT errorCode): ErrorCode(errorCode) {}
|
||||
};
|
||||
#endif
|
||||
|
||||
class CLZOutWindow
|
||||
{
|
||||
BYTE *_buffer;
|
||||
UINT32 _pos;
|
||||
UINT32 _windowSize;
|
||||
UINT32 _streamPos;
|
||||
Byte *_buffer;
|
||||
UInt32 _pos;
|
||||
UInt32 _windowSize;
|
||||
UInt32 _streamPos;
|
||||
ISequentialOutStream *_stream;
|
||||
void FlushWithCheck();
|
||||
|
||||
public:
|
||||
#ifdef _NO_EXCEPTIONS
|
||||
HRESULT ErrorCode;
|
||||
#endif
|
||||
|
||||
void Free();
|
||||
CLZOutWindow(): _buffer(0), _stream(0) {}
|
||||
~CLZOutWindow();
|
||||
void Create(UINT32 windowSize);
|
||||
bool IsCreated() const { return _buffer != 0; }
|
||||
|
||||
void Init(ISequentialOutStream *stream, bool solid = false);
|
||||
HRESULT Flush();
|
||||
// void ReleaseStream();
|
||||
~CLZOutWindow() { Free(); /* ReleaseStream(); */ }
|
||||
bool Create(UInt32 windowSize);
|
||||
|
||||
// UINT32 GetCurPos() const { return _pos; }
|
||||
// const BYTE *GetPointerToCurrentPos() const { return _buffer + _pos;};
|
||||
|
||||
void CopyBackBlock(UINT32 distance, UINT32 len)
|
||||
void SetStream(ISequentialOutStream *stream);
|
||||
void Init(bool solid = false);
|
||||
HRESULT Flush();
|
||||
void ReleaseStream();
|
||||
|
||||
void CopyBlock(UInt32 distance, UInt32 len)
|
||||
{
|
||||
UINT32 pos = _pos - distance - 1;
|
||||
if (pos >= _windowSize)
|
||||
pos += _windowSize;
|
||||
for(; len > 0; len--)
|
||||
{
|
||||
if (pos >= _windowSize)
|
||||
pos = 0;
|
||||
_buffer[_pos++] = _buffer[pos++];
|
||||
if (_pos >= _windowSize)
|
||||
FlushWithCheck();
|
||||
// PutOneByte(GetOneByte(0 - distance));
|
||||
}
|
||||
UInt32 pos = _pos - distance - 1;
|
||||
if (pos >= _windowSize)
|
||||
pos += _windowSize;
|
||||
for(; len > 0; len--)
|
||||
{
|
||||
if (pos >= _windowSize)
|
||||
pos = 0;
|
||||
_buffer[_pos++] = _buffer[pos++];
|
||||
if (_pos >= _windowSize)
|
||||
FlushWithCheck();
|
||||
// PutOneByte(GetOneByte(distance));
|
||||
}
|
||||
}
|
||||
|
||||
void PutOneByte(BYTE b)
|
||||
|
||||
void PutByte(Byte b)
|
||||
{
|
||||
_buffer[_pos++] = b;
|
||||
if (_pos >= _windowSize)
|
||||
FlushWithCheck();
|
||||
_buffer[_pos++] = b;
|
||||
if (_pos >= _windowSize)
|
||||
FlushWithCheck();
|
||||
}
|
||||
|
||||
BYTE GetOneByte(UINT32 index) const
|
||||
|
||||
Byte GetByte(UInt32 distance) const
|
||||
{
|
||||
UINT32 pos = _pos + index;
|
||||
if (pos >= _windowSize)
|
||||
pos += _windowSize;
|
||||
return _buffer[pos];
|
||||
UInt32 pos = _pos - distance - 1;
|
||||
if (pos >= _windowSize)
|
||||
pos += _windowSize;
|
||||
return _buffer[pos];
|
||||
}
|
||||
|
||||
// BYTE *GetBuffer() const { return _buffer; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user