mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 10:07:13 -06:00
3.13
This commit is contained in:
9
7zip/Compress/BZip2/BZip2.def
Executable file
9
7zip/Compress/BZip2/BZip2.def
Executable file
@@ -0,0 +1,9 @@
|
||||
; BZip2.def
|
||||
|
||||
LIBRARY BZip2.dll
|
||||
|
||||
EXPORTS
|
||||
CreateObject PRIVATE
|
||||
GetNumberOfMethods PRIVATE
|
||||
GetMethodProperty PRIVATE
|
||||
|
||||
297
7zip/Compress/BZip2/BZip2.dsp
Executable file
297
7zip/Compress/BZip2/BZip2.dsp
Executable file
@@ -0,0 +1,297 @@
|
||||
# Microsoft Developer Studio Project File - Name="BZip2" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=BZip2 - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "BZip2.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "BZip2.mak" CFG="BZip2 - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BZip2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "BZip2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /D "BZ_NO_STDIO" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Codecs\BZip2.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Codecs\BZip2.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "BZip2 - Win32 Release"
|
||||
# Name "BZip2 - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"StdAfx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Origianl"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\blocksort.c
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\bzlib.c
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\bzlib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\bzlib_private.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\compress.c
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\crctable.c
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\decompress.c
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\huffman.c
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\randtable.c
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Decoder.cpp
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Decoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Encoder.cpp
|
||||
|
||||
!IF "$(CFG)" == "BZip2 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Encoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BZip2Error.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
7zip/Compress/BZip2/BZip2.dsw
Executable file
29
7zip/Compress/BZip2/BZip2.dsw
Executable file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "BZip2"=.\BZip2.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
125
7zip/Compress/BZip2/BZip2Decoder.cpp
Executable file
125
7zip/Compress/BZip2/BZip2Decoder.cpp
Executable file
@@ -0,0 +1,125 @@
|
||||
// BZip2Decoder.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "BZip2Decoder.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "Original/bzlib.h"
|
||||
|
||||
namespace NCompress {
|
||||
namespace NBZip2 {
|
||||
|
||||
static const UINT32 kBufferSize = (1 << 20);
|
||||
|
||||
CDecoder::CDecoder()
|
||||
{
|
||||
m_InBuffer = new BYTE[kBufferSize];
|
||||
m_OutBuffer = new BYTE[kBufferSize];
|
||||
}
|
||||
|
||||
CDecoder::~CDecoder()
|
||||
{
|
||||
delete []m_OutBuffer;
|
||||
delete []m_InBuffer;
|
||||
}
|
||||
|
||||
struct CBZip2Decompressor: public bz_stream
|
||||
{
|
||||
// bz_stream m_Object;
|
||||
public:
|
||||
int Init(int verbosity, int small) { return BZ2_bzDecompressInit(this, verbosity, small); }
|
||||
int Decompress() { return BZ2_bzDecompress(this); }
|
||||
int End() { return BZ2_bzDecompressEnd(this); }
|
||||
UINT64 GetTotalIn() const { return (UINT64(total_in_hi32) << 32) + total_in_lo32; }
|
||||
UINT64 GetTotalOut() const { return (UINT64(total_out_hi32) << 32) + total_out_lo32; }
|
||||
};
|
||||
|
||||
class CBZip2DecompressorReleaser
|
||||
{
|
||||
CBZip2Decompressor *m_Decompressor;
|
||||
public:
|
||||
CBZip2DecompressorReleaser(CBZip2Decompressor *aDecompressor): m_Decompressor(aDecompressor) {}
|
||||
void Diable() { m_Decompressor = NULL; }
|
||||
~CBZip2DecompressorReleaser() { if (m_Decompressor != NULL) m_Decompressor->End(); }
|
||||
};
|
||||
|
||||
STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UINT64 *inSize, const UINT64 *outSize,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
CBZip2Decompressor bzStream;
|
||||
bzStream.bzalloc = NULL;
|
||||
bzStream.bzfree = NULL;
|
||||
bzStream.opaque = NULL;
|
||||
|
||||
|
||||
int result = bzStream.Init(0, 0);
|
||||
switch(result)
|
||||
{
|
||||
case BZ_OK:
|
||||
break;
|
||||
case BZ_MEM_ERROR:
|
||||
return E_OUTOFMEMORY;
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
CBZip2DecompressorReleaser releaser(&bzStream);
|
||||
bzStream.avail_in = 0;
|
||||
while (true)
|
||||
{
|
||||
if (bzStream.avail_in == 0)
|
||||
{
|
||||
bzStream.next_in = (char *)m_InBuffer;
|
||||
UINT32 processedSize;
|
||||
RINOK(inStream->Read(m_InBuffer, kBufferSize, &processedSize));
|
||||
bzStream.avail_in = processedSize;
|
||||
}
|
||||
|
||||
bzStream.next_out = (char *)m_OutBuffer;
|
||||
bzStream.avail_out = kBufferSize;
|
||||
result = bzStream.Decompress();
|
||||
UINT32 numBytesToWrite = kBufferSize - bzStream.avail_out;
|
||||
if (numBytesToWrite > 0)
|
||||
{
|
||||
UINT32 processedSize;
|
||||
RINOK(outStream->Write(m_OutBuffer, numBytesToWrite, &processedSize));
|
||||
if (numBytesToWrite != processedSize)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (result == BZ_STREAM_END)
|
||||
break;
|
||||
switch(result)
|
||||
{
|
||||
case BZ_DATA_ERROR:
|
||||
case BZ_DATA_ERROR_MAGIC:
|
||||
return S_FALSE;
|
||||
case BZ_OK:
|
||||
break;
|
||||
case BZ_MEM_ERROR:
|
||||
return E_OUTOFMEMORY;
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
if (progress != NULL)
|
||||
{
|
||||
UINT64 totalIn = bzStream.GetTotalIn();
|
||||
UINT64 totalOut = bzStream.GetTotalOut();
|
||||
RINOK(progress->SetRatioInfo(&totalIn, &totalOut));
|
||||
}
|
||||
}
|
||||
// result = bzStream.End();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UINT64 *inSize, const UINT64 *outSize,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
|
||||
catch(...) { return S_FALSE; }
|
||||
}
|
||||
|
||||
}}
|
||||
41
7zip/Compress/BZip2/BZip2Decoder.h
Executable file
41
7zip/Compress/BZip2/BZip2Decoder.h
Executable file
@@ -0,0 +1,41 @@
|
||||
// Compress/BZip2/Decoder.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __COMPRESS_BZIP2_DECODER_H
|
||||
#define __COMPRESS_BZIP2_DECODER_H
|
||||
|
||||
#include "../../ICoder.h"
|
||||
// #include "../../Interface/CompressInterface.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
namespace NCompress {
|
||||
namespace NBZip2 {
|
||||
|
||||
class CDecoder :
|
||||
public ICompressCoder,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
BYTE *m_InBuffer;
|
||||
BYTE *m_OutBuffer;
|
||||
public:
|
||||
CDecoder();
|
||||
~CDecoder();
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
HRESULT Flush();
|
||||
// void (ReleaseStreams)();
|
||||
|
||||
STDMETHOD(CodeReal)(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UINT64 *inSize, const UINT64 *outSize,
|
||||
ICompressProgressInfo *progress);
|
||||
|
||||
STDMETHOD(Code)(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UINT64 *inSize, const UINT64 *outSize,
|
||||
ICompressProgressInfo *progress);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
120
7zip/Compress/BZip2/BZip2Encoder.cpp
Executable file
120
7zip/Compress/BZip2/BZip2Encoder.cpp
Executable file
@@ -0,0 +1,120 @@
|
||||
// BZip2Encoder.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "BZip2Encoder.h"
|
||||
#include "Original/bzlib.h"
|
||||
|
||||
namespace NCompress {
|
||||
namespace NBZip2 {
|
||||
|
||||
static const UINT32 kBufferSize = (1 << 20);
|
||||
|
||||
CEncoder::CEncoder()
|
||||
{
|
||||
m_InBuffer = new BYTE[kBufferSize];
|
||||
m_OutBuffer = new BYTE[kBufferSize];
|
||||
}
|
||||
|
||||
CEncoder::~CEncoder()
|
||||
{
|
||||
delete []m_OutBuffer;
|
||||
delete []m_InBuffer;
|
||||
}
|
||||
|
||||
struct CBZip2Compressor: public bz_stream
|
||||
{
|
||||
public:
|
||||
int Init(int blockSize100k, int verbosity, int small)
|
||||
{ return BZ2_bzCompressInit(this, blockSize100k, verbosity, small); }
|
||||
int Compress(int action ) { return BZ2_bzCompress(this, action ); }
|
||||
int End() { return BZ2_bzCompressEnd(this); }
|
||||
UINT64 GetTotalIn() const { return (UINT64(total_in_hi32) << 32) + total_in_lo32; }
|
||||
UINT64 GetTotalOut() const { return (UINT64(total_out_hi32) << 32) + total_out_lo32; }
|
||||
};
|
||||
|
||||
class CBZip2CompressorReleaser
|
||||
{
|
||||
CBZip2Compressor *m_Compressor;
|
||||
public:
|
||||
CBZip2CompressorReleaser(CBZip2Compressor *compressor): m_Compressor(compressor) {}
|
||||
void Disable() { m_Compressor = NULL; }
|
||||
~CBZip2CompressorReleaser() { if (m_Compressor != NULL) m_Compressor->End(); }
|
||||
};
|
||||
|
||||
|
||||
STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UINT64 *inSize, const UINT64 *outSize,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
CBZip2Compressor bzStream;
|
||||
bzStream.bzalloc = NULL;
|
||||
bzStream.bzfree = NULL;
|
||||
bzStream.opaque = NULL;
|
||||
|
||||
int result = bzStream.Init(9, 0, 0);
|
||||
switch(result)
|
||||
{
|
||||
case BZ_OK:
|
||||
break;
|
||||
case BZ_MEM_ERROR:
|
||||
return E_OUTOFMEMORY;
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
CBZip2CompressorReleaser releaser(&bzStream);
|
||||
bzStream.avail_in = 0;
|
||||
while (true)
|
||||
{
|
||||
if (bzStream.avail_in == 0)
|
||||
{
|
||||
bzStream.next_in = (char *)m_InBuffer;
|
||||
UINT32 processedSize;
|
||||
RINOK(inStream->Read(m_InBuffer, kBufferSize, &processedSize));
|
||||
bzStream.avail_in = processedSize;
|
||||
}
|
||||
|
||||
bzStream.next_out = (char *)m_OutBuffer;
|
||||
bzStream.avail_out = kBufferSize;
|
||||
bool askFinish = (bzStream.avail_in == 0);
|
||||
result = bzStream.Compress(askFinish ? BZ_FINISH : BZ_RUN);
|
||||
UINT32 numBytesToWrite = kBufferSize - bzStream.avail_out;
|
||||
if (numBytesToWrite > 0)
|
||||
{
|
||||
UINT32 processedSize;
|
||||
RINOK(outStream->Write(m_OutBuffer, numBytesToWrite, &processedSize));
|
||||
if (numBytesToWrite != processedSize)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (result == BZ_STREAM_END)
|
||||
break;
|
||||
switch(result)
|
||||
{
|
||||
case BZ_RUN_OK:
|
||||
if (!askFinish)
|
||||
break;
|
||||
return E_FAIL;
|
||||
case BZ_FINISH_OK:
|
||||
if (askFinish)
|
||||
break;
|
||||
return E_FAIL;
|
||||
case BZ_MEM_ERROR:
|
||||
return E_OUTOFMEMORY;
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
if (progress != NULL)
|
||||
{
|
||||
UINT64 totalIn = bzStream.GetTotalIn();
|
||||
UINT64 totalOut = bzStream.GetTotalOut();
|
||||
RINOK(progress->SetRatioInfo(&totalIn, &totalOut));
|
||||
}
|
||||
}
|
||||
// result = bzStream.End();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
36
7zip/Compress/BZip2/BZip2Encoder.h
Executable file
36
7zip/Compress/BZip2/BZip2Encoder.h
Executable file
@@ -0,0 +1,36 @@
|
||||
// Compress/BZip2/Encoder.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __COMPRESS_BZIP2_ENCODER_H
|
||||
#define __COMPRESS_BZIP2_ENCODER_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
namespace NCompress {
|
||||
namespace NBZip2 {
|
||||
|
||||
class CEncoder :
|
||||
public ICompressCoder,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
BYTE *m_InBuffer;
|
||||
BYTE *m_OutBuffer;
|
||||
|
||||
public:
|
||||
CEncoder();
|
||||
~CEncoder();
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
// STDMETHOD(ReleaseStreams)();
|
||||
|
||||
STDMETHOD(Code)(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UINT64 *inSize, const UINT64 *outSize,
|
||||
ICompressProgressInfo *progress);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
10
7zip/Compress/BZip2/BZip2Error.cpp
Executable file
10
7zip/Compress/BZip2/BZip2Error.cpp
Executable file
@@ -0,0 +1,10 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Original/bzlib.h"
|
||||
|
||||
extern "C"
|
||||
|
||||
void bz_internal_error (int errcode)
|
||||
{
|
||||
throw "error";
|
||||
}
|
||||
86
7zip/Compress/BZip2/DllExports.cpp
Executable file
86
7zip/Compress/BZip2/DllExports.cpp
Executable file
@@ -0,0 +1,86 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#define INITGUID
|
||||
|
||||
#include "BZip2Encoder.h"
|
||||
#include "BZip2Decoder.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
// {23170F69-40C1-278B-0402-020000000000}
|
||||
DEFINE_GUID(CLSID_CCompressBZip2Decoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
// {23170F69-40C1-278B-0402-020000000100}
|
||||
DEFINE_GUID(CLSID_CCompressBZip2Encoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00);
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
int correctInterface = (*iid == IID_ICompressCoder);
|
||||
CMyComPtr<ICompressCoder> coder;
|
||||
if (*clsid == CLSID_CCompressBZip2Decoder)
|
||||
{
|
||||
if (!correctInterface)
|
||||
return E_NOINTERFACE;
|
||||
coder = (ICompressCoder *)new NCompress::NBZip2::CDecoder;
|
||||
}
|
||||
else if (*clsid == CLSID_CCompressBZip2Encoder)
|
||||
{
|
||||
if (!correctInterface)
|
||||
return E_NOINTERFACE;
|
||||
coder = (ICompressCoder *)new NCompress::NBZip2::CEncoder;
|
||||
}
|
||||
else
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
*outObject = coder.Detach();
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetNumberOfMethods(UINT32 *numMethods)
|
||||
{
|
||||
*numMethods = 1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
if (index != 0)
|
||||
return E_INVALIDARG;
|
||||
::VariantClear((tagVARIANT *)value);
|
||||
switch(propID)
|
||||
{
|
||||
case NMethodPropID::kID:
|
||||
{
|
||||
const char id[] = { 0x04, 0x02, 0x02 };
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NMethodPropID::kName:
|
||||
if ((value->bstrVal = ::SysAllocString(L"BZip2")) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
case NMethodPropID::kDecoder:
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CCompressBZip2Decoder, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
case NMethodPropID::kEncoder:
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CCompressBZip2Encoder, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
3
7zip/Compress/BZip2/StdAfx.cpp
Executable file
3
7zip/Compress/BZip2/StdAfx.cpp
Executable file
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "stdafx.h"
|
||||
8
7zip/Compress/BZip2/StdAfx.h
Executable file
8
7zip/Compress/BZip2/StdAfx.h
Executable file
@@ -0,0 +1,8 @@
|
||||
// stdafx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#endif
|
||||
15
7zip/Compress/BZip2/resource.h
Executable file
15
7zip/Compress/BZip2/resource.h
Executable file
@@ -0,0 +1,15 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by resource.rc
|
||||
//
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
121
7zip/Compress/BZip2/resource.rc
Executable file
121
7zip/Compress/BZip2/resource.rc
Executable file
@@ -0,0 +1,121 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Russian resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
|
||||
#pragma code_page(1251)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Russian resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,8,1,0
|
||||
PRODUCTVERSION 3,8,1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", " \0"
|
||||
VALUE "FileDescription", "BZip2 Coder\0"
|
||||
VALUE "FileVersion", "3, 8, 1, 0\0"
|
||||
VALUE "InternalName", "BZip2\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2003 Igor Pavlov\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "BZip2.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "7-Zip\0"
|
||||
VALUE "ProductVersion", "3, 8, 1, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
Reference in New Issue
Block a user