mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 20:07:19 -06:00
4.45 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
d9666cf046
commit
a145bfc7cf
@@ -1,125 +0,0 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "../../ICoder.h"
|
||||
#include "GZipHandler.h"
|
||||
|
||||
// {23170F69-40C1-278A-1000-000110EF0000}
|
||||
DEFINE_GUID(CLSID_CGZipHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEF, 0x00, 0x00);
|
||||
|
||||
// {23170F69-40C1-278B-0401-080000000100}
|
||||
DEFINE_GUID(CLSID_CCompressDeflateEncoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00);
|
||||
|
||||
// {23170F69-40C1-278B-0401-080000000000}
|
||||
DEFINE_GUID(CLSID_CCompressDeflateDecoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COMPRESS_DEFLATE
|
||||
#include "../Common/CodecsPath.h"
|
||||
CSysString GetDeflateCodecPath()
|
||||
{
|
||||
return GetCodecsFolderPrefix() + TEXT("Deflate.dll");
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != CLSID_CGZipHandler)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
int needIn = *interfaceID == IID_IInArchive;
|
||||
int needOut = *interfaceID == IID_IOutArchive;
|
||||
if (needIn || needOut)
|
||||
{
|
||||
NArchive::NGZip::CHandler *temp = new NArchive::NGZip::CHandler;
|
||||
if (needIn)
|
||||
{
|
||||
CMyComPtr<IInArchive> inArchive = (IInArchive *)temp;
|
||||
*outObject = inArchive.Detach();
|
||||
}
|
||||
else
|
||||
{
|
||||
CMyComPtr<IOutArchive> outArchive = (IOutArchive *)temp;
|
||||
*outObject = outArchive.Detach();
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_NOINTERFACE;
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case NArchive::kName:
|
||||
propVariant = L"GZip";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CGZipHandler, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"gz gzip tgz tpz";
|
||||
break;
|
||||
case NArchive::kAddExtension:
|
||||
propVariant = L"* * .tar .tar";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = true;
|
||||
break;
|
||||
case NArchive::kKeepName:
|
||||
propVariant = true;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
const unsigned char sig[] = { 0x1F, 0x8B };
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen((const char *)sig, 2)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1,321 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="GZip" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=GZip - 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 "GZip.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 "GZip.mak" CFG="GZip - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "GZip - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "GZip - 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)" == "GZip - 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 "GZIP_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GZIP_EXPORTS" /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\Formats\gz.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "GZip - 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 "GZIP_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GZIP_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\Formats\gz.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "GZip - Win32 Release"
|
||||
# Name "GZip - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZip.ico
|
||||
# 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 "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compression"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipHandlerOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipHeader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipHeader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipOut.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipUpdate.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GZipUpdate.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\InStreamWithCRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\InStreamWithCRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OutStreamWithCRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gz.ico
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "GZip"=.\GZip.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "GZipHandler.h"
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/CRC.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
@@ -13,23 +12,16 @@
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../Common/OutStreamWithCRC.h"
|
||||
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
#include "../../Compress/Deflate/DeflateDecoder.h"
|
||||
#else
|
||||
// {23170F69-40C1-278B-0401-080000000000}
|
||||
DEFINE_GUID(CLSID_CCompressDeflateDecoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
#include "../Common/CoderLoader.h"
|
||||
extern CSysString GetDeflateCodecPath();
|
||||
#endif
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
namespace NGZip {
|
||||
|
||||
static const CMethodId kMethodId_Deflate = 0x040108;
|
||||
|
||||
const wchar_t *kHostOS[] =
|
||||
{
|
||||
L"FAT",
|
||||
@@ -269,9 +261,6 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
new CLocalCompressProgressInfo;
|
||||
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
|
||||
|
||||
#ifndef COMPRESS_DEFLATE
|
||||
CCoderLibrary lib;
|
||||
#endif
|
||||
CMyComPtr<ICompressCoder> deflateDecoder;
|
||||
bool firstItem = true;
|
||||
RINOK(m_Stream->Seek(m_StreamStartPosition, STREAM_SEEK_SET, NULL));
|
||||
@@ -305,12 +294,15 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
{
|
||||
if(!deflateDecoder)
|
||||
{
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
deflateDecoder = new NCompress::NDeflate::NDecoder::CCOMCoder;
|
||||
#else
|
||||
RINOK(lib.LoadAndCreateCoder(GetDeflateCodecPath(),
|
||||
CLSID_CCompressDeflateDecoder, &deflateDecoder));
|
||||
#endif
|
||||
RINOK(CreateCoder(
|
||||
EXTERNAL_CODECS_VARS
|
||||
kMethodId_Deflate, deflateDecoder, false));
|
||||
if (!deflateDecoder)
|
||||
{
|
||||
outStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -358,4 +350,6 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
IMPL_ISetCompressCodecsInfo
|
||||
|
||||
}}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "../IArchive.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#include "GZipIn.h"
|
||||
#include "GZipUpdate.h"
|
||||
|
||||
@@ -17,13 +19,17 @@ class CHandler:
|
||||
public IInArchive,
|
||||
public IOutArchive,
|
||||
public ISetProperties,
|
||||
PUBLIC_ISetCompressCodecsInfo
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP3(
|
||||
IInArchive,
|
||||
IOutArchive,
|
||||
ISetProperties)
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
STDMETHOD(Open)(IInStream *inStream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
@@ -55,7 +61,8 @@ public:
|
||||
// ISetProperties
|
||||
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
|
||||
|
||||
public:
|
||||
DECL_ISetCompressCodecsInfo
|
||||
|
||||
CHandler() { InitMethodProperties(); }
|
||||
|
||||
private:
|
||||
@@ -67,6 +74,8 @@ private:
|
||||
CCompressionMethodMode m_Method;
|
||||
UInt32 m_Level;
|
||||
|
||||
DECL_EXTERNAL_CODECS_VARS
|
||||
|
||||
void InitMethodProperties()
|
||||
{
|
||||
m_Method.NumMatchFinderCyclesDefined = false;
|
||||
|
||||
@@ -138,7 +138,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
(level >= 7 ? kNumFastBytesX7 :
|
||||
kNumFastBytesX1));
|
||||
|
||||
return UpdateArchive(m_Stream, size, outStream, newItem, m_Method, itemIndex, updateCallback);
|
||||
return UpdateArchive(
|
||||
EXTERNAL_CODECS_VARS
|
||||
m_Stream, size, outStream, newItem, m_Method, itemIndex, updateCallback);
|
||||
}
|
||||
|
||||
if (indexInArchive != 0)
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/7zCrc.h"
|
||||
}
|
||||
|
||||
namespace NArchive {
|
||||
namespace NGZip {
|
||||
|
||||
@@ -23,43 +28,44 @@ HRESULT CInArchive::ReadBytes(ISequentialInStream *inStream, void *data, UInt32
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadByte(ISequentialInStream *inStream, Byte &value)
|
||||
HRESULT CInArchive::ReadByte(ISequentialInStream *inStream, Byte &value, UInt32 &crc)
|
||||
{
|
||||
return ReadBytes(inStream, &value, 1);
|
||||
HRESULT res = ReadBytes(inStream, &value, 1);
|
||||
crc = CRC_UPDATE_BYTE(crc, value);
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadUInt16(ISequentialInStream *inStream, UInt16 &value)
|
||||
HRESULT CInArchive::ReadUInt16(ISequentialInStream *inStream, UInt16 &value, UInt32 &crc)
|
||||
{
|
||||
value = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Byte b;
|
||||
RINOK(ReadByte(inStream, b));
|
||||
RINOK(ReadByte(inStream, b, crc));
|
||||
value |= (UInt16(b) << (8 * i));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadUInt32(ISequentialInStream *inStream, UInt32 &value)
|
||||
HRESULT CInArchive::ReadUInt32(ISequentialInStream *inStream, UInt32 &value, UInt32 &crc)
|
||||
{
|
||||
value = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Byte b;
|
||||
RINOK(ReadByte(inStream, b));
|
||||
RINOK(ReadByte(inStream, b, crc));
|
||||
value |= (UInt32(b) << (8 * i));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadZeroTerminatedString(ISequentialInStream *inStream, AString &resString, CCRC &crc)
|
||||
HRESULT CInArchive::ReadZeroTerminatedString(ISequentialInStream *inStream, AString &resString, UInt32 &crc)
|
||||
{
|
||||
resString.Empty();
|
||||
for (;;)
|
||||
{
|
||||
Byte c;
|
||||
RINOK(ReadByte(inStream, c));
|
||||
crc.UpdateByte(c);
|
||||
RINOK(ReadByte(inStream, c, crc));
|
||||
if (c == 0)
|
||||
return S_OK;
|
||||
resString += char(c);
|
||||
@@ -72,31 +78,24 @@ HRESULT CInArchive::ReadHeader(ISequentialInStream *inStream, CItem &item)
|
||||
m_Position = 0;
|
||||
|
||||
UInt16 signature;
|
||||
RINOK(ReadUInt16(inStream, signature));
|
||||
UInt32 crc = CRC_INIT_VAL;;
|
||||
RINOK(ReadUInt16(inStream, signature, crc));
|
||||
if (signature != kSignature)
|
||||
return S_FALSE;
|
||||
RINOK(ReadByte(inStream, item.CompressionMethod));
|
||||
RINOK(ReadByte(inStream, item.Flags));
|
||||
RINOK(ReadUInt32(inStream, item.Time));
|
||||
RINOK(ReadByte(inStream, item.ExtraFlags));
|
||||
RINOK(ReadByte(inStream, item.HostOS));
|
||||
|
||||
CCRC crc;
|
||||
crc.Update(&signature, 2);
|
||||
crc.UpdateByte(item.CompressionMethod);
|
||||
crc.UpdateByte(item.Flags);
|
||||
crc.UpdateUInt32(item.Time);
|
||||
crc.UpdateByte(item.ExtraFlags);
|
||||
crc.UpdateByte(item.HostOS);
|
||||
|
||||
RINOK(ReadByte(inStream, item.CompressionMethod, crc));
|
||||
RINOK(ReadByte(inStream, item.Flags, crc));
|
||||
RINOK(ReadUInt32(inStream, item.Time, crc));
|
||||
RINOK(ReadByte(inStream, item.ExtraFlags, crc));
|
||||
RINOK(ReadByte(inStream, item.HostOS, crc));
|
||||
|
||||
if (item.ExtraFieldIsPresent())
|
||||
{
|
||||
UInt16 extraSize;
|
||||
RINOK(ReadUInt16(inStream, extraSize));
|
||||
crc.UpdateUInt16(extraSize);
|
||||
RINOK(ReadUInt16(inStream, extraSize, crc));
|
||||
item.Extra.SetCapacity(extraSize);
|
||||
RINOK(ReadBytes(inStream, item.Extra, extraSize));
|
||||
crc.Update(item.Extra, extraSize);
|
||||
crc = CrcUpdate(crc, item.Extra, extraSize);
|
||||
}
|
||||
if (item.NameIsPresent())
|
||||
RINOK(ReadZeroTerminatedString(inStream, item.Name, crc));
|
||||
@@ -105,8 +104,9 @@ HRESULT CInArchive::ReadHeader(ISequentialInStream *inStream, CItem &item)
|
||||
if (item.HeaderCRCIsPresent())
|
||||
{
|
||||
UInt16 headerCRC;
|
||||
RINOK(ReadUInt16(inStream, headerCRC));
|
||||
if ((UInt16)crc.GetDigest() != headerCRC)
|
||||
UInt32 dummy = 0;
|
||||
RINOK(ReadUInt16(inStream, headerCRC, dummy));
|
||||
if ((UInt16)CRC_GET_DIGEST(crc) != headerCRC)
|
||||
return S_FALSE;
|
||||
}
|
||||
return S_OK;
|
||||
@@ -114,8 +114,9 @@ HRESULT CInArchive::ReadHeader(ISequentialInStream *inStream, CItem &item)
|
||||
|
||||
HRESULT CInArchive::ReadPostHeader(ISequentialInStream *inStream, CItem &item)
|
||||
{
|
||||
RINOK(ReadUInt32(inStream, item.FileCRC));
|
||||
return ReadUInt32(inStream, item.UnPackSize32);
|
||||
UInt32 dummy = 0;
|
||||
RINOK(ReadUInt32(inStream, item.FileCRC, dummy));
|
||||
return ReadUInt32(inStream, item.UnPackSize32, dummy);
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "GZipHeader.h"
|
||||
#include "GZipItem.h"
|
||||
#include "Common/CRC.h"
|
||||
#include "../../IStream.h"
|
||||
|
||||
namespace NArchive {
|
||||
@@ -16,10 +15,10 @@ class CInArchive
|
||||
UInt64 m_Position;
|
||||
|
||||
HRESULT ReadBytes(ISequentialInStream *inStream, void *data, UInt32 size);
|
||||
HRESULT ReadZeroTerminatedString(ISequentialInStream *inStream, AString &resString, CCRC &crc);
|
||||
HRESULT ReadByte(ISequentialInStream *inStream, Byte &value);
|
||||
HRESULT ReadUInt16(ISequentialInStream *inStream, UInt16 &value);
|
||||
HRESULT ReadUInt32(ISequentialInStream *inStream, UInt32 &value);
|
||||
HRESULT ReadZeroTerminatedString(ISequentialInStream *inStream, AString &resString, UInt32 &crc);
|
||||
HRESULT ReadByte(ISequentialInStream *inStream, Byte &value, UInt32 &crc);
|
||||
HRESULT ReadUInt16(ISequentialInStream *inStream, UInt16 &value, UInt32 &crc);
|
||||
HRESULT ReadUInt32(ISequentialInStream *inStream, UInt32 &value, UInt32 &crc);
|
||||
public:
|
||||
HRESULT ReadHeader(ISequentialInStream *inStream, CItem &item);
|
||||
HRESULT ReadPostHeader(ISequentialInStream *inStream, CItem &item);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "GZipOut.h"
|
||||
#include "Common/CRC.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
|
||||
18
CPP/7zip/Archive/GZip/GZipRegister.cpp
Executable file
18
CPP/7zip/Archive/GZip/GZipRegister.cpp
Executable file
@@ -0,0 +1,18 @@
|
||||
// GZipRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterArc.h"
|
||||
|
||||
#include "GZipHandler.h"
|
||||
static IInArchive *CreateArc() { return new NArchive::NGZip::CHandler; }
|
||||
#ifndef EXTRACT_ONLY
|
||||
static IOutArchive *CreateArcOut() { return new NArchive::NGZip::CHandler; }
|
||||
#else
|
||||
#define CreateArcOut 0
|
||||
#endif
|
||||
|
||||
static CArcInfo g_ArcInfo =
|
||||
{ L"GZip", L"gz gzip tgz tpz", L"* * .tar .tar", 0xEF, { 0x1F, 0x8B }, 2, true, CreateArc, CreateArcOut };
|
||||
|
||||
REGISTER_ARC(GZip)
|
||||
@@ -12,26 +12,21 @@
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
|
||||
#include "../Common/InStreamWithCRC.h"
|
||||
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
#include "../../Compress/Deflate/DeflateEncoder.h"
|
||||
#else
|
||||
// {23170F69-40C1-278B-0401-080000000100}
|
||||
DEFINE_GUID(CLSID_CCompressDeflateEncoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00);
|
||||
#include "../Common/CoderLoader.h"
|
||||
extern CSysString GetDeflateCodecPath();
|
||||
#endif
|
||||
|
||||
namespace NArchive {
|
||||
namespace NGZip {
|
||||
|
||||
static const CMethodId kMethodId_Deflate = 0x040108;
|
||||
|
||||
static const Byte kHostOS = NFileHeader::NHostOS::kFAT;
|
||||
|
||||
HRESULT UpdateArchive(IInStream * /* inStream */,
|
||||
HRESULT UpdateArchive(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream * /* inStream */,
|
||||
UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
const CItem &newItem,
|
||||
@@ -45,9 +40,6 @@ HRESULT UpdateArchive(IInStream * /* inStream */,
|
||||
|
||||
RINOK(updateCallback->SetTotal(complexity));
|
||||
|
||||
#ifndef COMPRESS_DEFLATE
|
||||
CCoderLibrary lib;
|
||||
#endif
|
||||
CMyComPtr<ICompressCoder> deflateEncoder;
|
||||
|
||||
complexity = 0;
|
||||
@@ -83,12 +75,11 @@ HRESULT UpdateArchive(IInStream * /* inStream */,
|
||||
localCompressProgressSpec->Init(localProgress, &complexity, NULL);
|
||||
|
||||
{
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
deflateEncoder = new NCompress::NDeflate::NEncoder::CCOMCoder;
|
||||
#else
|
||||
RINOK(lib.LoadAndCreateCoder(GetDeflateCodecPath(),
|
||||
CLSID_CCompressDeflateEncoder, &deflateEncoder));
|
||||
#endif
|
||||
RINOK(CreateCoder(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
kMethodId_Deflate, deflateEncoder, true));
|
||||
if (!deflateEncoder)
|
||||
return E_NOTIMPL;
|
||||
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "../IArchive.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#include "GZipOut.h"
|
||||
#include "GZipItem.h"
|
||||
|
||||
@@ -19,7 +21,9 @@ struct CCompressionMethodMode
|
||||
UInt32 NumMatchFinderCycles;
|
||||
};
|
||||
|
||||
HRESULT UpdateArchive(IInStream *inStream,
|
||||
HRESULT UpdateArchive(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
const CItem &newItem,
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
PROG = gz.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
GZ_OBJS = \
|
||||
$O\GZipHandler.obj \
|
||||
$O\GZipHandlerOut.obj \
|
||||
$O\GZipHeader.obj \
|
||||
$O\GZipIn.obj \
|
||||
$O\GZipOut.obj \
|
||||
$O\GZipUpdate.obj \
|
||||
$O\DllExports.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\CRC.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\PropVariant.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CodecsPath.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(GZ_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(GZ_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AR_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
@@ -1,5 +0,0 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("GZip Plugin", "gz")
|
||||
|
||||
101 ICON "gz.ico"
|
||||
Reference in New Issue
Block a user