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

@@ -122,6 +122,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\CRC.cpp
# End Source File
# Begin Source File
@@ -201,10 +209,6 @@ SOURCE=.\ArjIn.h
SOURCE=.\ArjItem.h
# End Source File
# End Group
# Begin Group "Compression"
# PROP Default_Filter ""
# End Group
# Begin Group "Compress"
# PROP Default_Filter ""
@@ -274,6 +278,10 @@ SOURCE=..\..\Common\LimitedStreams.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\MSBFDecoder.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\ProgressUtils.cpp
# End Source File
# Begin Source File

View File

@@ -93,13 +93,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]))
@@ -111,25 +111,25 @@ 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_NOTIMPL;
}
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;
@@ -193,24 +193,24 @@ STDMETHODIMP CHandler::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *va
COM_TRY_END
}
/*
class CPropgressImp: public CProgressVirt
{
CMyComPtr<IArchiveOpenCallback> m_OpenArchiveCallBack;
public:
STDMETHOD(SetCompleted)(const UINT64 *numFiles);
void Init(IArchiveOpenCallback *openArchiveCallback)
{ m_OpenArchiveCallBack = openArchiveCallback; }
CMyComPtr<IArchiveOpenCallback> Callback;
STDMETHOD(SetCompleted)(const UInt64 *numFiles);
};
STDMETHODIMP CPropgressImp::SetCompleted(const UINT64 *numFiles)
STDMETHODIMP CPropgressImp::SetCompleted(const UInt64 *numFiles)
{
if (m_OpenArchiveCallBack)
return m_OpenArchiveCallBack->SetCompleted(numFiles, NULL);
if (Callback)
return Callback->SetCompleted(numFiles, NULL);
return S_OK;
}
*/
STDMETHODIMP CHandler::Open(IInStream *inStream,
const UINT64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback)
const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *callback)
{
COM_TRY_BEGIN
try
@@ -219,11 +219,11 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
CInArchive archive;
if(!archive.Open(inStream, maxCheckStartPosition))
return S_FALSE;
if (openArchiveCallback != NULL)
if (callback != NULL)
{
RINOK(openArchiveCallback->SetTotal(NULL, NULL));
UINT64 numFiles = _items.Size();
RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
RINOK(callback->SetTotal(NULL, NULL));
UInt64 numFiles = _items.Size();
RINOK(callback->SetCompleted(&numFiles, NULL));
}
while(true)
{
@@ -238,10 +238,10 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
break;
_items.Add(itemInfo);
archive.IncreaseRealPosition(itemInfo.PackSize);
if (openArchiveCallback != NULL)
if (callback != NULL)
{
UINT64 numFiles = _items.Size();
RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
UInt64 numFiles = _items.Size();
RINOK(callback->SetCompleted(&numFiles, NULL));
}
}
_stream = inStream;
@@ -265,18 +265,18 @@ STDMETHODIMP CHandler::Close()
//////////////////////////////////////
// CHandler::DecompressItems
STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
INT32 testModeSpec, IArchiveExtractCallback *extractCallback)
STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
{
COM_TRY_BEGIN
bool testMode = (testModeSpec != 0);
UINT64 totalUnPacked = 0, totalPacked = 0;
bool allFilesMode = (numItems == UINT32(-1));
UInt64 totalUnPacked = 0, totalPacked = 0;
bool allFilesMode = (numItems == UInt32(-1));
if (allFilesMode)
numItems = _items.Size();
if(numItems == 0)
return S_OK;
UINT32 i;
UInt32 i;
for(i = 0; i < numItems; i++)
{
const CItemEx &itemInfo = _items[allFilesMode ? i : indices[i]];
@@ -285,8 +285,8 @@ STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
}
extractCallback->SetTotal(totalUnPacked);
UINT64 currentTotalUnPacked = 0, currentTotalPacked = 0;
UINT64 currentItemUnPacked, currentItemPacked;
UInt64 currentTotalUnPacked = 0, currentTotalPacked = 0;
UInt64 currentItemUnPacked, currentItemPacked;
CMyComPtr<ICompressCoder> arj1Decoder;
CMyComPtr<ICompressCoder> arj2Decoder;
@@ -300,10 +300,10 @@ STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
RINOK(extractCallback->SetCompleted(&currentTotalUnPacked));
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));
@@ -333,7 +333,7 @@ STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
CMyComPtr<ISequentialInStream> inStream(streamSpec);
UINT64 pos;
UInt64 pos;
_stream->Seek(itemInfo.DataPosition, STREAM_SEEK_SET, &pos);
streamSpec->Init(_stream, itemInfo.PackSize);

View File

@@ -1,7 +1,5 @@
// ArjHandler.h
#pragma once
#ifndef __ARJ_HANDLER_H
#define __ARJ_HANDLER_H
@@ -19,23 +17,23 @@ class CHandler:
public:
MY_UNKNOWN_IMP
STDMETHOD(Open)(IInStream *aStream,
const UINT64 *aMaxCheckStartPosition,
IArchiveOpenCallback *anOpenArchiveCallback);
STDMETHOD(Open)(IInStream *inStream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *callback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
STDMETHOD(GetProperty)(UINT32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UINT32* indices, UINT32 numItems,
INT32 testMode, IArchiveExtractCallback *anExtractCallback);
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *anExtractCallback);
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);
CHandler();
@@ -46,4 +44,4 @@ private:
}}
#endif
#endif

View File

@@ -1,7 +1,5 @@
// Archive/Arj/Header.h
#pragma once
#ifndef __ARCHIVE_ARJ_HEADER_H
#define __ARCHIVE_ARJ_HEADER_H
@@ -14,33 +12,32 @@ const int kMaxBlockSize = 2600;
namespace NSignature
{
const BYTE kSig0 = 0x60;
const BYTE kSig1 = 0xEA;
const Byte kSig0 = 0x60;
const Byte kSig1 = 0xEA;
}
#pragma pack( push, Pragma_Arj_Headers)
#pragma pack( push, 1)
/*
struct CArchiveHeader
{
// UINT16 BasicHeaderSize;
BYTE FirstHeaderSize;
BYTE Version;
BYTE ExtractVersion;
BYTE HostOS;
BYTE Flags;
BYTE SecuryVersion;
BYTE FileType;
BYTE Reserved;
UINT32 CreatedTime;
UINT32 ModifiedTime;
UINT32 ArchiveSize;
UINT32 SecurityEnvelopeFilePosition;
UINT16 FilespecPositionInFilename;
UINT16 LengthOfSecurityEnvelopeSata;
BYTE EncryptionVersion;
BYTE LastChapter;
// UInt16 BasicHeaderSize;
Byte FirstHeaderSize;
Byte Version;
Byte ExtractVersion;
Byte HostOS;
Byte Flags;
Byte SecuryVersion;
Byte FileType;
Byte Reserved;
UInt32 CreatedTime;
UInt32 ModifiedTime;
UInt32 ArchiveSize;
UInt32 SecurityEnvelopeFilePosition;
UInt16 FilespecPositionInFilename;
UInt16 LengthOfSecurityEnvelopeSata;
Byte EncryptionVersion;
Byte LastChapter;
};
*/
namespace NFileHeader
{
@@ -70,32 +67,35 @@ namespace NFileHeader
}
namespace NFlags
{
const BYTE kGarbled = 1;
const BYTE kVolume = 4;
const BYTE kExtFile = 8;
const BYTE kPathSym = 0x10;
const BYTE kBackup= 0x20;
const Byte kGarbled = 1;
const Byte kVolume = 4;
const Byte kExtFile = 8;
const Byte kPathSym = 0x10;
const Byte kBackup= 0x20;
}
/*
struct CHeader
{
BYTE FirstHeaderSize;
BYTE Version;
BYTE ExtractVersion;
BYTE HostOS;
BYTE Flags;
BYTE Method;
BYTE FileType;
BYTE Reserved;
UINT32 ModifiedTime;
UINT32 PackSize;
UINT32 Size;
UINT32 FileCRC;
UINT16 FilespecPositionInFilename;
UINT16 FileAccessMode;
BYTE FirstChapter;
BYTE LastChapter;
Byte FirstHeaderSize;
Byte Version;
Byte ExtractVersion;
Byte HostOS;
Byte Flags;
Byte Method;
Byte FileType;
Byte Reserved;
UInt32 ModifiedTime;
UInt32 PackSize;
UInt32 Size;
UInt32 FileCRC;
UInt16 FilespecPositionInFilename;
UInt16 FileAccessMode;
Byte FirstChapter;
Byte LastChapter;
};
*/
namespace NHostOS
{
enum EEnum
@@ -116,9 +116,6 @@ namespace NFileHeader
}
}
#pragma pack(pop)
#pragma pack(pop, Pragma_Arj_Headers)
}}
#endif

View File

@@ -6,20 +6,14 @@
#include "Common/Buffer.h"
#include "Common/CRC.h"
#include "Windows/Defs.h"
#include "ArjIn.h"
namespace NArchive {
namespace NArj {
CInArchiveException::CInArchiveException(CCauseType cause):
Cause(cause)
{}
HRESULT CInArchive::ReadBytes(void *data, UINT32 size, UINT32 *processedSize)
HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
{
UINT32 realProcessedSize;
UInt32 realProcessedSize;
HRESULT result = _stream->Read(data, size, &realProcessedSize);
if(processedSize != NULL)
*processedSize = realProcessedSize;
@@ -27,39 +21,49 @@ HRESULT CInArchive::ReadBytes(void *data, UINT32 size, UINT32 *processedSize)
return result;
}
inline bool TestMarkerCandidate(const void *testBytes, UINT32 maxSize)
static inline UInt16 GetUInt16FromMemLE(const Byte *p)
{
return p[0] | (((UInt32)p[1]) << 8);
}
static inline UInt32 GetUInt32FromMemLE(const Byte *p)
{
return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
}
inline bool TestMarkerCandidate(const void *testBytes, UInt32 maxSize)
{
if (maxSize < 2 + 2 + 4)
return false;
const BYTE *block = ((const BYTE *)(testBytes));
const Byte *block = ((const Byte *)(testBytes));
if (block[0] != NSignature::kSig0 || block[1] != NSignature::kSig1)
return false;
UINT32 blockSize = *((const UINT16 *)(block + 2));
UInt32 blockSize = GetUInt16FromMemLE(block + 2);
if (maxSize < 2 + 2 + blockSize + 4)
return false;
block += 4;
if (blockSize == 0 || blockSize > 2600)
return false;
UINT32 crcFromFile = *(const UINT32 *)(block + blockSize);
UInt32 crcFromFile = GetUInt32FromMemLE(block + blockSize);
return (CCRC::VerifyDigest(crcFromFile, block, blockSize));
}
bool CInArchive::FindAndReadMarker(const UINT64 *searchHeaderSizeLimit)
bool CInArchive::FindAndReadMarker(const UInt64 *searchHeaderSizeLimit)
{
// _archiveInfo.StartPosition = 0;
_position = _streamStartPosition;
if(_stream->Seek(_streamStartPosition, STREAM_SEEK_SET, NULL) != S_OK)
return false;
const int kMarkerSizeMax = 2 + 2 + kMaxBlockSize + sizeof(UINT32);
const int kMarkerSizeMax = 2 + 2 + kMaxBlockSize + 4;
CByteBuffer byteBuffer;
static const UINT32 kSearchMarkerBufferSize = 0x10000;
static const UInt32 kSearchMarkerBufferSize = 0x10000;
byteBuffer.SetCapacity(kSearchMarkerBufferSize);
BYTE *buffer = byteBuffer;
Byte *buffer = byteBuffer;
UINT32 processedSize;
ReadBytes(buffer, 2 + 2 + kMaxBlockSize + sizeof(UINT32), &processedSize);
UInt32 processedSize;
ReadBytes(buffer, kMarkerSizeMax, &processedSize);
if (processedSize == 0)
return false;
if (TestMarkerCandidate(buffer, processedSize))
@@ -70,21 +74,21 @@ bool CInArchive::FindAndReadMarker(const UINT64 *searchHeaderSizeLimit)
return true;
}
UINT32 numBytesPrev = processedSize - 1;
UInt32 numBytesPrev = processedSize - 1;
memmove(buffer, buffer + 1, numBytesPrev);
UINT64 curTestPos = _streamStartPosition + 1;
UInt64 curTestPos = _streamStartPosition + 1;
while(true)
{
if (searchHeaderSizeLimit != NULL)
if (curTestPos - _streamStartPosition > *searchHeaderSizeLimit)
return false;
UINT32 numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
UInt32 numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
ReadBytes(buffer + numBytesPrev, numReadBytes, &processedSize);
UINT32 numBytesInBuffer = numBytesPrev + processedSize;
UInt32 numBytesInBuffer = numBytesPrev + processedSize;
if (numBytesInBuffer < 1)
return false;
UINT32 numTests = numBytesInBuffer;
for(UINT32 pos = 0; pos < numTests; pos++, curTestPos++)
UInt32 numTests = numBytesInBuffer;
for(UInt32 pos = 0; pos < numTests; pos++, curTestPos++)
{
if (TestMarkerCandidate(buffer + pos, numBytesInBuffer - pos))
{
@@ -100,39 +104,68 @@ bool CInArchive::FindAndReadMarker(const UINT64 *searchHeaderSizeLimit)
}
}
void CInArchive::IncreasePositionValue(UINT64 addValue)
void CInArchive::IncreasePositionValue(UInt64 addValue)
{
_position += addValue;
}
void CInArchive::IncreaseRealPosition(UINT64 addValue)
void CInArchive::IncreaseRealPosition(UInt64 addValue)
{
if(_stream->Seek(addValue, STREAM_SEEK_CUR, &_position) != S_OK)
throw CInArchiveException(CInArchiveException::kSeekStreamError);
}
bool CInArchive::ReadBytesAndTestSize(void *data, UINT32 size)
bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
{
UINT32 realProcessedSize;
UInt32 realProcessedSize;
if(ReadBytes(data, size, &realProcessedSize) != S_OK)
throw CInArchiveException(CInArchiveException::kReadStreamError);
return (realProcessedSize == size);
}
void CInArchive::SafeReadBytes(void *data, UINT32 size)
void CInArchive::SafeReadBytes(void *data, UInt32 size)
{
if(!ReadBytesAndTestSize(data, size))
throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
}
Byte CInArchive::SafeReadByte()
{
Byte b;
SafeReadBytes(&b, 1);
return b;
}
UInt16 CInArchive::SafeReadUInt16()
{
UInt16 value = 0;
for (int i = 0; i < 2; i++)
{
Byte b = SafeReadByte();
value |= (UInt16(b) << (8 * i));
}
return value;
}
UInt32 CInArchive::SafeReadUInt32()
{
UInt32 value = 0;
for (int i = 0; i < 4; i++)
{
Byte b = SafeReadByte();
value |= (UInt32(b) << (8 * i));
}
return value;
}
bool CInArchive::ReadBlock()
{
SafeReadBytes(&_blockSize, sizeof(_blockSize));
_blockPos = 0;
_blockSize = SafeReadUInt16();
if (_blockSize == 0)
return false;
SafeReadBytes(_block, _blockSize);
UINT32 crcFromFile;
ReadBytesAndTestSize(&crcFromFile, sizeof(crcFromFile));
UInt32 crcFromFile = SafeReadUInt32();
if (!CCRC::VerifyDigest(crcFromFile, _block, _blockSize))
throw CInArchiveException(CInArchiveException::kCRCError);
return true;
@@ -140,14 +173,14 @@ bool CInArchive::ReadBlock()
bool CInArchive::ReadBlock2()
{
BYTE id[2];
Byte id[2];
ReadBytesAndTestSize(id, 2);
if (id[0] != NSignature::kSig0 || id[1] != NSignature::kSig1)
throw CInArchiveException(CInArchiveException::kIncorrectArchive);
return ReadBlock();
}
bool CInArchive::Open(IInStream *inStream, const UINT64 *searchHeaderSizeLimit)
bool CInArchive::Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit)
{
_stream = inStream;
if(_stream->Seek(0, STREAM_SEEK_CUR, &_streamStartPosition) != S_OK)
@@ -173,40 +206,67 @@ void CInArchive::ThrowIncorrectArchiveException()
throw CInArchiveException(CInArchiveException::kIncorrectArchive);
}
Byte CInArchive::ReadByte()
{
if (_blockPos >= _blockSize)
ThrowIncorrectArchiveException();
return _block[_blockPos++];
}
UInt16 CInArchive::ReadUInt16()
{
UInt16 value = 0;
for (int i = 0; i < 2; i++)
{
Byte b = ReadByte();
value |= (UInt16(b) << (8 * i));
}
return value;
}
UInt32 CInArchive::ReadUInt32()
{
UInt32 value = 0;
for (int i = 0; i < 4; i++)
{
Byte b = ReadByte();
value |= (UInt32(b) << (8 * i));
}
return value;
}
HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
{
filled = false;
if (!ReadBlock2())
return S_OK;
const NFileHeader::CHeader &header = *(const NFileHeader::CHeader *)_block;
item.Version = header.Version;
item.ExtractVersion = header.ExtractVersion;
item.HostOS = header.HostOS;
item.Flags = header.Flags;
item.Method = header.Method;
item.FileType = header.FileType;
item.ModifiedTime = header.ModifiedTime;
item.PackSize = header.PackSize;
item.Size = header.Size;
item.FileCRC = header.FileCRC;
item.FileAccessMode = header.FileAccessMode;
Byte firstHeaderSize = ReadByte();
item.Version = ReadByte();
item.ExtractVersion = ReadByte();
item.HostOS = ReadByte();
item.Flags = ReadByte();
item.Method = ReadByte();
item.FileType = ReadByte();
ReadByte(); // Reserved
item.ModifiedTime = ReadUInt32();
item.PackSize = ReadUInt32();
item.Size = ReadUInt32();
item.FileCRC = ReadUInt32();
ReadUInt16(); // FilespecPositionInFilename
item.FileAccessMode = ReadUInt16();
ReadByte(); // FirstChapter
ReadByte(); // LastChapter
/*
UINT32 extraData;
UInt32 extraData;
if ((header.Flags & NFileHeader::NFlags::kExtFile) != 0)
extraData = *(const UINT32 *)(_block + pos);
extraData = GetUInt32FromMemLE(_block + pos);
*/
int pos = header.FirstHeaderSize;
_blockPos = firstHeaderSize;
for (; pos < _blockSize; pos++)
{
char aByte = _block[pos];
if (aByte == 0)
break;
item.Name += aByte;
}
for (; _blockPos < _blockSize;)
item.Name += (char)ReadByte();
while(true)
if (!ReadBlock())

View File

@@ -1,15 +1,11 @@
// Archive/ArjIn.h
#pragma once
#ifndef __ARCHIVE_ARJIN_H
#define __ARCHIVE_ARJIN_H
#include "Common/Exception.h"
#include "Common/MyCom.h"
#include "../../IStream.h"
#include "Header.h"
#include "ArjItem.h"
namespace NArchive {
@@ -27,42 +23,51 @@ public:
kSeekStreamError
}
Cause;
CInArchiveException(CCauseType cause);
CInArchiveException(CCauseType cause): Cause(cause) {};
};
class CProgressVirt
{
public:
STDMETHOD(SetCompleted)(const UINT64 *numFiles) PURE;
STDMETHOD(SetCompleted)(const UInt64 *numFiles) PURE;
};
class CInArchive
{
CMyComPtr<IInStream> _stream;
UINT64 _streamStartPosition;
UINT64 _position;
UINT16 _blockSize;
BYTE _block[kMaxBlockSize];
UInt64 _streamStartPosition;
UInt64 _position;
UInt16 _blockSize;
Byte _block[kMaxBlockSize];
UInt32 _blockPos;
bool FindAndReadMarker(const UINT64 *searchHeaderSizeLimit);
bool FindAndReadMarker(const UInt64 *searchHeaderSizeLimit);
bool ReadBlock();
bool ReadBlock2();
HRESULT ReadBytes(void *data, UINT32 size, UINT32 *processedSize);
bool ReadBytesAndTestSize(void *data, UINT32 size);
void SafeReadBytes(void *data, UINT32 size);
void IncreasePositionValue(UINT64 addValue);
Byte ReadByte();
UInt16 ReadUInt16();
UInt32 ReadUInt32();
HRESULT ReadBytes(void *data, UInt32 size, UInt32 *processedSize);
bool ReadBytesAndTestSize(void *data, UInt32 size);
void SafeReadBytes(void *data, UInt32 size);
Byte SafeReadByte();
UInt16 SafeReadUInt16();
UInt32 SafeReadUInt32();
void IncreasePositionValue(UInt64 addValue);
void ThrowIncorrectArchiveException();
public:
HRESULT GetNextItem(bool &filled, CItemEx &item);
bool Open(IInStream *inStream, const UINT64 *searchHeaderSizeLimit);
bool Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
void Close();
void IncreaseRealPosition(UINT64 addValue);
void IncreaseRealPosition(UInt64 addValue);
};
}}

View File

@@ -1,9 +1,7 @@
// Archive/Arj/ItemInfo.h
// Archive/ArjItem.h
#pragma once
#ifndef __ARCHIVE_ARJ_ITEMINFO_H
#define __ARCHIVE_ARJ_ITEMINFO_H
#ifndef __ARCHIVE_ARJ_ITEM_H
#define __ARCHIVE_ARJ_ITEM_H
#include "Common/Types.h"
#include "Common/String.h"
@@ -14,8 +12,8 @@ namespace NArj {
struct CVersion
{
BYTE Version;
BYTE HostOS;
Byte Version;
Byte HostOS;
};
inline bool operator==(const CVersion &v1, const CVersion &v2)
@@ -26,29 +24,29 @@ inline bool operator!=(const CVersion &v1, const CVersion &v2)
class CItem
{
public:
BYTE Version;
BYTE ExtractVersion;
BYTE HostOS;
BYTE Flags;
BYTE Method;
BYTE FileType;
UINT32 ModifiedTime;
UINT32 PackSize;
UINT32 Size;
UINT32 FileCRC;
Byte Version;
Byte ExtractVersion;
Byte HostOS;
Byte Flags;
Byte Method;
Byte FileType;
UInt32 ModifiedTime;
UInt32 PackSize;
UInt32 Size;
UInt32 FileCRC;
// UINT16 FilespecPositionInFilename;
UINT16 FileAccessMode;
// BYTE FirstChapter;
// BYTE LastChapter;
// UInt16 FilespecPositionInFilename;
UInt16 FileAccessMode;
// Byte FirstChapter;
// Byte LastChapter;
AString Name;
bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kGarbled) != 0; }
bool IsDirectory() const { return (FileType == NFileHeader::NFileType::kDirectory); }
UINT32 GetWinAttributes() const
UInt32 GetWinAttributes() const
{
DWORD winAtrributes;
UInt32 winAtrributes;
switch(HostOS)
{
case NFileHeader::NHostOS::kMSDOS:
@@ -67,7 +65,7 @@ public:
class CItemEx: public CItem
{
public:
UINT64 DataPosition;
UInt64 DataPosition;
};
}}

View File

@@ -2,8 +2,7 @@
#include "StdAfx.h"
#include <initguid.h>
#include "Common/MyInitGuid.h"
#include "Common/ComTry.h"
#include "Windows/PropVariant.h"
#include "../../ICoder.h"
@@ -63,6 +62,13 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
case NArchive::kKeepName:
propVariant = false;
break;
case NArchive::kStartSignature:
{
const unsigned char sig[] = { 0x60, 0xEA };
if ((value->bstrVal = ::SysAllocStringByteLen((const char *)sig, 2)) != 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,9 +1,8 @@
// stdafx.h
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include <windows.h>
#include <limits.h>
#include "../../../Common/MyWindows.h"
#endif
#endif

View File

@@ -75,8 +75,8 @@ IDI_ICON1 ICON DISCARDABLE "arj.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", "Arj Plugin for 7-Zip\0"
VALUE "FileVersion", "3, 9, 2, 0\0"
VALUE "FileVersion", "4, 13, 0, 0\0"
VALUE "InternalName", "arj\0"
VALUE "LegalCopyright", "Copyright (C) 1999-2003 Igor Pavlov\0"
VALUE "LegalCopyright", "Copyright (C) 1999-2004 Igor Pavlov\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "arj.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