- First LZMA enhanced NSIS version - experimental
- Added SetCompressorDictSize (only works for LZMA) - Added SetCompressionLevel (only "works" for zlib and bzip2) - doesn't work for now - Section is only supposed to get 4 parameters if /o is specified - Updated version numbers git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3190 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
320cefa4b0
commit
594c3ed0f6
84 changed files with 8083 additions and 41 deletions
41
Source/7zip/7zip/Common/InBuffer.cpp
Normal file
41
Source/7zip/7zip/Common/InBuffer.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
// InBuffer.cpp
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "InBuffer.h"
|
||||
|
||||
CInBuffer::CInBuffer(UINT32 bufferSize):
|
||||
_bufferSize(bufferSize),
|
||||
_bufferBase(0)
|
||||
{
|
||||
_bufferBase = new BYTE[_bufferSize];
|
||||
}
|
||||
|
||||
CInBuffer::~CInBuffer()
|
||||
{
|
||||
delete []_bufferBase;
|
||||
}
|
||||
|
||||
void CInBuffer::Init(ISequentialInStream *stream)
|
||||
{
|
||||
_stream = stream;
|
||||
_processedSize = 0;
|
||||
_buffer = _bufferBase;
|
||||
_bufferLimit = _buffer;
|
||||
_streamWasExhausted = false;
|
||||
}
|
||||
|
||||
bool CInBuffer::ReadBlock()
|
||||
{
|
||||
if (_streamWasExhausted)
|
||||
return false;
|
||||
_processedSize += (_buffer - _bufferBase);
|
||||
UINT32 numProcessedBytes;
|
||||
HRESULT result = _stream->ReadPart(_bufferBase, _bufferSize, &numProcessedBytes);
|
||||
if (result != S_OK)
|
||||
throw CInBufferException(result);
|
||||
_buffer = _bufferBase;
|
||||
_bufferLimit = _buffer + numProcessedBytes;
|
||||
_streamWasExhausted = (numProcessedBytes == 0);
|
||||
return (!_streamWasExhausted);
|
||||
}
|
69
Source/7zip/7zip/Common/InBuffer.h
Normal file
69
Source/7zip/7zip/Common/InBuffer.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
// InBuffer.h
|
||||
|
||||
// #pragma once
|
||||
|
||||
#ifndef __INBUFFER_H
|
||||
#define __INBUFFER_H
|
||||
|
||||
#include "../IStream.h"
|
||||
|
||||
class CInBufferException
|
||||
{
|
||||
public:
|
||||
HRESULT ErrorCode;
|
||||
CInBufferException(HRESULT errorCode): ErrorCode(errorCode) {}
|
||||
};
|
||||
|
||||
class CInBuffer
|
||||
{
|
||||
UINT64 _processedSize;
|
||||
BYTE *_bufferBase;
|
||||
UINT32 _bufferSize;
|
||||
BYTE *_buffer;
|
||||
BYTE *_bufferLimit;
|
||||
ISequentialInStream *_stream;
|
||||
bool _streamWasExhausted;
|
||||
|
||||
bool ReadBlock();
|
||||
|
||||
public:
|
||||
CInBuffer(UINT32 bufferSize = 0x100000);
|
||||
~CInBuffer();
|
||||
|
||||
void Init(ISequentialInStream *stream);
|
||||
/*
|
||||
void ReleaseStream()
|
||||
{ _stream.Release(); }
|
||||
*/
|
||||
|
||||
bool ReadByte(BYTE &b)
|
||||
{
|
||||
if(_buffer >= _bufferLimit)
|
||||
if(!ReadBlock())
|
||||
return false;
|
||||
b = *_buffer++;
|
||||
return true;
|
||||
}
|
||||
BYTE ReadByte()
|
||||
{
|
||||
if(_buffer >= _bufferLimit)
|
||||
if(!ReadBlock())
|
||||
return 0x0;
|
||||
return *_buffer++;
|
||||
}
|
||||
void ReadBytes(void *data, UINT32 size, UINT32 &processedSize)
|
||||
{
|
||||
for(processedSize = 0; processedSize < size; processedSize++)
|
||||
if (!ReadByte(((BYTE *)data)[processedSize]))
|
||||
return;
|
||||
}
|
||||
bool ReadBytes(void *data, UINT32 size)
|
||||
{
|
||||
UINT32 processedSize;
|
||||
ReadBytes(data, size, processedSize);
|
||||
return (processedSize == size);
|
||||
}
|
||||
UINT64 GetProcessedSize() const { return _processedSize + (_buffer - _bufferBase); }
|
||||
};
|
||||
|
||||
#endif
|
53
Source/7zip/7zip/Common/OutBuffer.cpp
Normal file
53
Source/7zip/7zip/Common/OutBuffer.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Stream/OutByte.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "OutBuffer.h"
|
||||
|
||||
COutBuffer::COutBuffer(UINT32 bufferSize):
|
||||
_bufferSize(bufferSize)
|
||||
{
|
||||
_buffer = new BYTE[_bufferSize];
|
||||
}
|
||||
|
||||
COutBuffer::~COutBuffer()
|
||||
{
|
||||
delete []_buffer;
|
||||
}
|
||||
|
||||
void COutBuffer::Init(ISequentialOutStream *stream)
|
||||
{
|
||||
_stream = stream;
|
||||
_processedSize = 0;
|
||||
_pos = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
void COutBuffer::ReleaseStream()
|
||||
{
|
||||
_stream.Release();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
HRESULT COutBuffer::Flush()
|
||||
{
|
||||
if (_pos == 0)
|
||||
return S_OK;
|
||||
UINT32 processedSize;
|
||||
HRESULT result = _stream->Write(_buffer, _pos, &processedSize);
|
||||
if (result != S_OK)
|
||||
return result;
|
||||
if (_pos != processedSize)
|
||||
return E_FAIL;
|
||||
_processedSize += processedSize;
|
||||
_pos = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void COutBuffer::WriteBlock()
|
||||
{
|
||||
HRESULT result = Flush();
|
||||
if (result != S_OK)
|
||||
throw COutBufferException(result);
|
||||
}
|
49
Source/7zip/7zip/Common/OutBuffer.h
Normal file
49
Source/7zip/7zip/Common/OutBuffer.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
// OutBuffer.h
|
||||
|
||||
// #pragma once
|
||||
|
||||
#ifndef __OUTBUFFER_H
|
||||
#define __OUTBUFFER_H
|
||||
|
||||
#include "../IStream.h"
|
||||
|
||||
class COutBufferException
|
||||
{
|
||||
public:
|
||||
HRESULT ErrorCode;
|
||||
COutBufferException(HRESULT errorCode): ErrorCode(errorCode) {}
|
||||
};
|
||||
|
||||
class COutBuffer
|
||||
{
|
||||
BYTE *_buffer;
|
||||
UINT32 _pos;
|
||||
UINT32 _bufferSize;
|
||||
ISequentialOutStream *_stream;
|
||||
UINT64 _processedSize;
|
||||
|
||||
void WriteBlock();
|
||||
public:
|
||||
COutBuffer(UINT32 bufferSize = (1 << 20));
|
||||
~COutBuffer();
|
||||
|
||||
void Init(ISequentialOutStream *stream);
|
||||
HRESULT Flush();
|
||||
// void ReleaseStream();
|
||||
|
||||
void WriteByte(BYTE b)
|
||||
{
|
||||
_buffer[_pos++] = b;
|
||||
if(_pos >= _bufferSize)
|
||||
WriteBlock();
|
||||
}
|
||||
void WriteBytes(const void *data, UINT32 size)
|
||||
{
|
||||
for (UINT32 i = 0; i < size; i++)
|
||||
WriteByte(((const BYTE *)data)[i]);
|
||||
}
|
||||
|
||||
UINT64 GetProcessedSize() const { return _processedSize + _pos; }
|
||||
};
|
||||
|
||||
#endif
|
8
Source/7zip/7zip/Common/StdAfx.h
Normal file
8
Source/7zip/7zip/Common/StdAfx.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
// stdafx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue