This commit is contained in:
Igor Pavlov
2005-05-30 00:00:00 +00:00
committed by Kornel Lesiński
parent 8c1b5c7b7e
commit 3c510ba80b
926 changed files with 40559 additions and 23519 deletions

View File

@@ -126,6 +126,14 @@ SOURCE=.\StdAfx.h
# 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\NewHandler.cpp
# End Source File
# Begin Source File
@@ -134,6 +142,14 @@ 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

View File

@@ -29,7 +29,7 @@ namespace NDeb {
STATPROPSTG kProperties[] =
{
{ NULL, kpidPath, VT_BSTR},
{ NULL, kpidIsFolder, VT_BOOL},
// { NULL, kpidIsFolder, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
{ NULL, kpidPackedSize, VT_UI8},
{ NULL, kpidLastWriteTime, VT_FILETIME}
@@ -41,13 +41,13 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfProperties(UINT32 *numProperties)
STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
{
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK;
}
STDMETHODIMP CHandler::GetPropertyInfo(UINT32 index,
STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -59,13 +59,13 @@ STDMETHODIMP CHandler::GetPropertyInfo(UINT32 index,
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UINT32 *numProperties)
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
{
*numProperties = 0;
return S_OK;
}
STDMETHODIMP CHandler::GetArchivePropertyInfo(UINT32 index,
STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
return E_INVALIDARG;
@@ -73,12 +73,11 @@ STDMETHODIMP CHandler::GetArchivePropertyInfo(UINT32 index,
STDMETHODIMP CHandler::Open(IInStream *stream,
const UINT64 *maxCheckStartPosition,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback)
{
COM_TRY_BEGIN
bool mustBeClosed = true;
// try
{
CInArchive archive;
if(archive.Open(stream) != S_OK)
@@ -88,7 +87,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
if (openArchiveCallback != NULL)
{
RINOK(openArchiveCallback->SetTotal(NULL, NULL));
UINT64 numFiles = _items.Size();
UInt64 numFiles = _items.Size();
RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
}
@@ -107,18 +106,12 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
archive.SkeepData(itemInfo.Size);
if (openArchiveCallback != NULL)
{
UINT64 numFiles = _items.Size();
UInt64 numFiles = _items.Size();
RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
}
}
_inStream = stream;
}
/*
catch(...)
{
return S_FALSE;
}
*/
return S_OK;
COM_TRY_END
}
@@ -130,13 +123,13 @@ STDMETHODIMP CHandler::Close()
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfItems(UINT32 *numItems)
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
*numItems = _items.Size();
return S_OK;
}
STDMETHODIMP CHandler::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant propVariant;
@@ -174,24 +167,24 @@ STDMETHODIMP CHandler::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *val
COM_TRY_END
}
STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
INT32 _aTestMode, IArchiveExtractCallback *extractCallback)
STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
{
COM_TRY_BEGIN
bool allFilesMode = (numItems == UINT32(-1));
bool allFilesMode = (numItems == UInt32(-1));
if (allFilesMode)
numItems = _items.Size();
if(numItems == 0)
return S_OK;
bool testMode = (_aTestMode != 0);
UINT64 totalSize = 0;
UINT32 i;
UInt64 totalSize = 0;
UInt32 i;
for(i = 0; i < numItems; i++)
totalSize += _items[allFilesMode ? i : indices[i]].Size;
extractCallback->SetTotal(totalSize);
UINT64 currentTotalSize = 0;
UINT64 currentItemSize;
UInt64 currentTotalSize = 0;
UInt64 currentItemSize;
CMyComPtr<ICompressCoder> copyCoder;
@@ -199,10 +192,10 @@ STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
{
RINOK(extractCallback->SetCompleted(&currentTotalSize));
CMyComPtr<ISequentialOutStream> realOutStream;
INT32 askMode;
Int32 askMode;
askMode = testMode ? NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
INT32 index = allFilesMode ? i : indices[i];
Int32 index = allFilesMode ? i : indices[i];
const CItemEx &itemInfo = _items[index];
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));

View File

@@ -1,7 +1,5 @@
// DebHandler.h
#pragma once
#ifndef __DEB_HANDLER_H
#define __DEB_HANDLER_H
@@ -21,22 +19,22 @@ public:
MY_UNKNOWN_IMP
STDMETHOD(Open)(IInStream *stream,
const UINT64 *maxCheckStartPosition,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
STDMETHOD(GetProperty)(UINT32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UINT32* indices, UINT32 numItems,
INT32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
STDMETHOD(GetPropertyInfo)(UINT32 index,
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UINT32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UINT32 index,
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
private:

View File

@@ -8,7 +8,6 @@ namespace NArchive {
namespace NDeb {
namespace NHeader {
const char *kSignature = "!<arch>\n";
const char *kSignature = "!<arch>\n";
}}}

View File

@@ -1,7 +1,5 @@
// Archive/Deb/Header.h
#pragma once
#ifndef __ARCHIVE_DEB_HEADER_H
#define __ARCHIVE_DEB_HEADER_H
@@ -10,16 +8,16 @@
namespace NArchive {
namespace NDeb {
#pragma pack( push, PragmaDebHeaders)
#pragma pack( push, 1)
namespace NHeader
{
const int kSignatureLen = 8;
extern const char *kSignature;
const int kNameSize = 16;
const int kTimeSize = 12;
const int kModeSize = 8;
const int kSizeSize = 10;
/*
struct CHeader
{
char Name[kNameSize];
@@ -31,14 +29,10 @@ namespace NHeader
char Quote;
char NewLine;
};
const int kSignatureLen = 8;
extern const char *kSignature;
*/
const int kHeaderSize = kNameSize + kTimeSize + 6 + 6 + kModeSize + kSizeSize + 1 + 1;
}
#pragma pack(pop)
#pragma pack(pop, PragmaDebHeaders)
}}
#endif

View File

@@ -12,7 +12,7 @@ namespace NDeb {
using namespace NHeader;
HRESULT CInArchive::ReadBytes(void *data, UINT32 size, UINT32 &processedSize)
HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
{
RINOK(m_Stream->Read(data, size, &processedSize));
m_Position += processedSize;
@@ -23,7 +23,7 @@ HRESULT CInArchive::Open(IInStream *inStream)
{
RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
char signature[kSignatureLen];
UINT32 processedSize;
UInt32 processedSize;
RINOK(inStream->Read(signature, kSignatureLen, &processedSize));
m_Position += processedSize;
if (processedSize != kSignatureLen)
@@ -56,7 +56,7 @@ static bool CheckDecimalString(const char *srcString, int numChars)
#define ReturnIfBadOctal(x, y) { if (!CheckOctalString((x), (y))) return S_FALSE; }
#define ReturnIfBadDecimal(x, y) { if (!CheckDecimalString((x), (y))) return S_FALSE; }
static UINT32 StringToNumber(const char *srcString, int numChars, int radix)
static UInt32 StringToNumber(const char *srcString, int numChars, int radix)
{
AString modString;
for (int i = 0; i < numChars; i++)
@@ -64,39 +64,48 @@ static UINT32 StringToNumber(const char *srcString, int numChars, int radix)
char *endPtr;
return strtoul(modString, &endPtr, radix);
}
static UINT32 OctalToNumber(const char *srcString, int numChars)
static UInt32 OctalToNumber(const char *srcString, int numChars)
{ return StringToNumber(srcString, numChars, 8); }
static UINT32 DecimalToNumber(const char *srcString, int numChars)
static UInt32 DecimalToNumber(const char *srcString, int numChars)
{ return StringToNumber(srcString, numChars, 10); }
HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
{
filled = false;
CHeader header;
UINT32 processedSize;
char header[NHeader::kHeaderSize];
const char *cur = header;
UInt32 processedSize;
item.HeaderPosition = m_Position;
RINOK(ReadBytes(&header, sizeof(header), processedSize));
RINOK(ReadBytes(header, sizeof(header), processedSize));
if (processedSize < sizeof(header))
return S_OK;
char tempString[kNameSize + 1];
strncpy(tempString, header.Name, kNameSize);
strncpy(tempString, cur, kNameSize);
cur += kNameSize;
tempString[kNameSize] = '\0';
item.Name = tempString;
item.Name.Trim();
for (int i = 0; i < item.Name.Length(); i++)
if (((BYTE)item.Name[i]) < 0x20)
if (((Byte)item.Name[i]) < 0x20)
return S_FALSE;
ReturnIfBadDecimal(header.ModificationTime, kTimeSize);
ReturnIfBadOctal(header.Mode, kModeSize);
ReturnIfBadDecimal(header.Size, kSizeSize);
ReturnIfBadDecimal(cur, kTimeSize);
item.ModificationTime = DecimalToNumber(cur, kTimeSize);
cur += kTimeSize;
item.ModificationTime = DecimalToNumber(header.ModificationTime, kTimeSize);
item.Mode = OctalToNumber(header.Mode, kModeSize);
item.Size = DecimalToNumber(header.Size, kSizeSize);
cur += 6 + 6;
ReturnIfBadOctal(cur, kModeSize);
item.Mode = OctalToNumber(cur, kModeSize);
cur += kModeSize;
ReturnIfBadDecimal(cur, kSizeSize);
item.Size = DecimalToNumber(cur, kSizeSize);
cur += kSizeSize;
filled = true;
return S_OK;
@@ -118,9 +127,9 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
return S_OK;
}
HRESULT CInArchive::Skeep(UINT64 numBytes)
HRESULT CInArchive::Skeep(UInt64 numBytes)
{
UINT64 newPostion;
UInt64 newPostion;
RINOK(m_Stream->Seek(numBytes, STREAM_SEEK_CUR, &newPostion));
m_Position += numBytes;
if (m_Position != newPostion)
@@ -128,9 +137,9 @@ HRESULT CInArchive::Skeep(UINT64 numBytes)
return S_OK;
}
HRESULT CInArchive::SkeepData(UINT64 dataSize)
HRESULT CInArchive::SkeepData(UInt64 dataSize)
{
return Skeep((dataSize + 1) & 0xFFFFFFFFFFFFFFFE);
return Skeep((dataSize + 1) & (~((UInt64)0x1)));
}
}}

View File

@@ -1,7 +1,5 @@
// Archive/DebIn.h
#pragma once
#ifndef __ARCHIVE_DEB_IN_H
#define __ARCHIVE_DEB_IN_H
@@ -15,15 +13,15 @@ namespace NDeb {
class CInArchive
{
CMyComPtr<IInStream> m_Stream;
UINT64 m_Position;
UInt64 m_Position;
HRESULT ReadBytes(void *data, UINT32 size, UINT32 &processedSize);
HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize);
HRESULT GetNextItemReal(bool &filled, CItemEx &itemInfo);
HRESULT Skeep(UINT64 numBytes);
HRESULT Skeep(UInt64 numBytes);
public:
HRESULT Open(IInStream *inStream);
HRESULT GetNextItem(bool &filled, CItemEx &itemInfo);
HRESULT SkeepData(UINT64 dataSize);
HRESULT SkeepData(UInt64 dataSize);
};
}}

View File

@@ -1,7 +1,5 @@
// Archive/Deb/ItemInfo.h
#pragma once
#ifndef __ARCHIVE_DEB_ITEMINFO_H
#define __ARCHIVE_DEB_ITEMINFO_H
@@ -16,17 +14,17 @@ class CItem
{
public:
AString Name;
UINT64 Size;
UINT32 ModificationTime;
UINT32 Mode;
UInt64 Size;
UInt32 ModificationTime;
UInt32 Mode;
};
class CItemEx: public CItem
{
public:
UINT64 HeaderPosition;
UINT64 GetDataPosition() const { return HeaderPosition + sizeof(NHeader::CHeader); };
// UINT64 GetFullSize() const { return NFileHeader::kRecordSize + Size; };
UInt64 HeaderPosition;
UInt64 GetDataPosition() const { return HeaderPosition + NHeader::kHeaderSize; };
// UInt64 GetFullSize() const { return NFileHeader::kRecordSize + Size; };
};
}}

View File

@@ -2,11 +2,9 @@
#include "StdAfx.h"
#define INITGUID
#include "Common/MyInitGuid.h"
#include "Common/ComTry.h"
#include "Windows/PropVariant.h"
#include "DebHandler.h"
#include "../../ICoder.h"
@@ -14,15 +12,9 @@
DEFINE_GUID(CLSID_CDebHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x0C, 0x00, 0x00);
// HINSTANCE g_hInstance;
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
/*
if (dwReason == DLL_PROCESS_ATTACH)
g_hInstance = hInstance;
*/
return TRUE;
}
@@ -67,6 +59,14 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
case NArchive::kKeepName:
propVariant = false;
break;
case NArchive::kStartSignature:
{
if ((value->bstrVal = ::SysAllocStringByteLen(
(const char *)NArchive::NDeb::NHeader::kSignature,
NArchive::NDeb::NHeader::kSignatureLen)) != 0)
value->vt = VT_BSTR;
return S_OK;
}
}
propVariant.Detach(value);
return S_OK;

View File

@@ -1,3 +1,3 @@
// StdAfx.cpp
#include "stdafx.h"
#include "StdAfx.h"

View File

@@ -1,10 +1,8 @@
// stdafx.h
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include <windows.h>
#include "../../../Common/MyWindows.h"
#include <time.h>
#endif
#endif

View File

@@ -75,8 +75,8 @@ IDI_ICON1 ICON DISCARDABLE "Deb.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,9,2,0
PRODUCTVERSION 3,9,2,0
FILEVERSION 4,13,0,0
PRODUCTVERSION 4,13,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -94,14 +94,14 @@ BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "Igor Pavlov\0"
VALUE "FileDescription", "Deb Plugin for 7-Zip\0"
VALUE "FileVersion", "3, 9, 2, 0\0"
VALUE "FileVersion", "4, 13, 0, 0\0"
VALUE "InternalName", "deb\0"
VALUE "LegalCopyright", "Copyright (C) 1999-2003 Igor Pavlov\0"
VALUE "LegalCopyright", "Copyright (C) 1999-2004 Igor Pavlov\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "deb.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "7-Zip\0"
VALUE "ProductVersion", "3, 9, 2, 0\0"
VALUE "ProductVersion", "4, 13, 0, 0\0"
VALUE "SpecialBuild", "\0"
END
END