This commit is contained in:
Igor Pavlov
2010-04-15 00:00:00 +00:00
committed by Kornel Lesiński
parent 76b173af78
commit 3dacb5eb8a
67 changed files with 906 additions and 758 deletions

View File

@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 9 #define MY_VER_MAJOR 9
#define MY_VER_MINOR 12 #define MY_VER_MINOR 13
#define MY_VER_BUILD 0 #define MY_VER_BUILD 0
#define MY_VERSION "9.12 beta" #define MY_VERSION "9.13 beta"
#define MY_DATE "2010-03-24" #define MY_DATE "2010-04-15"
#define MY_COPYRIGHT ": Igor Pavlov : Public domain" #define MY_COPYRIGHT ": Igor Pavlov : Public domain"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE

View File

@@ -1,5 +1,5 @@
/* Lzma2Enc.c -- LZMA2 Encoder /* Lzma2Enc.c -- LZMA2 Encoder
2010-03-24 : Igor Pavlov : Public domain */ 2010-03-25 : Igor Pavlov : Public domain */
/* #include <stdio.h> */ /* #include <stdio.h> */
#include <string.h> #include <string.h>
@@ -240,9 +240,7 @@ static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)
/* ---------- Lzma2 ---------- */ /* ---------- Lzma2 ---------- */
extern struct _CLzma2Enc; typedef struct
typedef struct _CLzma2Enc
{ {
Byte propEncoded; Byte propEncoded;
CLzma2EncProps props; CLzma2EncProps props;

View File

@@ -232,7 +232,7 @@ HRESULT CDecoder::Decode(
size_t size = props.GetCapacity(); size_t size = props.GetCapacity();
if (size > 0xFFFFFFFF) if (size > 0xFFFFFFFF)
return E_NOTIMPL; return E_NOTIMPL;
if (size > 0) // if (size > 0)
{ {
RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)props, (UInt32)size)); RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)props, (UInt32)size));
} }

View File

@@ -382,6 +382,12 @@ static void MakeExeMethod(const CCompressionMethodMode &method,
prop.Value = kNumFastBytesForBCJ2_LZMA; prop.Value = kNumFastBytesForBCJ2_LZMA;
methodFull.Props.Add(prop); methodFull.Props.Add(prop);
} }
{
CProp prop;
prop.Id = NCoderPropID::kNumThreads;
prop.Value = (UInt32)1;
methodFull.Props.Add(prop);
}
exeMethod.Methods.Add(methodFull); exeMethod.Methods.Add(methodFull);
exeMethod.Methods.Add(methodFull); exeMethod.Methods.Add(methodFull);

View File

@@ -2,6 +2,8 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "../../../../C/Alloc.h"
#include "Common/Buffer.h" #include "Common/Buffer.h"
#include "Common/ComTry.h" #include "Common/ComTry.h"
#include "Common/Defs.h" #include "Common/Defs.h"
@@ -32,8 +34,6 @@ namespace NCab {
// #define _CAB_DETAILS // #define _CAB_DETAILS
static const UInt32 kMaxTempBufSize = 1 << 20;
#ifdef _CAB_DETAILS #ifdef _CAB_DETAILS
enum enum
{ {
@@ -344,9 +344,10 @@ private:
const CMvDatabaseEx *m_Database; const CMvDatabaseEx *m_Database;
const CRecordVector<bool> *m_ExtractStatuses; const CRecordVector<bool> *m_ExtractStatuses;
CByteBuffer TempBuf; Byte *TempBuf;
UInt32 TempBufSize;
int NumIdenticalFiles;
bool TempBufMode; bool TempBufMode;
bool IsSupported;
UInt32 m_BufStartFolderOffset; UInt32 m_BufStartFolderOffset;
int m_StartIndex; int m_StartIndex;
@@ -362,12 +363,21 @@ private:
UInt64 m_FolderSize; UInt64 m_FolderSize;
UInt64 m_PosInFolder; UInt64 m_PosInFolder;
void FreeTempBuf()
{
::MyFree(TempBuf);
TempBuf = NULL;
}
HRESULT OpenFile(); HRESULT OpenFile();
HRESULT CloseFileWithResOp(Int32 resOp);
HRESULT CloseFile(); HRESULT CloseFile();
HRESULT Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK); HRESULT Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK);
public: public:
HRESULT WriteEmptyFiles(); HRESULT WriteEmptyFiles();
CFolderOutStream(): TempBuf(NULL) {}
~CFolderOutStream() { FreeTempBuf(); }
void Init( void Init(
const CMvDatabaseEx *database, const CMvDatabaseEx *database,
const CRecordVector<bool> *extractStatuses, const CRecordVector<bool> *extractStatuses,
@@ -403,54 +413,80 @@ void CFolderOutStream::Init(
m_FileIsOpen = false; m_FileIsOpen = false;
m_IsOk = true; m_IsOk = true;
TempBufMode = false; TempBufMode = false;
NumIdenticalFiles = 0;
}
HRESULT CFolderOutStream::CloseFileWithResOp(Int32 resOp)
{
m_RealOutStream.Release();
m_FileIsOpen = false;
NumIdenticalFiles--;
return m_ExtractCallback->SetOperationResult(resOp);
} }
HRESULT CFolderOutStream::CloseFile() HRESULT CFolderOutStream::CloseFile()
{ {
m_RealOutStream.Release(); return CloseFileWithResOp(m_IsOk ?
HRESULT res = m_ExtractCallback->SetOperationResult(m_IsOk ?
NExtract::NOperationResult::kOK: NExtract::NOperationResult::kOK:
NExtract::NOperationResult::kDataError); NExtract::NOperationResult::kDataError);
m_FileIsOpen = false;
return res;
} }
HRESULT CFolderOutStream::OpenFile() HRESULT CFolderOutStream::OpenFile()
{ {
Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ? if (NumIdenticalFiles == 0)
NExtract::NAskMode::kTest :
NExtract::NAskMode::kExtract) :
NExtract::NAskMode::kSkip;
if (!TempBufMode)
{ {
const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex]; const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex];
const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex]; const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
int curIndex = m_CurrentIndex + 1; int numExtractItems = 0;
for (; curIndex < m_ExtractStatuses->Size(); curIndex++) int curIndex;
if ((*m_ExtractStatuses)[curIndex]) for (curIndex = m_CurrentIndex; curIndex < m_ExtractStatuses->Size(); curIndex++)
{
const CMvItem &mvItem2 = m_Database->Items[m_StartIndex + curIndex];
const CItem &item2 = m_Database->Volumes[mvItem2.VolumeIndex].Items[mvItem2.ItemIndex];
if (item.Offset != item2.Offset ||
item.Size != item2.Size ||
item.Size == 0)
break;
}
if (curIndex > m_CurrentIndex + 1)
{ {
size_t oldCapacity = TempBuf.GetCapacity(); const CMvItem &mvItem2 = m_Database->Items[m_StartIndex + curIndex];
IsSupported = (item.Size <= kMaxTempBufSize); const CItem &item2 = m_Database->Volumes[mvItem2.VolumeIndex].Items[mvItem2.ItemIndex];
if (item.Size > oldCapacity && IsSupported) if (item.Offset != item2.Offset ||
item.Size != item2.Size ||
item.Size == 0)
break;
if (!m_TestMode && (*m_ExtractStatuses)[curIndex])
numExtractItems++;
}
NumIdenticalFiles = (curIndex - m_CurrentIndex);
if (NumIdenticalFiles == 0)
NumIdenticalFiles = 1;
TempBufMode = false;
if (numExtractItems > 1)
{
if (!TempBuf || item.Size > TempBufSize)
{ {
TempBuf.SetCapacity(0); FreeTempBuf();
TempBuf.SetCapacity(item.Size); TempBuf = (Byte *)MyAlloc(item.Size);
TempBufSize = item.Size;
if (TempBuf == NULL)
return E_OUTOFMEMORY;
} }
TempBufMode = true; TempBufMode = true;
m_BufStartFolderOffset = item.Offset; m_BufStartFolderOffset = item.Offset;
} }
else if (numExtractItems == 1)
{
while (NumIdenticalFiles && !(*m_ExtractStatuses)[m_CurrentIndex])
{
CMyComPtr<ISequentialOutStream> stream;
RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &stream, NExtract::NAskMode::kSkip));
if (stream)
return E_FAIL;
RINOK(m_ExtractCallback->PrepareOperation(NExtract::NAskMode::kSkip));
m_CurrentIndex++;
m_FileIsOpen = true;
CloseFile();
}
}
} }
Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ?
NExtract::NAskMode::kTest :
NExtract::NAskMode::kExtract) :
NExtract::NAskMode::kSkip;
RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &m_RealOutStream, askMode)); RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &m_RealOutStream, askMode));
if (!m_RealOutStream && !m_TestMode) if (!m_RealOutStream && !m_TestMode)
askMode = NExtract::NAskMode::kSkip; askMode = NExtract::NAskMode::kSkip;
@@ -499,7 +535,7 @@ HRESULT CFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processe
res = m_RealOutStream->Write((const Byte *)data, numBytesToWrite, &processedSizeLocal); res = m_RealOutStream->Write((const Byte *)data, numBytesToWrite, &processedSizeLocal);
numBytesToWrite = processedSizeLocal; numBytesToWrite = processedSizeLocal;
} }
if (TempBufMode && IsSupported) if (TempBufMode && TempBuf)
memcpy(TempBuf + (m_PosInFolder - m_BufStartFolderOffset), data, numBytesToWrite); memcpy(TempBuf + (m_PosInFolder - m_BufStartFolderOffset), data, numBytesToWrite);
} }
realProcessed += numBytesToWrite; realProcessed += numBytesToWrite;
@@ -513,38 +549,27 @@ HRESULT CFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processe
return res; return res;
if (m_RemainFileSize == 0) if (m_RemainFileSize == 0)
{ {
m_RealOutStream.Release();
RINOK(CloseFile()); RINOK(CloseFile());
if (TempBufMode) while (NumIdenticalFiles)
{ {
while (m_CurrentIndex < m_ExtractStatuses->Size()) HRESULT result = OpenFile();
{ m_FileIsOpen = true;
const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex]; m_CurrentIndex++;
const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex]; if (result == S_OK && m_RealOutStream && TempBuf)
if (item.Offset != m_BufStartFolderOffset) result = WriteStream(m_RealOutStream, TempBuf, (size_t)(m_PosInFolder - m_BufStartFolderOffset));
break;
HRESULT result = OpenFile();
m_FileIsOpen = true;
m_CurrentIndex++;
m_IsOk = true;
if (result == S_OK && m_RealOutStream && IsSupported)
result = WriteStream(m_RealOutStream, TempBuf, item.Size);
if (IsSupported) if (!TempBuf && TempBufMode && m_RealOutStream)
{ {
RINOK(CloseFile()); RINOK(CloseFileWithResOp(NExtract::NOperationResult::kUnSupportedMethod));
RINOK(result);
}
else
{
m_RealOutStream.Release();
RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod));
m_FileIsOpen = false;
}
} }
TempBufMode = false; else
{
RINOK(CloseFile());
}
RINOK(result);
} }
TempBufMode = false;
} }
if (realProcessed > 0) if (realProcessed > 0)
break; // with this break this function works as Write-Part break; // with this break this function works as Write-Part

View File

@@ -54,7 +54,7 @@ static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
{ {
sizes.Clear(); sizes.Clear();
sizePointers.Clear(); sizePointers.Clear();
for(UInt32 i = 0; i < numItems; i++) for (UInt32 i = 0; i < numItems; i++)
{ {
if (srcSizes == 0 || srcSizes[i] == NULL) if (srcSizes == 0 || srcSizes[i] == NULL)
{ {
@@ -83,7 +83,7 @@ HRESULT CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
{ {
_bindInfo = bindInfo; _bindInfo = bindInfo;
_streamBinders.Clear(); _streamBinders.Clear();
for(int i = 0; i < _bindInfo.BindPairs.Size(); i++) for (int i = 0; i < _bindInfo.BindPairs.Size(); i++)
{ {
_streamBinders.Add(CStreamBinder()); _streamBinders.Add(CStreamBinder());
RINOK(_streamBinders.Back().CreateEvents()); RINOK(_streamBinders.Back().CreateEvents());
@@ -113,7 +113,7 @@ void CCoderMixer2MT::AddCoder2(ICompressCoder2 *coder)
void CCoderMixer2MT::ReInit() void CCoderMixer2MT::ReInit()
{ {
for(int i = 0; i < _streamBinders.Size(); i++) for (int i = 0; i < _streamBinders.Size(); i++)
_streamBinders[i].ReInit(); _streamBinders[i].ReInit();
} }
@@ -125,20 +125,20 @@ HRESULT CCoderMixer2MT::Init(ISequentialInStream **inStreams, ISequentialOutStre
throw 0; throw 0;
*/ */
int i; int i;
for(i = 0; i < _coders.Size(); i++) for (i = 0; i < _coders.Size(); i++)
{ {
CCoder2 &coderInfo = _coders[i]; CCoder2 &coderInfo = _coders[i];
const CCoderStreamsInfo &coderStreamsInfo = _bindInfo.Coders[i]; const CCoderStreamsInfo &coderStreamsInfo = _bindInfo.Coders[i];
coderInfo.InStreams.Clear(); coderInfo.InStreams.Clear();
UInt32 j; UInt32 j;
for(j = 0; j < coderStreamsInfo.NumInStreams; j++) for (j = 0; j < coderStreamsInfo.NumInStreams; j++)
coderInfo.InStreams.Add(NULL); coderInfo.InStreams.Add(NULL);
coderInfo.OutStreams.Clear(); coderInfo.OutStreams.Clear();
for(j = 0; j < coderStreamsInfo.NumOutStreams; j++) for (j = 0; j < coderStreamsInfo.NumOutStreams; j++)
coderInfo.OutStreams.Add(NULL); coderInfo.OutStreams.Add(NULL);
} }
for(i = 0; i < _bindInfo.BindPairs.Size(); i++) for (i = 0; i < _bindInfo.BindPairs.Size(); i++)
{ {
const CBindPair &bindPair = _bindInfo.BindPairs[i]; const CBindPair &bindPair = _bindInfo.BindPairs[i];
UInt32 inCoderIndex, inCoderStreamIndex; UInt32 inCoderIndex, inCoderStreamIndex;
@@ -149,16 +149,26 @@ HRESULT CCoderMixer2MT::Init(ISequentialInStream **inStreams, ISequentialOutStre
_streamBinders[i].CreateStreams( _streamBinders[i].CreateStreams(
&_coders[inCoderIndex].InStreams[inCoderStreamIndex], &_coders[inCoderIndex].InStreams[inCoderStreamIndex],
&_coders[outCoderIndex].OutStreams[outCoderStreamIndex]); &_coders[outCoderIndex].OutStreams[outCoderStreamIndex]);
CMyComPtr<ICompressSetBufSize> inSetSize, outSetSize;
_coders[inCoderIndex].QueryInterface(IID_ICompressSetBufSize, (void **)&inSetSize);
_coders[outCoderIndex].QueryInterface(IID_ICompressSetBufSize, (void **)&outSetSize);
if (inSetSize && outSetSize)
{
const UInt32 kBufSize = 1 << 19;
inSetSize->SetInBufSize(inCoderStreamIndex, kBufSize);
outSetSize->SetOutBufSize(outCoderStreamIndex, kBufSize);
}
} }
for(i = 0; i < _bindInfo.InStreams.Size(); i++) for (i = 0; i < _bindInfo.InStreams.Size(); i++)
{ {
UInt32 inCoderIndex, inCoderStreamIndex; UInt32 inCoderIndex, inCoderStreamIndex;
_bindInfo.FindInStream(_bindInfo.InStreams[i], inCoderIndex, inCoderStreamIndex); _bindInfo.FindInStream(_bindInfo.InStreams[i], inCoderIndex, inCoderStreamIndex);
_coders[inCoderIndex].InStreams[inCoderStreamIndex] = inStreams[i]; _coders[inCoderIndex].InStreams[inCoderStreamIndex] = inStreams[i];
} }
for(i = 0; i < _bindInfo.OutStreams.Size(); i++) for (i = 0; i < _bindInfo.OutStreams.Size(); i++)
{ {
UInt32 outCoderIndex, outCoderStreamIndex; UInt32 outCoderIndex, outCoderStreamIndex;
_bindInfo.FindOutStream(_bindInfo.OutStreams[i], outCoderIndex, outCoderStreamIndex); _bindInfo.FindOutStream(_bindInfo.OutStreams[i], outCoderIndex, outCoderStreamIndex);

View File

@@ -41,7 +41,7 @@ namespace NMacho {
#define MACH_SECT_ATTR_ZEROFILL 1 #define MACH_SECT_ATTR_ZEROFILL 1
const char *g_SectTypes[] = static const char *g_SectTypes[] =
{ {
"REGULAR", "REGULAR",
"ZEROFILL", "ZEROFILL",
@@ -60,7 +60,7 @@ const char *g_SectTypes[] =
"16BYTE_LITERALS" "16BYTE_LITERALS"
}; };
const char *g_FileTypes[] = static const char *g_FileTypes[] =
{ {
"0", "0",
"OBJECT", "OBJECT",
@@ -111,11 +111,18 @@ struct CSection
char Name[kNameSize]; char Name[kNameSize];
char SegName[kNameSize]; char SegName[kNameSize];
UInt64 Va; UInt64 Va;
UInt64 Size; UInt64 Pa;
UInt32 Pa; UInt64 VSize;
UInt64 PSize;
UInt32 Flags; UInt32 Flags;
int SegmentIndex; int SegmentIndex;
UInt64 GetPackSize() const { return Flags == MACH_SECT_ATTR_ZEROFILL ? 0 : Size; }
bool IsDummy;
CSection(): IsDummy(false) {}
// UInt64 GetPackSize() const { return Flags == MACH_SECT_ATTR_ZEROFILL ? 0 : Size; }
UInt64 GetPackSize() const { return PSize; }
}; };
@@ -195,8 +202,9 @@ bool CHandler::Parse(const Byte *buf, UInt32 size)
if (cmdSize < offs) if (cmdSize < offs)
break; break;
UInt64 vmAddr, vmSize, phAddr, phSize;
{ {
UInt64 vmAddr, vmSize, phAddr, phSize;
if (cmd == MACH_CMD_SEGMENT_64) if (cmd == MACH_CMD_SEGMENT_64)
{ {
vmAddr = Get64(buf + 0x18, be); vmAddr = Get64(buf + 0x18, be);
@@ -226,7 +234,19 @@ bool CHandler::Parse(const Byte *buf, UInt32 size)
if (numSections > (1 << 8)) if (numSections > (1 << 8))
return false; return false;
while (numSections-- != 0) if (numSections == 0)
{
CSection section;
section.IsDummy = true;
section.SegmentIndex = _segments.Size() - 1;
section.Va = vmAddr;
section.PSize = phSize;
section.VSize = vmSize;
section.Pa = phAddr;
section.Flags = 0;
_sections.Add(section);
}
else do
{ {
CSection section; CSection section;
UInt32 headerSize = (cmd == MACH_CMD_SEGMENT_64) ? 0x50 : 0x44; UInt32 headerSize = (cmd == MACH_CMD_SEGMENT_64) ? 0x50 : 0x44;
@@ -236,23 +256,29 @@ bool CHandler::Parse(const Byte *buf, UInt32 size)
if (cmd == MACH_CMD_SEGMENT_64) if (cmd == MACH_CMD_SEGMENT_64)
{ {
section.Va = Get64(p + 0x20, be); section.Va = Get64(p + 0x20, be);
section.Size = Get64(p + 0x28, be); section.VSize = Get64(p + 0x28, be);
section.Pa = Get32(p + 0x30, be); section.Pa = Get32(p + 0x30, be);
section.Flags = Get32(p + 0x40, be); section.Flags = Get32(p + 0x40, be);
} }
else else
{ {
section.Va = Get32(p + 0x20, be); section.Va = Get32(p + 0x20, be);
section.Size = Get32(p + 0x24, be); section.VSize = Get32(p + 0x24, be);
section.Pa = Get32(p + 0x28, be); section.Pa = Get32(p + 0x28, be);
section.Flags = Get32(p + 0x38, be); section.Flags = Get32(p + 0x38, be);
} }
if (section.Flags == MACH_SECT_ATTR_ZEROFILL)
section.PSize = 0;
else
section.PSize = section.VSize;
memcpy(section.Name, p, kNameSize); memcpy(section.Name, p, kNameSize);
memcpy(section.SegName, p + kNameSize, kNameSize); memcpy(section.SegName, p + kNameSize, kNameSize);
section.SegmentIndex = _segments.Size() - 1; section.SegmentIndex = _segments.Size() - 1;
_sections.Add(section); _sections.Add(section);
offs += headerSize; offs += headerSize;
} }
while (--numSections);
if (offs != cmdSize) if (offs != cmdSize)
return false; return false;
} }
@@ -263,7 +289,7 @@ bool CHandler::Parse(const Byte *buf, UInt32 size)
return reduceCommands || (size == 0); return reduceCommands || (size == 0);
} }
STATPROPSTG kArcProps[] = static STATPROPSTG kArcProps[] =
{ {
{ NULL, kpidCpu, VT_BSTR}, { NULL, kpidCpu, VT_BSTR},
{ NULL, kpidBit64, VT_BOOL}, { NULL, kpidBit64, VT_BOOL},
@@ -273,7 +299,7 @@ STATPROPSTG kArcProps[] =
{ NULL, kpidHeadersSize, VT_UI4} { NULL, kpidHeadersSize, VT_UI4}
}; };
STATPROPSTG kProps[] = static STATPROPSTG kProps[] =
{ {
{ NULL, kpidPath, VT_BSTR}, { NULL, kpidPath, VT_BSTR},
{ NULL, kpidSize, VT_UI8}, { NULL, kpidSize, VT_UI8},
@@ -333,10 +359,17 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
const CSection &item = _sections[index]; const CSection &item = _sections[index];
switch(propID) switch(propID)
{ {
case kpidPath: StringToProp(GetName(_segments[item.SegmentIndex].Name) + GetName(item.Name), prop); break; case kpidPath:
case kpidSize: prop = (UInt64)item.Size; break; {
AString s = GetName(_segments[item.SegmentIndex].Name);
if (!item.IsDummy)
s += GetName(item.Name);
StringToProp(s, prop);
break;
}
case kpidSize: /* prop = (UInt64)item.VSize; break; */
case kpidPackSize: prop = (UInt64)item.GetPackSize(); break; case kpidPackSize: prop = (UInt64)item.GetPackSize(); break;
case kpidCharacts: StringToProp(SectFlagsToString(item.Flags), prop); break; case kpidCharacts: if (!item.IsDummy) StringToProp(SectFlagsToString(item.Flags), prop); break;
case kpidOffset: prop = item.Pa; break; case kpidOffset: prop = item.Pa; break;
case kpidVa: prop = item.Va; break; case kpidVa: prop = item.Va; break;
} }

View File

@@ -23,20 +23,20 @@ using namespace NWindows;
namespace NArchive { namespace NArchive {
namespace NNsis { namespace NNsis {
static const wchar_t *kBcjMethod = L"BCJ"; static const char *kBcjMethod = "BCJ";
static const wchar_t *kUnknownMethod = L"Unknown"; static const char *kUnknownMethod = "Unknown";
static const wchar_t *kMethods[] = static const char *kMethods[] =
{ {
L"Copy", "Copy",
L"Deflate", "Deflate",
L"BZip2", "BZip2",
L"LZMA" "LZMA"
}; };
static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]); static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
STATPROPSTG kProps[] = static STATPROPSTG kProps[] =
{ {
{ NULL, kpidPath, VT_BSTR}, { NULL, kpidPath, VT_BSTR},
{ NULL, kpidSize, VT_UI8}, { NULL, kpidSize, VT_UI8},
@@ -46,7 +46,7 @@ STATPROPSTG kProps[] =
{ NULL, kpidSolid, VT_BOOL} { NULL, kpidSolid, VT_BOOL}
}; };
STATPROPSTG kArcProps[] = static STATPROPSTG kArcProps[] =
{ {
{ NULL, kpidMethod, VT_BSTR}, { NULL, kpidMethod, VT_BSTR},
{ NULL, kpidSolid, VT_BOOL} { NULL, kpidSolid, VT_BOOL}
@@ -116,50 +116,45 @@ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
return S_OK; return S_OK;
} }
static UString ConvertUInt32ToString(UInt32 value) static AString UInt32ToString(UInt32 value)
{ {
wchar_t buffer[32]; char buffer[16];
ConvertUInt64ToString(value, buffer); ConvertUInt32ToString(value, buffer);
return buffer; return buffer;
} }
static UString GetStringForSizeValue(UInt32 value) static AString GetStringForSizeValue(UInt32 value)
{ {
for (int i = 31; i >= 0; i--) for (int i = 31; i >= 0; i--)
if ((UInt32(1) << i) == value) if (((UInt32)1 << i) == value)
return ConvertUInt32ToString(i); return UInt32ToString(i);
UString result; char c = 'b';
if (value % (1 << 20) == 0) if (value % (1 << 20) == 0)
{ {
result += ConvertUInt32ToString(value >> 20); value >>= 20;
result += L"m"; c = 'm';
} }
else if (value % (1 << 10) == 0) else if (value % (1 << 10) == 0)
{ {
result += ConvertUInt32ToString(value >> 10); value >>= 10;
result += L"k"; c = 'k';
} }
else return UInt32ToString(value) + c;
{
result += ConvertUInt32ToString(value);
result += L"b";
}
return result;
} }
UString CHandler::GetMethod(bool useItemFilter, UInt32 dictionary) const AString CHandler::GetMethod(bool useItemFilter, UInt32 dictionary) const
{ {
NMethodType::EEnum methodIndex = _archive.Method; NMethodType::EEnum methodIndex = _archive.Method;
UString method; AString method;
if (_archive.IsSolid && _archive.UseFilter || !_archive.IsSolid && useItemFilter) if (_archive.IsSolid && _archive.UseFilter || !_archive.IsSolid && useItemFilter)
{ {
method += kBcjMethod; method += kBcjMethod;
method += L" "; method += ' ';
} }
method += (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod; method += (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
if (methodIndex == NMethodType::kLZMA) if (methodIndex == NMethodType::kLZMA)
{ {
method += L":"; method += ':';
method += GetStringForSizeValue(_archive.IsSolid ? _archive.DictionarySize: dictionary); method += GetStringForSizeValue(_archive.IsSolid ? _archive.DictionarySize: dictionary);
} }
return method; return method;

View File

@@ -26,7 +26,7 @@ class CHandler:
bool GetUncompressedSize(int index, UInt32 &size); bool GetUncompressedSize(int index, UInt32 &size);
bool GetCompressedSize(int index, UInt32 &size); bool GetCompressedSize(int index, UInt32 &size);
UString GetMethod(bool useItemFilter, UInt32 dictionary) const; AString GetMethod(bool useItemFilter, UInt32 dictionary) const;
public: public:
MY_QUERYINTERFACE_BEGIN2(IInArchive) MY_QUERYINTERFACE_BEGIN2(IInArchive)
QUERY_ENTRY_ISetCompressCodecsInfo QUERY_ENTRY_ISetCompressCodecsInfo

View File

@@ -1290,6 +1290,7 @@ HRESULT CInArchive::Open2(
_headerIsCompressed = true; _headerIsCompressed = true;
IsSolid = true; IsSolid = true;
FilterFlag = false; FilterFlag = false;
DictionarySize = 1;
UInt32 compressedHeaderSize = Get32(sig); UInt32 compressedHeaderSize = Get32(sig);

View File

@@ -72,7 +72,7 @@ struct CItem
UInt32 DictionarySize; UInt32 DictionarySize;
CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false), CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false),
CompressedSizeIsDefined(false), EstimatedSizeIsDefined(false), Size(0) {} CompressedSizeIsDefined(false), EstimatedSizeIsDefined(false), Size(0), DictionarySize(1) {}
bool IsINSTDIR() const bool IsINSTDIR() const
{ {

View File

@@ -145,7 +145,7 @@ struct COptHeader
// UInt32 AddressOfEntryPoint; // UInt32 AddressOfEntryPoint;
// UInt32 BaseOfCode; // UInt32 BaseOfCode;
// UInt32 BaseOfData32; // UInt32 BaseOfData32;
// UInt64 ImageBase; UInt64 ImageBase;
UInt32 SectAlign; UInt32 SectAlign;
UInt32 FileAlign; UInt32 FileAlign;
@@ -202,8 +202,8 @@ bool COptHeader::Parse(const Byte *p, UInt32 size)
// AddressOfEntryPoint = Get32(p + 16); // AddressOfEntryPoint = Get32(p + 16);
// BaseOfCode = Get32(p + 20); // BaseOfCode = Get32(p + 20);
// BaseOfData32 = Get32(p + 24); // BaseOfData32 = hdr64 ? 0: Get32(p + 24);
// ImageBase = hdr64 ? GetUi64(p + 24) :Get32(p + 28); ImageBase = hdr64 ? GetUi64(p + 24) : Get32(p + 28);
SectAlign = Get32(p + 32); SectAlign = Get32(p + 32);
FileAlign = Get32(p + 36); FileAlign = Get32(p + 36);
@@ -625,6 +625,10 @@ enum
kpidStackCommit, kpidStackCommit,
kpidHeapReserve, kpidHeapReserve,
kpidHeapCommit, kpidHeapCommit,
kpidImageBase
// kpidAddressOfEntryPoint,
// kpidBaseOfCode,
// kpidBaseOfData32,
}; };
STATPROPSTG kArcProps[] = STATPROPSTG kArcProps[] =
@@ -652,6 +656,10 @@ STATPROPSTG kArcProps[] =
{ L"Stack Commit", kpidStackCommit, VT_UI8}, { L"Stack Commit", kpidStackCommit, VT_UI8},
{ L"Heap Reserve", kpidHeapReserve, VT_UI8}, { L"Heap Reserve", kpidHeapReserve, VT_UI8},
{ L"Heap Commit", kpidHeapCommit, VT_UI8}, { L"Heap Commit", kpidHeapCommit, VT_UI8},
{ L"Image Base", kpidImageBase, VT_UI8}
// { L"Address Of Entry Point", kpidAddressOfEntryPoint, VT_UI8},
// { L"Base Of Code", kpidBaseOfCode, VT_UI8},
// { L"Base Of Data", kpidBaseOfData32, VT_UI8},
}; };
STATPROPSTG kProps[] = STATPROPSTG kProps[] =
@@ -720,6 +728,12 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
case kpidStackCommit: prop = _optHeader.StackCommit; break; case kpidStackCommit: prop = _optHeader.StackCommit; break;
case kpidHeapReserve: prop = _optHeader.HeapReserve; break; case kpidHeapReserve: prop = _optHeader.HeapReserve; break;
case kpidHeapCommit: prop = _optHeader.HeapCommit; break; case kpidHeapCommit: prop = _optHeader.HeapCommit; break;
case kpidImageBase: prop = _optHeader.ImageBase; break;
// case kpidAddressOfEntryPoint: prop = _optHeader.AddressOfEntryPoint; break;
// case kpidBaseOfCode: prop = _optHeader.BaseOfCode; break;
// case kpidBaseOfData32: if (!_optHeader.Is64Bit()) prop = _optHeader.BaseOfData32; break;
case kpidMainSubfile: if (_mainSubfile >= 0) prop = (UInt32)_mainSubfile; break; case kpidMainSubfile: if (_mainSubfile >= 0) prop = (UInt32)_mainSubfile; break;
} }
prop.Detach(value); prop.Detach(value);
@@ -1393,7 +1407,8 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
_parseResources = true; _parseResources = true;
UInt64 mainSize = 0, mainSize2 = 0; UInt64 mainSize = 0, mainSize2 = 0;
for (int i = 0; i < _sections.Size(); i++) int i;
for (i = 0; i < _sections.Size(); i++)
{ {
const CSection &sect = _sections[i]; const CSection &sect = _sections[i];
CMixItem mixItem; CMixItem mixItem;
@@ -1469,8 +1484,20 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
} }
_mixItems.Add(mixItem); _mixItems.Add(mixItem);
} }
if (mainSize2 >= (1 << 20) && mainSize < mainSize2 * 2) if (mainSize2 >= (1 << 20) && mainSize < mainSize2 * 2)
_mainSubfile = -1; _mainSubfile = -1;
for (i = 0; i < _mixItems.Size(); i++)
{
const CMixItem &mixItem = _mixItems[i];
if (mixItem.StringIndex < 0 && mixItem.ResourceIndex < 0 && _sections[mixItem.SectionIndex].Name == "_winzip_")
{
_mainSubfile = i;
break;
}
}
return S_OK; return S_OK;
} }

View File

@@ -128,7 +128,9 @@ static STATPROPSTG kProps[] =
static STATPROPSTG kArcProps[] = static STATPROPSTG kArcProps[] =
{ {
{ NULL, kpidBit64, VT_BOOL}, { NULL, kpidBit64, VT_BOOL},
{ NULL, kpidComment, VT_BSTR} { NULL, kpidComment, VT_BSTR},
{ NULL, kpidPhySize, VT_UI8},
{ NULL, kpidOffset, VT_UI8}
}; };
CHandler::CHandler() CHandler::CHandler()
@@ -160,9 +162,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
switch(propID) switch(propID)
{ {
case kpidBit64: if (m_Archive.IsZip64) prop = m_Archive.IsZip64; break; case kpidBit64: if (m_Archive.IsZip64) prop = m_Archive.IsZip64; break;
case kpidComment: case kpidComment: prop = MultiByteToUnicodeString(BytesToString(m_Archive.ArcInfo.Comment), CP_ACP); break;
prop = MultiByteToUnicodeString(BytesToString(m_Archive.m_ArchiveInfo.Comment), CP_ACP); case kpidPhySize: prop = m_Archive.ArcInfo.GetPhySize(); break;
break; case kpidOffset: if (m_Archive.ArcInfo.StartPosition != 0) prop = m_Archive.ArcInfo.StartPosition; break;
} }
prop.Detach(value); prop.Detach(value);
COM_TRY_END COM_TRY_END

View File

@@ -87,7 +87,7 @@ private:
m_ForceAesMode = false; m_ForceAesMode = false;
m_IsAesMode = false; m_IsAesMode = false;
m_AesKeyMode = 3; // aes-256 m_AesKeyMode = 3; // aes-256
m_WriteNtfsTimeExtra = false; m_WriteNtfsTimeExtra = true;
m_ForseLocal = false; m_ForseLocal = false;
m_ForseUtf8 = false; m_ForseUtf8 = false;
#ifndef _7ZIP_ST #ifndef _7ZIP_ST

View File

@@ -63,7 +63,7 @@ static inline bool TestMarkerCandidate2(const Byte *p, UInt32 &value)
HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit) HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{ {
m_ArchiveInfo.Clear(); ArcInfo.Clear();
m_Position = m_StreamStartPosition; m_Position = m_StreamStartPosition;
Byte marker[NSignature::kMarkerSize]; Byte marker[NSignature::kMarkerSize];
@@ -99,7 +99,7 @@ HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHea
if (TestMarkerCandidate2(buffer + pos, m_Signature)) if (TestMarkerCandidate2(buffer + pos, m_Signature))
{ {
curTestPos += pos; curTestPos += pos;
m_ArchiveInfo.StartPosition = curTestPos; ArcInfo.StartPosition = curTestPos;
m_Position = curTestPos + NSignature::kMarkerSize; m_Position = curTestPos + NSignature::kMarkerSize;
return S_OK; return S_OK;
} }
@@ -208,11 +208,6 @@ void CInArchive::ReadFileName(UInt32 nameSize, AString &dest)
dest.ReleaseBuffer(); dest.ReleaseBuffer();
} }
void CInArchive::GetArchiveInfo(CInArchiveInfo &archiveInfo) const
{
archiveInfo = m_ArchiveInfo;
}
void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock, void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber) UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber)
{ {
@@ -332,7 +327,7 @@ HRESULT CInArchive::ReadLocalItemAfterCdItem(CItemEx &item)
return S_OK; return S_OK;
try try
{ {
RINOK(Seek(m_ArchiveInfo.Base + item.LocalHeaderPosition)); RINOK(Seek(ArcInfo.Base + item.LocalHeaderPosition));
CItemEx localItem; CItemEx localItem;
if (ReadUInt32() != NSignature::kLocalFileHeader) if (ReadUInt32() != NSignature::kLocalFileHeader)
return S_FALSE; return S_FALSE;
@@ -419,7 +414,7 @@ HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
RINOK(ReadLocalItemAfterCdItem(item)); RINOK(ReadLocalItemAfterCdItem(item));
if (item.HasDescriptor()) if (item.HasDescriptor())
{ {
RINOK(Seek(m_ArchiveInfo.Base + item.GetDataPosition() + item.PackSize)); RINOK(Seek(ArcInfo.Base + item.GetDataPosition() + item.PackSize));
if (ReadUInt32() != NSignature::kDataDescriptor) if (ReadUInt32() != NSignature::kDataDescriptor)
return S_FALSE; return S_FALSE;
UInt32 crc = ReadUInt32(); UInt32 crc = ReadUInt32();
@@ -534,9 +529,9 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
UInt64 ecd64Offset = Get64(locator + 8); UInt64 ecd64Offset = Get64(locator + 8);
if (TryEcd64(ecd64Offset, cdInfo) == S_OK) if (TryEcd64(ecd64Offset, cdInfo) == S_OK)
return S_OK; return S_OK;
if (TryEcd64(m_ArchiveInfo.StartPosition + ecd64Offset, cdInfo) == S_OK) if (TryEcd64(ArcInfo.StartPosition + ecd64Offset, cdInfo) == S_OK)
{ {
m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition; ArcInfo.Base = ArcInfo.StartPosition;
return S_OK; return S_OK;
} }
} }
@@ -548,8 +543,8 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
cdInfo.Offset = Get32(buf + i + 16); cdInfo.Offset = Get32(buf + i + 16);
UInt64 curPos = endPosition - bufSize + i; UInt64 curPos = endPosition - bufSize + i;
UInt64 cdEnd = cdInfo.Size + cdInfo.Offset; UInt64 cdEnd = cdInfo.Size + cdInfo.Offset;
if (curPos > cdEnd) if (curPos != cdEnd)
m_ArchiveInfo.Base = curPos - cdEnd; ArcInfo.Base = curPos - cdEnd;
return S_OK; return S_OK;
} }
} }
@@ -585,18 +580,18 @@ HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UI
HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress) HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress)
{ {
m_ArchiveInfo.Base = 0; ArcInfo.Base = 0;
CCdInfo cdInfo; CCdInfo cdInfo;
RINOK(FindCd(cdInfo)); RINOK(FindCd(cdInfo));
HRESULT res = S_FALSE; HRESULT res = S_FALSE;
cdSize = cdInfo.Size; cdSize = cdInfo.Size;
cdOffset = cdInfo.Offset; cdOffset = cdInfo.Offset;
res = TryReadCd(items, m_ArchiveInfo.Base + cdOffset, cdSize, progress); res = TryReadCd(items, ArcInfo.Base + cdOffset, cdSize, progress);
if (res == S_FALSE && m_ArchiveInfo.Base == 0) if (res == S_FALSE && ArcInfo.Base == 0)
{ {
res = TryReadCd(items, cdInfo.Offset + m_ArchiveInfo.StartPosition, cdSize, progress); res = TryReadCd(items, cdInfo.Offset + ArcInfo.StartPosition, cdSize, progress);
if (res == S_OK) if (res == S_OK)
m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition; ArcInfo.Base = ArcInfo.StartPosition;
} }
if (!ReadUInt32(m_Signature)) if (!ReadUInt32(m_Signature))
return S_FALSE; return S_FALSE;
@@ -645,7 +640,7 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt
CItemEx &item = items[j]; CItemEx &item = items[j];
if (item.Name == cdItem.Name) if (item.Name == cdItem.Name)
{ {
m_ArchiveInfo.Base = item.LocalHeaderPosition - cdItem.LocalHeaderPosition; ArcInfo.Base = item.LocalHeaderPosition - cdItem.LocalHeaderPosition;
break; break;
} }
} }
@@ -660,7 +655,7 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt
if (left >= right) if (left >= right)
return S_FALSE; return S_FALSE;
index = (left + right) / 2; index = (left + right) / 2;
UInt64 position = items[index].LocalHeaderPosition - m_ArchiveInfo.Base; UInt64 position = items[index].LocalHeaderPosition - ArcInfo.Base;
if (cdItem.LocalHeaderPosition == position) if (cdItem.LocalHeaderPosition == position)
break; break;
if (cdItem.LocalHeaderPosition < position) if (cdItem.LocalHeaderPosition < position)
@@ -693,7 +688,7 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt
return S_FALSE; return S_FALSE;
} }
for (i = 0; i < items.Size(); i++) for (i = 0; i < items.Size(); i++)
items[i].LocalHeaderPosition -= m_ArchiveInfo.Base; items[i].LocalHeaderPosition -= ArcInfo.Base;
return S_OK; return S_OK;
} }
@@ -781,20 +776,20 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
if (res == S_FALSE) if (res == S_FALSE)
{ {
_inBufMode = false; _inBufMode = false;
m_ArchiveInfo.Base = 0; ArcInfo.Base = 0;
RINOK(m_Stream->Seek(m_ArchiveInfo.StartPosition, STREAM_SEEK_SET, &m_Position)); RINOK(m_Stream->Seek(ArcInfo.StartPosition, STREAM_SEEK_SET, &m_Position));
if (m_Position != m_ArchiveInfo.StartPosition) if (m_Position != ArcInfo.StartPosition)
return S_FALSE; return S_FALSE;
if (!ReadUInt32(m_Signature)) if (!ReadUInt32(m_Signature))
return S_FALSE; return S_FALSE;
RINOK(ReadLocalsAndCd(items, progress, cdStartOffset, numCdItems)); RINOK(ReadLocalsAndCd(items, progress, cdStartOffset, numCdItems));
cdSize = (m_Position - 4) - cdStartOffset; cdSize = (m_Position - 4) - cdStartOffset;
cdStartOffset -= m_ArchiveInfo.Base; cdStartOffset -= ArcInfo.Base;
} }
CEcd64 ecd64; CEcd64 ecd64;
bool isZip64 = false; bool isZip64 = false;
UInt64 zip64EcdStartOffset = m_Position - 4 - m_ArchiveInfo.Base; UInt64 zip64EcdStartOffset = m_Position - 4 - ArcInfo.Base;
if (m_Signature == NSignature::kZip64EndOfCentralDir) if (m_Signature == NSignature::kZip64EndOfCentralDir)
{ {
IsZip64 = isZip64 = true; IsZip64 = isZip64 = true;
@@ -843,7 +838,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
COPY_ECD_ITEM_32(cdSize); COPY_ECD_ITEM_32(cdSize);
COPY_ECD_ITEM_32(cdStartOffset); COPY_ECD_ITEM_32(cdStartOffset);
ReadBuffer(m_ArchiveInfo.Comment, ecd.commentSize); ReadBuffer(ArcInfo.Comment, ecd.commentSize);
if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0) if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported); throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
@@ -857,6 +852,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
_inBufMode = false; _inBufMode = false;
_inBuffer.Free(); _inBuffer.Free();
IsOkHeaders = (numCdItems == items.Size()); IsOkHeaders = (numCdItems == items.Size());
ArcInfo.FinishPosition = m_Position;
return S_OK; return S_OK;
} }
@@ -864,7 +860,7 @@ ISequentialInStream* CInArchive::CreateLimitedStream(UInt64 position, UInt64 siz
{ {
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream; CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
CMyComPtr<ISequentialInStream> stream(streamSpec); CMyComPtr<ISequentialInStream> stream(streamSpec);
SeekInArchive(m_ArchiveInfo.Base + position); SeekInArchive(ArcInfo.Base + position);
streamSpec->SetStream(m_Stream); streamSpec->SetStream(m_Stream);
streamSpec->Init(size); streamSpec->Init(size);
return stream.Detach(); return stream.Detach();

View File

@@ -38,8 +38,11 @@ class CInArchiveInfo
public: public:
UInt64 Base; UInt64 Base;
UInt64 StartPosition; UInt64 StartPosition;
UInt64 FinishPosition;
CByteBuffer Comment; CByteBuffer Comment;
CInArchiveInfo(): Base(0), StartPosition(0) {} CInArchiveInfo(): Base(0), StartPosition(0) {}
UInt64 GetPhySize() const { return FinishPosition - StartPosition; }
void Clear() void Clear()
{ {
Base = 0; Base = 0;
@@ -101,7 +104,7 @@ class CInArchive
HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress); HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress);
HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset, int &numCdItems); HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset, int &numCdItems);
public: public:
CInArchiveInfo m_ArchiveInfo; CInArchiveInfo ArcInfo;
bool IsZip64; bool IsZip64;
bool IsOkHeaders; bool IsOkHeaders;
@@ -110,7 +113,6 @@ public:
HRESULT ReadLocalItemAfterCdItemFull(CItemEx &item); HRESULT ReadLocalItemAfterCdItemFull(CItemEx &item);
HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit); HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
void Close(); void Close();
void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
bool SeekInArchive(UInt64 position); bool SeekInArchive(UInt64 position);
ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size); ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
IInStream* CreateStream(); IInStream* CreateStream();

View File

@@ -221,7 +221,7 @@ void COutArchive::WriteCentralHeader(const CItem &item)
WriteBytes(item.Comment, (UInt32)item.Comment.GetCapacity()); WriteBytes(item.Comment, (UInt32)item.Comment.GetCapacity());
} }
void COutArchive::WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer &comment) void COutArchive::WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer *comment)
{ {
SeekTo(m_BasePosition); SeekTo(m_BasePosition);
@@ -260,10 +260,10 @@ void COutArchive::WriteCentralDir(const CObjectVector<CItem> &items, const CByte
WriteUInt16((UInt16)(items64 ? 0xFFFF: items.Size())); WriteUInt16((UInt16)(items64 ? 0xFFFF: items.Size()));
WriteUInt32(cdSize64 ? 0xFFFFFFFF: (UInt32)cdSize); WriteUInt32(cdSize64 ? 0xFFFFFFFF: (UInt32)cdSize);
WriteUInt32(cdOffset64 ? 0xFFFFFFFF: (UInt32)cdOffset); WriteUInt32(cdOffset64 ? 0xFFFFFFFF: (UInt32)cdOffset);
UInt16 commentSize = (UInt16)comment.GetCapacity(); UInt32 commentSize = (UInt32)(comment ? comment->GetCapacity() : 0);
WriteUInt16(commentSize); WriteUInt16((UInt16)commentSize);
if (commentSize > 0) if (commentSize > 0)
WriteBytes((const Byte *)comment, commentSize); WriteBytes((const Byte *)*comment, commentSize);
m_OutBuffer.FlushWithCheck(); m_OutBuffer.FlushWithCheck();
} }

View File

@@ -44,7 +44,7 @@ public:
void PrepareWriteCompressedData2(UInt16 fileNameLength, UInt64 unPackSize, UInt64 packSize, bool aesEncryption); void PrepareWriteCompressedData2(UInt16 fileNameLength, UInt64 unPackSize, UInt64 packSize, bool aesEncryption);
void WriteLocalHeader(const CLocalItem &item); void WriteLocalHeader(const CLocalItem &item);
void WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer &comment); void WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer *comment);
void CreateStreamForCompressing(IOutStream **outStream); void CreateStreamForCompressing(IOutStream **outStream);
void CreateStreamForCopying(ISequentialOutStream **outStream); void CreateStreamForCopying(ISequentialOutStream **outStream);

View File

@@ -398,7 +398,7 @@ static HRESULT Update2St(
const CObjectVector<CItemEx> &inputItems, const CObjectVector<CItemEx> &inputItems,
const CObjectVector<CUpdateItem> &updateItems, const CObjectVector<CUpdateItem> &updateItems,
const CCompressionMethodMode *options, const CCompressionMethodMode *options,
const CByteBuffer &comment, const CByteBuffer *comment,
IArchiveUpdateCallback *updateCallback) IArchiveUpdateCallback *updateCallback)
{ {
CLocalProgress *lps = new CLocalProgress; CLocalProgress *lps = new CLocalProgress;
@@ -482,7 +482,7 @@ static HRESULT Update2(
const CObjectVector<CItemEx> &inputItems, const CObjectVector<CItemEx> &inputItems,
const CObjectVector<CUpdateItem> &updateItems, const CObjectVector<CUpdateItem> &updateItems,
const CCompressionMethodMode *options, const CCompressionMethodMode *options,
const CByteBuffer &comment, const CByteBuffer *comment,
IArchiveUpdateCallback *updateCallback) IArchiveUpdateCallback *updateCallback)
{ {
UInt64 complexity = 0; UInt64 complexity = 0;
@@ -515,8 +515,8 @@ static HRESULT Update2(
complexity += NFileHeader::kCentralBlockSize; complexity += NFileHeader::kCentralBlockSize;
} }
if (comment != 0) if (comment)
complexity += comment.GetCapacity(); complexity += comment->GetCapacity();
complexity++; // end of central complexity++; // end of central
updateCallback->SetTotal(complexity); updateCallback->SetTotal(complexity);
@@ -812,27 +812,27 @@ HRESULT Update(
if (!outStream) if (!outStream)
return E_NOTIMPL; return E_NOTIMPL;
CInArchiveInfo archiveInfo; if (inArchive)
if(inArchive != 0)
{ {
inArchive->GetArchiveInfo(archiveInfo); if (inArchive->ArcInfo.Base != 0 ||
if (archiveInfo.Base != 0 || !inArchive->IsOkHeaders) inArchive->ArcInfo.StartPosition != 0 ||
!inArchive->IsOkHeaders)
return E_NOTIMPL; return E_NOTIMPL;
} }
else
archiveInfo.StartPosition = 0;
COutArchive outArchive; COutArchive outArchive;
outArchive.Create(outStream); outArchive.Create(outStream);
if (archiveInfo.StartPosition > 0) /*
if (inArchive && inArchive->ArcInfo.StartPosition > 0)
{ {
CMyComPtr<ISequentialInStream> inStream; CMyComPtr<ISequentialInStream> inStream;
inStream.Attach(inArchive->CreateLimitedStream(0, archiveInfo.StartPosition)); inStream.Attach(inArchive->CreateLimitedStream(0, inArchive->ArcInfo.StartPosition));
RINOK(CopyBlockToArchive(inStream, outArchive, NULL)); RINOK(CopyBlockToArchive(inStream, outArchive, NULL));
outArchive.MoveBasePosition(archiveInfo.StartPosition); outArchive.MoveBasePosition(inArchive->ArcInfo.StartPosition);
} }
*/
CMyComPtr<IInStream> inStream; CMyComPtr<IInStream> inStream;
if(inArchive != 0) if (inArchive)
inStream.Attach(inArchive->CreateStream()); inStream.Attach(inArchive->CreateStream());
return Update2( return Update2(
@@ -840,7 +840,8 @@ HRESULT Update(
outArchive, inArchive, inStream, outArchive, inArchive, inStream,
inputItems, updateItems, inputItems, updateItems,
compressionMethodMode, compressionMethodMode,
archiveInfo.Comment, updateCallback); inArchive ? &inArchive->ArcInfo.Comment : NULL,
updateCallback);
} }
}} }}

View File

@@ -440,14 +440,6 @@ SOURCE=..\..\UI\FileManager\OptionsDialog.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\UI\FileManager\PluginsPage.cpp
# End Source File
# Begin Source File
SOURCE=..\..\UI\FileManager\PluginsPage.h
# End Source File
# Begin Source File
SOURCE=..\..\UI\FileManager\SettingsPage.cpp SOURCE=..\..\UI\FileManager\SettingsPage.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -65,7 +65,6 @@ FM_OBJS = \
$O\MessagesDialog.obj \ $O\MessagesDialog.obj \
$O\OverwriteDialog.obj \ $O\OverwriteDialog.obj \
$O\PasswordDialog.obj \ $O\PasswordDialog.obj \
$O\PluginsPage.obj \
$O\ProgressDialog2.obj \ $O\ProgressDialog2.obj \
$O\SettingsPage.obj \ $O\SettingsPage.obj \
$O\SplitDialog.obj \ $O\SplitDialog.obj \

View File

@@ -57,13 +57,9 @@ HRESULT CEncoder::Flush()
const UInt32 kDefaultLimit = (1 << 24); const UInt32 kDefaultLimit = (1 << 24);
HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams, HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
const UInt64 **inSizes, ISequentialOutStream **outStreams, const UInt64 ** /* outSizes */, UInt32 numOutStreams,
UInt32 numInStreams, ICompressProgressInfo *progress)
ISequentialOutStream **outStreams,
const UInt64 ** /* outSizes */,
UInt32 numOutStreams,
ICompressProgressInfo *progress)
{ {
if (numInStreams != 1 || numOutStreams != 4) if (numInStreams != 1 || numOutStreams != 4)
return E_INVALIDARG; return E_INVALIDARG;
@@ -81,6 +77,8 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
sizeIsDefined = true; sizeIsDefined = true;
} }
CCoderReleaser releaser(this);
ISequentialInStream *inStream = inStreams[0]; ISequentialInStream *inStream = inStreams[0];
_mainStream.SetStream(outStreams[0]); _mainStream.SetStream(outStreams[0]);
@@ -93,7 +91,6 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
_rangeEncoder.Init(); _rangeEncoder.Init();
for (int i = 0; i < 256 + 2; i++) for (int i = 0; i < 256 + 2; i++)
_statusEncoder[i].Init(); _statusEncoder[i].Init();
CCoderReleaser releaser(this);
CMyComPtr<ICompressGetSubStreamSize> getSubStreamSize; CMyComPtr<ICompressGetSubStreamSize> getSubStreamSize;
{ {
@@ -253,18 +250,13 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
} }
} }
STDMETHODIMP CEncoder::Code(ISequentialInStream **inStreams, STDMETHODIMP CEncoder::Code(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
const UInt64 **inSizes, ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
UInt32 numInStreams, ICompressProgressInfo *progress)
ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress)
{ {
try try
{ {
return CodeReal(inStreams, inSizes, numInStreams, return CodeReal(inStreams, inSizes, numInStreams, outStreams, outSizes,numOutStreams, progress);
outStreams, outSizes,numOutStreams, progress);
} }
catch(const COutBufferException &e) { return e.ErrorCode; } catch(const COutBufferException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; } catch(...) { return S_FALSE; }
@@ -272,28 +264,39 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream **inStreams,
#endif #endif
HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams,
const UInt64 ** /* inSizes */, STDMETHODIMP CDecoder::SetInBufSize(UInt32 streamIndex, UInt32 size) { _inBufSizes[streamIndex] = size; return S_OK; }
UInt32 numInStreams, STDMETHODIMP CDecoder::SetOutBufSize(UInt32 , UInt32 size) { _outBufSize = size; return S_OK; }
ISequentialOutStream **outStreams,
const UInt64 ** /* outSizes */, CDecoder::CDecoder():
UInt32 numOutStreams, _outBufSize(1 << 16)
ICompressProgressInfo *progress) {
_inBufSizes[0] = 1 << 20;
_inBufSizes[1] = 1 << 20;
_inBufSizes[2] = 1 << 20;
_inBufSizes[3] = 1 << 20;
}
HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams, const UInt64 ** /* inSizes */, UInt32 numInStreams,
ISequentialOutStream **outStreams, const UInt64 ** /* outSizes */, UInt32 numOutStreams,
ICompressProgressInfo *progress)
{ {
if (numInStreams != 4 || numOutStreams != 1) if (numInStreams != 4 || numOutStreams != 1)
return E_INVALIDARG; return E_INVALIDARG;
if (!_mainInStream.Create(1 << 16)) if (!_mainInStream.Create(_inBufSizes[0]))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (!_callStream.Create(1 << 20)) if (!_callStream.Create(_inBufSizes[1]))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (!_jumpStream.Create(1 << 16)) if (!_jumpStream.Create(_inBufSizes[2]))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (!_rangeDecoder.Create(1 << 20)) if (!_rangeDecoder.Create(_inBufSizes[3]))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (!_outStream.Create(1 << 16)) if (!_outStream.Create(_outBufSize))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
CCoderReleaser releaser(this);
_mainInStream.SetStream(inStreams[0]); _mainInStream.SetStream(inStreams[0]);
_callStream.SetStream(inStreams[1]); _callStream.SetStream(inStreams[1]);
_jumpStream.SetStream(inStreams[2]); _jumpStream.SetStream(inStreams[2]);
@@ -309,8 +312,6 @@ HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams,
for (int i = 0; i < 256 + 2; i++) for (int i = 0; i < 256 + 2; i++)
_statusDecoder[i].Init(); _statusDecoder[i].Init();
CCoderReleaser releaser(this);
Byte prevByte = 0; Byte prevByte = 0;
UInt32 processedBytes = 0; UInt32 processedBytes = 0;
for (;;) for (;;)
@@ -369,18 +370,13 @@ HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams,
} }
} }
STDMETHODIMP CDecoder::Code(ISequentialInStream **inStreams, STDMETHODIMP CDecoder::Code(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
const UInt64 **inSizes, ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
UInt32 numInStreams, ICompressProgressInfo *progress)
ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress)
{ {
try try
{ {
return CodeReal(inStreams, inSizes, numInStreams, return CodeReal(inStreams, inSizes, numInStreams, outStreams, outSizes,numOutStreams, progress);
outStreams, outSizes,numOutStreams, progress);
} }
catch(const CInBufferException &e) { return e.ErrorCode; } catch(const CInBufferException &e) { return e.ErrorCode; }
catch(const COutBufferException &e) { return e.ErrorCode; } catch(const COutBufferException &e) { return e.ErrorCode; }

View File

@@ -21,9 +21,6 @@ class CEncoder:
public CMyUnknownImp public CMyUnknownImp
{ {
Byte *_buffer; Byte *_buffer;
public:
CEncoder(): _buffer(0) {};
~CEncoder();
bool Create(); bool Create();
COutBuffer _mainStream; COutBuffer _mainStream;
@@ -33,6 +30,7 @@ public:
NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2]; NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2];
HRESULT Flush(); HRESULT Flush();
public:
void ReleaseStreams() void ReleaseStreams()
{ {
_mainStream.ReleaseStream(); _mainStream.ReleaseStream();
@@ -50,32 +48,25 @@ public:
}; };
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP
HRESULT CodeReal(ISequentialInStream **inStreams, HRESULT CodeReal(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
const UInt64 **inSizes, ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
UInt32 numInStreams,
ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress); ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream **inStreams, STDMETHOD(Code)(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
const UInt64 **inSizes, ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
UInt32 numInStreams,
ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress); ICompressProgressInfo *progress);
CEncoder(): _buffer(0) {};
~CEncoder();
}; };
#endif #endif
class CDecoder: class CDecoder:
public ICompressCoder2, public ICompressCoder2,
public ICompressSetBufSize,
public CMyUnknownImp public CMyUnknownImp
{ {
public:
CInBuffer _mainInStream; CInBuffer _mainInStream;
CInBuffer _callStream; CInBuffer _callStream;
CInBuffer _jumpStream; CInBuffer _jumpStream;
@@ -83,7 +74,10 @@ public:
NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2]; NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2];
COutBuffer _outStream; COutBuffer _outStream;
UInt32 _inBufSizes[4];
UInt32 _outBufSize;
public:
void ReleaseStreams() void ReleaseStreams()
{ {
_mainInStream.ReleaseStream(); _mainInStream.ReleaseStream();
@@ -103,21 +97,17 @@ public:
}; };
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(ICompressSetBufSize);
HRESULT CodeReal(ISequentialInStream **inStreams, HRESULT CodeReal(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
const UInt64 **inSizes, ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
UInt32 numInStreams,
ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress); ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream **inStreams, STDMETHOD(Code)(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
const UInt64 **inSizes, ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
UInt32 numInStreams,
ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress); ICompressProgressInfo *progress);
STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size);
STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
CDecoder();
}; };
}} }}

View File

@@ -24,9 +24,10 @@ static HRESULT SResToHRESULT(SRes res)
namespace NCompress { namespace NCompress {
namespace NLzma { namespace NLzma {
static const UInt32 kInBufSize = 1 << 20; CDecoder::CDecoder(): _inBuf(0), _propsWereSet(false), _outSizeDefined(false),
_inBufSize(1 << 20),
CDecoder::CDecoder(): _inBuf(0), _propsWereSet(false), _outSizeDefined(false), FinishStream(false) _outBufSize(1 << 22),
FinishStream(false)
{ {
_inSizeProcessed = 0; _inSizeProcessed = 0;
_inPos = _inSize = 0; _inPos = _inSize = 0;
@@ -43,13 +44,18 @@ CDecoder::~CDecoder()
MyFree(_inBuf); MyFree(_inBuf);
} }
STDMETHODIMP CDecoder::SetInBufSize(UInt32 , UInt32 size) { _inBufSize = size; return S_OK; }
STDMETHODIMP CDecoder::SetOutBufSize(UInt32 , UInt32 size) { _outBufSize = size; return S_OK; }
HRESULT CDecoder::CreateInputBuffer() HRESULT CDecoder::CreateInputBuffer()
{ {
if (_inBuf == 0) if (_inBuf == 0 || _inBufSize != _inBufSizeAllocated)
{ {
_inBuf = (Byte *)MyAlloc(kInBufSize); MyFree(_inBuf);
_inBuf = (Byte *)MyAlloc(_inBufSize);
if (_inBuf == 0) if (_inBuf == 0)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
_inBufSizeAllocated = _inBufSize;
} }
return S_OK; return S_OK;
} }
@@ -67,6 +73,7 @@ void CDecoder::SetOutStreamSizeResume(const UInt64 *outSize)
if (_outSizeDefined) if (_outSizeDefined)
_outSize = *outSize; _outSize = *outSize;
_outSizeProcessed = 0; _outSizeProcessed = 0;
_wrPos = 0;
LzmaDec_Init(&_state); LzmaDec_Init(&_state);
} }
@@ -85,19 +92,17 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
UInt64 startInProgress = _inSizeProcessed; UInt64 startInProgress = _inSizeProcessed;
SizeT next = (_state.dicBufSize - _state.dicPos < _outBufSize) ? _state.dicBufSize : (_state.dicPos + _outBufSize);
for (;;) for (;;)
{ {
if (_inPos == _inSize) if (_inPos == _inSize)
{ {
_inPos = _inSize = 0; _inPos = _inSize = 0;
RINOK(inStream->Read(_inBuf, kInBufSize, &_inSize)); RINOK(inStream->Read(_inBuf, _inBufSizeAllocated, &_inSize));
} }
SizeT dicPos = _state.dicPos; SizeT dicPos = _state.dicPos;
SizeT curSize = _state.dicBufSize - dicPos; SizeT curSize = next - dicPos;
const UInt32 kStepSize = ((UInt32)1 << 22);
if (curSize > kStepSize)
curSize = (SizeT)kStepSize;
ELzmaFinishMode finishMode = LZMA_FINISH_ANY; ELzmaFinishMode finishMode = LZMA_FINISH_ANY;
if (_outSizeDefined) if (_outSizeDefined)
@@ -123,9 +128,18 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
bool finished = (inSizeProcessed == 0 && outSizeProcessed == 0); bool finished = (inSizeProcessed == 0 && outSizeProcessed == 0);
bool stopDecoding = (_outSizeDefined && _outSizeProcessed >= _outSize); bool stopDecoding = (_outSizeDefined && _outSizeProcessed >= _outSize);
if (res != 0 || _state.dicPos == _state.dicBufSize || finished || stopDecoding) if (res != 0 || _state.dicPos == next || finished || stopDecoding)
{ {
HRESULT res2 = WriteStream(outStream, _state.dic, _state.dicPos); HRESULT res2 = WriteStream(outStream, _state.dic + _wrPos, _state.dicPos - _wrPos);
_wrPos = _state.dicPos;
if (_state.dicPos == _state.dicBufSize)
{
_state.dicPos = 0;
_wrPos = 0;
}
next = (_state.dicBufSize - _state.dicPos < _outBufSize) ? _state.dicBufSize : (_state.dicPos + _outBufSize);
if (res != 0) if (res != 0)
return S_FALSE; return S_FALSE;
RINOK(res2); RINOK(res2);
@@ -134,9 +148,6 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
if (finished) if (finished)
return (status == LZMA_STATUS_FINISHED_WITH_MARK ? S_OK : S_FALSE); return (status == LZMA_STATUS_FINISHED_WITH_MARK ? S_OK : S_FALSE);
} }
if (_state.dicPos == _state.dicBufSize)
_state.dicPos = 0;
if (progress) if (progress)
{ {
UInt64 inSize = _inSizeProcessed - startInProgress; UInt64 inSize = _inSizeProcessed - startInProgress;
@@ -148,6 +159,8 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream, STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress) const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
{ {
if (_inBuf == 0)
return E_INVALIDARG;
SetOutStreamSize(outSize); SetOutStreamSize(outSize);
return CodeSpec(inStream, outStream, progress); return CodeSpec(inStream, outStream, progress);
} }
@@ -166,7 +179,7 @@ STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
if (_inPos == _inSize) if (_inPos == _inSize)
{ {
_inPos = _inSize = 0; _inPos = _inSize = 0;
RINOK(_inStream->Read(_inBuf, kInBufSize, &_inSize)); RINOK(_inStream->Read(_inBuf, _inBufSizeAllocated, &_inSize));
} }
{ {
SizeT inProcessed = _inSize - _inPos; SizeT inProcessed = _inSize - _inPos;
@@ -214,7 +227,7 @@ HRESULT CDecoder::ReadFromInputStream(void *data, UInt32 size, UInt32 *processed
if (_inPos == _inSize) if (_inPos == _inSize)
{ {
_inPos = _inSize = 0; _inPos = _inSize = 0;
RINOK(_inStream->Read(_inBuf, kInBufSize, &_inSize)); RINOK(_inStream->Read(_inBuf, _inBufSizeAllocated, &_inSize));
if (_inSize == 0) if (_inSize == 0)
break; break;
} }

View File

@@ -14,6 +14,7 @@ namespace NLzma {
class CDecoder: class CDecoder:
public ICompressCoder, public ICompressCoder,
public ICompressSetDecoderProperties2, public ICompressSetDecoderProperties2,
public ICompressSetBufSize,
#ifndef NO_READ_FROM_CODER #ifndef NO_READ_FROM_CODER
public ICompressSetInStream, public ICompressSetInStream,
public ICompressSetOutStreamSize, public ICompressSetOutStreamSize,
@@ -32,6 +33,11 @@ class CDecoder:
UInt64 _inSizeProcessed; UInt64 _inSizeProcessed;
UInt64 _outSizeProcessed; UInt64 _outSizeProcessed;
UInt32 _inBufSizeAllocated;
UInt32 _inBufSize;
UInt32 _outBufSize;
SizeT _wrPos;
HRESULT CreateInputBuffer(); HRESULT CreateInputBuffer();
HRESULT CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress); HRESULT CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress);
void SetOutStreamSizeResume(const UInt64 *outSize); void SetOutStreamSizeResume(const UInt64 *outSize);
@@ -39,6 +45,7 @@ class CDecoder:
public: public:
MY_QUERYINTERFACE_BEGIN2(ICompressCoder) MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
MY_QUERYINTERFACE_ENTRY(ICompressSetDecoderProperties2) MY_QUERYINTERFACE_ENTRY(ICompressSetDecoderProperties2)
MY_QUERYINTERFACE_ENTRY(ICompressSetBufSize)
#ifndef NO_READ_FROM_CODER #ifndef NO_READ_FROM_CODER
MY_QUERYINTERFACE_ENTRY(ICompressSetInStream) MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize) MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize)
@@ -51,6 +58,8 @@ public:
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize); STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size);
STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
#ifndef NO_READ_FROM_CODER #ifndef NO_READ_FROM_CODER
@@ -68,7 +77,6 @@ public:
CDecoder(); CDecoder();
virtual ~CDecoder(); virtual ~CDecoder();
}; };
}} }}

View File

@@ -4,8 +4,6 @@
#ifndef __COMPRESS_PPMD_ZIP_H #ifndef __COMPRESS_PPMD_ZIP_H
#define __COMPRESS_PPMD_ZIP_H #define __COMPRESS_PPMD_ZIP_H
#include "StdAfx.h"
#include "../../../C/Alloc.h" #include "../../../C/Alloc.h"
#include "../../../C/Ppmd8.h" #include "../../../C/Ppmd8.h"

View File

@@ -11,8 +11,9 @@
07 IFileExtractCallback.h::IFolderArchiveExtractCallback 07 IFileExtractCallback.h::IFolderArchiveExtractCallback
0A IOutFolderArchive 0A IOutFolderArchive
0B IFolderArchiveUpdateCallback 0B IFolderArchiveUpdateCallback
0<EFBFBD> Agent.h::IArchiveFolderInternal 0C Agent.h::IArchiveFolderInternal
0D IInFolderArchive 0D
0E IInFolderArchive
03 IStream.h 03 IStream.h
@@ -40,6 +41,7 @@
32 ICompressSetOutStream 32 ICompressSetOutStream
33 ICompressSetInStreamSize 33 ICompressSetInStreamSize
34 ICompressSetOutStreamSize 34 ICompressSetOutStreamSize
35 ICompressSetBufSize
40 ICompressFilter 40 ICompressFilter
60 ICompressCodecsInfo 60 ICompressCodecsInfo
61 ISetCompressCodecsInfo 61 ISetCompressCodecsInfo
@@ -88,24 +90,24 @@
09 IFolderClone 09 IFolderClone
0A IFolderSetFlatMode 0A IFolderSetFlatMode
0B IFolderOperationsExtractCallback 0B IFolderOperationsExtractCallback
0C IFolderArchiveProperties 0C //
0D IGetFolderArchiveProperties 0D //
0E IFolderProperties 0E IFolderProperties
0F
10 IFolderArcProps
11 IGetFolderArcProps
09 IFolder.h :: FOLDER_MANAGER_INTERFACE 09 IFolder.h :: FOLDER_MANAGER_INTERFACE
00 - 03 // old IFolderManager 00 - 04 // old IFolderManager
04 IFolderManager 05 IFolderManager
// 0A PluginInterface.h
------------------ 00 IInitContextMenu
01 IPluginOptionsCallback
02 IPluginOptions
{23170F69-40C1-278D-0000-000100010000} PluginInterface::IInitContextMenu
{23170F69-40C1-278D-0000-000100020100} PluginInterface::IPluginOptionsCallback
{23170F69-40C1-278D-0000-000100020000} PluginInterface::IPluginOptions
Handler GUIDs: Handler GUIDs:

View File

@@ -107,6 +107,12 @@ CODER_INTERFACE(ICompressSetOutStreamSize, 0x34)
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize) PURE; STDMETHOD(SetOutStreamSize)(const UInt64 *outSize) PURE;
}; };
CODER_INTERFACE(ICompressSetBufSize, 0x35)
{
STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size) PURE;
STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size) PURE;
};
CODER_INTERFACE(ICompressFilter, 0x40) CODER_INTERFACE(ICompressFilter, 0x40)
{ {
STDMETHOD(Init)() PURE; STDMETHOD(Init)() PURE;

View File

@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 9 #define MY_VER_MAJOR 9
#define MY_VER_MINOR 12 #define MY_VER_MINOR 13
#define MY_VER_BUILD 0 #define MY_VER_BUILD 0
#define MY_VERSION "9.12 beta" #define MY_VERSION "9.13 beta"
#define MY_7ZIP_VERSION "7-Zip 9.12 beta" #define MY_7ZIP_VERSION "7-Zip 9.13 beta"
#define MY_DATE "2010-03-24" #define MY_DATE "2010-04-15"
#define MY_COPYRIGHT "Copyright (c) 1999-2010 Igor Pavlov" #define MY_COPYRIGHT "Copyright (c) 1999-2010 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE

View File

@@ -278,15 +278,15 @@ struct CArchiveItemPropertyTemp
VARTYPE Type; VARTYPE Type;
}; };
STDMETHODIMP CAgentFolder::GetNumberOfProperties(UInt32 *numProperties) STDMETHODIMP CAgentFolder::GetNumberOfProperties(UInt32 *numProps)
{ {
COM_TRY_BEGIN COM_TRY_BEGIN
RINOK(_agentSpec->GetArchive()->GetNumberOfProperties(numProperties)); RINOK(_agentSpec->GetArchive()->GetNumberOfProperties(numProps));
*numProperties += kNumProperties; *numProps += kNumProperties;
if (!_flatMode) if (!_flatMode)
(*numProperties)--; (*numProps)--;
if (!_agentSpec->_proxyArchive->ThereIsPathProp) if (!_agentSpec->_proxyArchive->ThereIsPathProp)
(*numProperties)++; (*numProps)++;
return S_OK; return S_OK;
COM_TRY_END COM_TRY_END
} }
@@ -294,8 +294,8 @@ STDMETHODIMP CAgentFolder::GetNumberOfProperties(UInt32 *numProperties)
STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
{ {
COM_TRY_BEGIN COM_TRY_BEGIN
UInt32 numProperties; UInt32 numProps;
_agentSpec->GetArchive()->GetNumberOfProperties(&numProperties); _agentSpec->GetArchive()->GetNumberOfProperties(&numProps);
if (!_agentSpec->_proxyArchive->ThereIsPathProp) if (!_agentSpec->_proxyArchive->ThereIsPathProp)
{ {
if (index == 0) if (index == 0)
@@ -308,7 +308,7 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro
index--; index--;
} }
if (index < numProperties) if (index < numProps)
{ {
RINOK(_agentSpec->GetArchive()->GetPropertyInfo(index, name, propID, varType)); RINOK(_agentSpec->GetArchive()->GetPropertyInfo(index, name, propID, varType));
if (*propID == kpidPath) if (*propID == kpidPath)
@@ -316,7 +316,7 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro
} }
else else
{ {
const STATPROPSTG &srcItem = kProperties[index - numProperties]; const STATPROPSTG &srcItem = kProperties[index - numProps];
*propID = srcItem.propid; *propID = srcItem.propid;
*varType = srcItem.vt; *varType = srcItem.vt;
*name = 0; *name = 0;
@@ -356,9 +356,9 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
COM_TRY_END COM_TRY_END
} }
STDMETHODIMP CAgentFolder::GetNumberOfFolderProperties(UInt32 *numProperties) STDMETHODIMP CAgentFolder::GetNumberOfFolderProperties(UInt32 *numProps)
{ {
*numProperties = kNumFolderProps; *numProps = kNumFolderProps;
return S_OK; return S_OK;
} }
@@ -374,9 +374,9 @@ STDMETHODIMP CAgentFolder::GetFolderPropertyInfo(UInt32 index, BSTR *name, PROPI
} }
} }
STDMETHODIMP CAgentFolder::GetFolderArchiveProperties(IFolderArchiveProperties **object) STDMETHODIMP CAgentFolder::GetFolderArcProps(IFolderArcProps **object)
{ {
CMyComPtr<IFolderArchiveProperties> temp = _agentSpec; CMyComPtr<IFolderArcProps> temp = _agentSpec;
*object = temp.Detach(); *object = temp.Detach();
return S_OK; return S_OK;
} }
@@ -468,6 +468,7 @@ CAgent::~CAgent()
STDMETHODIMP CAgent::Open( STDMETHODIMP CAgent::Open(
IInStream *inStream, IInStream *inStream,
const wchar_t *filePath, const wchar_t *filePath,
const wchar_t *arcFormat,
BSTR *archiveType, BSTR *archiveType,
IArchiveOpenCallback *openArchiveCallback) IArchiveOpenCallback *openArchiveCallback)
{ {
@@ -488,7 +489,11 @@ STDMETHODIMP CAgent::Open(
_compressCodecsInfo = _codecs; _compressCodecsInfo = _codecs;
RINOK(_codecs->Load()); RINOK(_codecs->Load());
RINOK(_archiveLink.Open(_codecs, CIntVector(), false, inStream, _archiveFilePath, openArchiveCallback)); CIntVector formatIndices;
if (!_codecs->FindFormatForArchiveType(arcFormat, formatIndices))
return S_FALSE;
RINOK(_archiveLink.Open(_codecs, formatIndices, false, inStream, _archiveFilePath, openArchiveCallback));
CArc &arc = _archiveLink.Arcs.Back(); CArc &arc = _archiveLink.Arcs.Back();
if (!inStream) if (!inStream)
@@ -573,10 +578,10 @@ STDMETHODIMP CAgent::Extract(
COM_TRY_END COM_TRY_END
} }
STDMETHODIMP CAgent::GetNumberOfProperties(UInt32 *numProperties) STDMETHODIMP CAgent::GetNumberOfProperties(UInt32 *numProps)
{ {
COM_TRY_BEGIN COM_TRY_BEGIN
return GetArchive()->GetNumberOfProperties(numProperties); return GetArchive()->GetNumberOfProperties(numProps);
COM_TRY_END COM_TRY_END
} }
@@ -591,25 +596,50 @@ STDMETHODIMP CAgent::GetPropertyInfo(UInt32 index,
COM_TRY_END COM_TRY_END
} }
STDMETHODIMP CAgent::GetArchiveProperty(PROPID propID, PROPVARIANT *value) STDMETHODIMP CAgent::GetArcNumLevels(UInt32 *numLevels)
{
*numLevels = _archiveLink.Arcs.Size();
return S_OK;
}
STDMETHODIMP CAgent::GetArcProp(UInt32 level, PROPID propID, PROPVARIANT *value)
{ {
COM_TRY_BEGIN COM_TRY_BEGIN
return GetArchive()->GetArchiveProperty(propID, value); NWindows::NCOM::CPropVariant prop;
CArc &arc = _archiveLink.Arcs[level];
switch(propID)
{
case kpidType: prop = _codecs->Formats[arc.FormatIndex].Name; break;
case kpidPath: prop = arc.Path; break;
default: return arc.Archive->GetArchiveProperty(propID, value);
}
prop.Detach(value);
return S_OK;
COM_TRY_END COM_TRY_END
} }
STDMETHODIMP CAgent::GetNumberOfArchiveProperties(UInt32 *numProperties) STDMETHODIMP CAgent::GetArcNumProps(UInt32 level, UInt32 *numProps)
{ {
COM_TRY_BEGIN return _archiveLink.Arcs[level].Archive->GetNumberOfArchiveProperties(numProps);
return GetArchive()->GetNumberOfArchiveProperties(numProperties);
COM_TRY_END
} }
STDMETHODIMP CAgent::GetArchivePropertyInfo(UInt32 index, STDMETHODIMP CAgent::GetArcPropInfo(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
BSTR *name, PROPID *propID, VARTYPE *varType)
{ {
COM_TRY_BEGIN return _archiveLink.Arcs[level].Archive->GetArchivePropertyInfo(index, name, propID, varType);
return GetArchive()->GetArchivePropertyInfo(index, }
name, propID, varType);
COM_TRY_END // MainItemProperty
STDMETHODIMP CAgent::GetArcProp2(UInt32 level, PROPID propID, PROPVARIANT *value)
{
return _archiveLink.Arcs[level - 1].Archive->GetProperty(_archiveLink.Arcs[level].SubfileIndex, propID, value);
}
STDMETHODIMP CAgent::GetArcNumProps2(UInt32 level, UInt32 *numProps)
{
return _archiveLink.Arcs[level - 1].Archive->GetNumberOfProperties(numProps);
}
STDMETHODIMP CAgent::GetArcPropInfo2(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
{
return _archiveLink.Arcs[level - 1].Archive->GetPropertyInfo(index, name, propID, varType);
} }

View File

@@ -36,7 +36,7 @@ class CAgent;
class CAgentFolder: class CAgentFolder:
public IFolderFolder, public IFolderFolder,
public IFolderProperties, public IFolderProperties,
public IGetFolderArchiveProperties, public IGetFolderArcProps,
public IArchiveFolder, public IArchiveFolder,
public IArchiveFolderInternal, public IArchiveFolderInternal,
public IInArchiveGetStream, public IInArchiveGetStream,
@@ -50,7 +50,7 @@ public:
MY_QUERYINTERFACE_BEGIN2(IFolderFolder) MY_QUERYINTERFACE_BEGIN2(IFolderFolder)
MY_QUERYINTERFACE_ENTRY(IFolderProperties) MY_QUERYINTERFACE_ENTRY(IFolderProperties)
MY_QUERYINTERFACE_ENTRY(IGetFolderArchiveProperties) MY_QUERYINTERFACE_ENTRY(IGetFolderArcProps)
MY_QUERYINTERFACE_ENTRY(IArchiveFolder) MY_QUERYINTERFACE_ENTRY(IArchiveFolder)
MY_QUERYINTERFACE_ENTRY(IArchiveFolderInternal) MY_QUERYINTERFACE_ENTRY(IArchiveFolderInternal)
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream) MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
@@ -68,7 +68,7 @@ public:
INTERFACE_FolderFolder(;) INTERFACE_FolderFolder(;)
INTERFACE_FolderProperties(;) INTERFACE_FolderProperties(;)
STDMETHOD(GetFolderArchiveProperties)(IFolderArchiveProperties **object); STDMETHOD(GetFolderArcProps)(IFolderArcProps **object);
// IArchiveFolder // IArchiveFolder
STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems, STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems,
@@ -132,7 +132,7 @@ private:
class CAgent: class CAgent:
public IInFolderArchive, public IInFolderArchive,
public IFolderArchiveProperties, public IFolderArcProps,
#ifndef EXTRACT_ONLY #ifndef EXTRACT_ONLY
public IOutFolderArchive, public IOutFolderArchive,
public ISetProperties, public ISetProperties,
@@ -142,7 +142,7 @@ class CAgent:
public: public:
MY_QUERYINTERFACE_BEGIN2(IInFolderArchive) MY_QUERYINTERFACE_BEGIN2(IInFolderArchive)
MY_QUERYINTERFACE_ENTRY(IFolderArchiveProperties) MY_QUERYINTERFACE_ENTRY(IFolderArcProps)
#ifndef EXTRACT_ONLY #ifndef EXTRACT_ONLY
MY_QUERYINTERFACE_ENTRY(IOutFolderArchive) MY_QUERYINTERFACE_ENTRY(IOutFolderArchive)
MY_QUERYINTERFACE_ENTRY(ISetProperties) MY_QUERYINTERFACE_ENTRY(ISetProperties)
@@ -151,7 +151,7 @@ public:
MY_ADDREF_RELEASE MY_ADDREF_RELEASE
INTERFACE_IInFolderArchive(;) INTERFACE_IInFolderArchive(;)
INTERFACE_IFolderArchiveProperties(;) INTERFACE_IFolderArcProps(;)
#ifndef EXTRACT_ONLY #ifndef EXTRACT_ONLY
INTERFACE_IOutFolderArchive(;) INTERFACE_IOutFolderArchive(;)

View File

@@ -34,7 +34,8 @@ int CArchiveFolderManager::FindFormat(const UString &type)
return -1; return -1;
} }
STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream, const wchar_t *filePath, STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream,
const wchar_t *filePath, const wchar_t *arcFormat,
IFolderFolder **resultFolder, IProgress *progress) IFolderFolder **resultFolder, IProgress *progress)
{ {
CMyComPtr<IArchiveOpenCallback> openArchiveCallback; CMyComPtr<IArchiveOpenCallback> openArchiveCallback;
@@ -45,7 +46,7 @@ STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream, const wc
} }
CAgent *agent = new CAgent(); CAgent *agent = new CAgent();
CMyComPtr<IInFolderArchive> archive = agent; CMyComPtr<IInFolderArchive> archive = agent;
RINOK(agent->Open(inStream, filePath, NULL, openArchiveCallback)); RINOK(agent->Open(inStream, filePath, arcFormat, NULL, openArchiveCallback));
return agent->BindToRootFolder(resultFolder); return agent->BindToRootFolder(resultFolder);
} }

View File

@@ -27,7 +27,7 @@ FOLDER_ARCHIVE_INTERFACE(IArchiveFolder, 0x05)
}; };
#define INTERFACE_IInFolderArchive(x) \ #define INTERFACE_IInFolderArchive(x) \
STDMETHOD(Open)(IInStream *inStream, const wchar_t *filePath, BSTR *archiveType, IArchiveOpenCallback *openArchiveCallback) x; \ STDMETHOD(Open)(IInStream *inStream, const wchar_t *filePath, const wchar_t *arcFormat, BSTR *archiveTypeRes, IArchiveOpenCallback *openArchiveCallback) x; \
STDMETHOD(ReOpen)(IArchiveOpenCallback *openArchiveCallback) x; \ STDMETHOD(ReOpen)(IArchiveOpenCallback *openArchiveCallback) x; \
STDMETHOD(Close)() x; \ STDMETHOD(Close)() x; \
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
@@ -37,7 +37,7 @@ FOLDER_ARCHIVE_INTERFACE(IArchiveFolder, 0x05)
NExtract::NOverwriteMode::EEnum overwriteMode, const wchar_t *path, \ NExtract::NOverwriteMode::EEnum overwriteMode, const wchar_t *path, \
Int32 testMode, IFolderArchiveExtractCallback *extractCallback2) x; \ Int32 testMode, IFolderArchiveExtractCallback *extractCallback2) x; \
FOLDER_ARCHIVE_INTERFACE(IInFolderArchive, 0x0D) FOLDER_ARCHIVE_INTERFACE(IInFolderArchive, 0x0E)
{ {
INTERFACE_IInFolderArchive(PURE) INTERFACE_IInFolderArchive(PURE)
}; };

View File

@@ -696,9 +696,13 @@ HRESULT LzmaBench(
const UInt32 kLzmaId = 0x030101; const UInt32 kLzmaId = 0x030101;
RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS kLzmaId, encoder.encoder, true)); RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS kLzmaId, encoder.encoder, true));
if (!encoder.encoder)
return E_NOTIMPL;
for (UInt32 j = 0; j < numSubDecoderThreads; j++) for (UInt32 j = 0; j < numSubDecoderThreads; j++)
{ {
RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS kLzmaId, encoder.decoders[j], false)); RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS kLzmaId, encoder.decoders[j], false));
if (!encoder.decoders[j])
return E_NOTIMPL;
} }
} }

View File

@@ -160,6 +160,14 @@ SOURCE=.\StdAfx.h
# PROP Default_Filter "" # PROP Default_Filter ""
# Begin Source File # Begin Source File
SOURCE=.\BenchCon.cpp
# End Source File
# Begin Source File
SOURCE=.\BenchCon.h
# End Source File
# Begin Source File
SOURCE=.\ConsoleClose.cpp SOURCE=.\ConsoleClose.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -184,14 +192,6 @@ SOURCE=.\List.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\BenchCon.cpp
# End Source File
# Begin Source File
SOURCE=.\BenchCon.h
# End Source File
# Begin Source File
SOURCE=.\Main.cpp SOURCE=.\Main.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -364,10 +364,6 @@ SOURCE=..\..\..\Common\Defs.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\..\Common\Exception.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\IntToString.cpp SOURCE=..\..\..\Common\IntToString.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -488,7 +484,11 @@ SOURCE=..\Common\ArchiveOpenCallback.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\Common\CompressionMode.h SOURCE=..\Common\Bench.cpp
# End Source File
# Begin Source File
SOURCE=..\Common\Bench.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -532,10 +532,6 @@ SOURCE=..\Common\ExtractingFilePath.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\Common\HandlerLoader.h
# End Source File
# Begin Source File
SOURCE=..\Common\IFileExtractCallback.h SOURCE=..\Common\IFileExtractCallback.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -548,14 +544,6 @@ SOURCE=..\Common\LoadCodecs.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\Common\Bench.cpp
# End Source File
# Begin Source File
SOURCE=..\Common\Bench.h
# End Source File
# Begin Source File
SOURCE=..\Common\OpenArchive.cpp SOURCE=..\Common\OpenArchive.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -502,7 +502,7 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
{ {
const CArc &arc = archiveLink.Arcs[i]; const CArc &arc = archiveLink.Arcs[i];
g_StdOut << "----\n"; g_StdOut << "--\n";
PrintPropPair(L"Path", arc.Path); PrintPropPair(L"Path", arc.Path);
PrintPropPair(L"Type", codecs->Formats[arc.FormatIndex].Name); PrintPropPair(L"Type", codecs->Formats[arc.FormatIndex].Name);
UInt32 numProps; UInt32 numProps;
@@ -524,6 +524,30 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
PrintPropPair(GetPropName(propID, name), s); PrintPropPair(GetPropName(propID, name), s);
} }
} }
if (i != archiveLink.Arcs.Size() - 1)
{
UInt32 numProps;
g_StdOut << "----\n";
if (archive->GetNumberOfProperties(&numProps) == S_OK)
{
UInt32 mainIndex = archiveLink.Arcs[i + 1].SubfileIndex;
for (UInt32 j = 0; j < numProps; j++)
{
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
if (archive->GetPropertyInfo(j, &name, &propID, &vt) != S_OK)
continue;
NCOM::CPropVariant prop;
if (archive->GetProperty(mainIndex, propID, &prop) != S_OK)
continue;
UString s = ConvertPropertyToString(prop, propID);
if (!s.IsEmpty())
PrintPropPair(GetPropName(propID, name), s);
}
}
}
} }
g_StdOut << endl; g_StdOut << endl;
if (techMode) if (techMode)

View File

@@ -94,11 +94,10 @@ STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT
return GetFileNames(dataObject, _fileNames); return GetFileNames(dataObject, _fileNames);
} }
STDMETHODIMP CZipContextMenu::InitContextMenu(const wchar_t * /* folder */, HRESULT CZipContextMenu::InitContextMenu(const wchar_t * /* folder */, const wchar_t **names, UInt32 numFiles)
const wchar_t **names, UINT32 numFiles)
{ {
_fileNames.Clear(); _fileNames.Clear();
for (UINT32 i = 0; i < numFiles; i++) for (UInt32 i = 0; i < numFiles; i++)
_fileNames.Add(names[i]); _fileNames.Add(names[i]);
_dropMode = false; _dropMode = false;
return S_OK; return S_OK;
@@ -124,12 +123,12 @@ static LPCTSTR kCompressToEmailVerb = TEXT("SevenCompressToEmail");
struct CContextMenuCommand struct CContextMenuCommand
{ {
UINT32 flag; UInt32 flag;
CZipContextMenu::ECommandInternalID CommandInternalID; CZipContextMenu::ECommandInternalID CommandInternalID;
LPCWSTR Verb; LPCWSTR Verb;
UINT ResourceID; UINT ResourceID;
UINT ResourceHelpID; UINT ResourceHelpID;
UINT32 LangID; UInt32 LangID;
}; };
static CContextMenuCommand g_Commands[] = static CContextMenuCommand g_Commands[] =
@@ -224,7 +223,7 @@ static CContextMenuCommand g_Commands[] =
} }
}; };
int FindCommand(CZipContextMenu::ECommandInternalID &id) static int FindCommand(CZipContextMenu::ECommandInternalID &id)
{ {
for (int i = 0; i < sizeof(g_Commands) / sizeof(g_Commands[0]); i++) for (int i = 0; i < sizeof(g_Commands) / sizeof(g_Commands[0]); i++)
if (g_Commands[i].CommandInternalID == id) if (g_Commands[i].CommandInternalID == id)
@@ -336,6 +335,9 @@ static const char *kExtractExludeExtensions =
" xml xsd xsl xslt" " xml xsd xsl xslt"
" "; " ";
static const char *kNoOpenAsExtensions =
" 7z arj bz2 cab chm cpio dmg flv gz lha lzh lzma rar swm tar tbz2 tgz wim xar xz z zip ";
static bool FindExt(const char *p, const UString &name) static bool FindExt(const char *p, const UString &name)
{ {
int extPos = name.ReverseFind('.'); int extPos = name.ReverseFind('.');
@@ -415,40 +417,55 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if (!fileInfo.IsDir() && DoNeedExtract(fileInfo.Name)) if (!fileInfo.IsDir() && DoNeedExtract(fileInfo.Name))
{ {
// Open // Open
if ((contextMenuFlags & NContextMenuFlags::kOpen) != 0) bool thereIsMainOpenItem = ((contextMenuFlags & NContextMenuFlags::kOpen) != 0);
if (thereIsMainOpenItem)
{ {
CCommandMapItem commandMapItem; CCommandMapItem commandMapItem;
FillCommand(kOpen, mainString, commandMapItem); FillCommand(kOpen, mainString, commandMapItem);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
}
/* if ((contextMenuFlags & NContextMenuFlags::kOpenAs) != 0 &&
if (FindExt(" exe dll ", fileInfo.Name)) (!thereIsMainOpenItem || !FindExt(kNoOpenAsExtensions, fileInfo.Name)))
{
CMenu subMenu;
if (subMenu.CreatePopup())
{ {
CMenu subMenu; CCommandMapItem commandMapItem;
if (subMenu.CreatePopup())
CMenuItem menuItem;
menuItem.fType = MFT_STRING;
menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
menuItem.wID = currentCommandID++;
menuItem.hSubMenu = subMenu;
menuItem.StringValue = LangString(IDS_CONTEXT_OPEN, 0x02000103);
popupMenu.InsertItem(subIndex++, true, menuItem);
commandMapItem.CommandInternalID = kCommandNULL;
commandMapItem.Verb = kMainVerb;
commandMapItem.HelpString = LangString(IDS_CONTEXT_OPEN_HELP, 0x02000104);
_commandMap.Add(commandMapItem);
UINT subIndex2 = 0;
const wchar_t *exts[] = { L"", L"*", L"7z", L"zip", L"cab", L"rar" };
for (int i = (thereIsMainOpenItem ? 1 : 0); i < sizeof(exts) / sizeof(exts[0]); i++)
{ {
CMenuItem menuItem; CCommandMapItem commandMapItem;
menuItem.fType = MFT_STRING; if (i == 0)
menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID; FillCommand(kOpen, mainString, commandMapItem);
menuItem.wID = currentCommandID++; else
menuItem.hSubMenu = subMenu;
menuItem.StringValue = LangString(IDS_CONTEXT_OPEN, 0x02000103);
popupMenu.InsertItem(subIndex++, true, menuItem);
const wchar_t *exts[] = { L"7z", L"cab", L"rar", L"zip", L"pe" };
for (int i = 0; i < sizeof(exts) / sizeof(exts[0]); i++)
{ {
CCommandMapItem commandMapItem;
FillCommand(kOpenAs, mainString, commandMapItem);
mainString = exts[i]; mainString = exts[i];
commandMapItem.ArchiveType = mainString; commandMapItem.CommandInternalID = kOpen;
MyInsertMenu(subMenu, subIndex++, currentCommandID++, mainString); commandMapItem.Verb = (UString)kMainVerb + L".Open." + mainString;
_commandMap.Add(commandMapItem); commandMapItem.HelpString = mainString;
commandMapItem.ArcType = mainString;
} }
subMenu.Detach(); MyInsertMenu(subMenu, subIndex2++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
} }
subMenu.Detach();
} }
*/
} }
} }
} }
@@ -542,7 +559,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Folder = _dropPath; commandMapItem.Folder = _dropPath;
else else
commandMapItem.Folder = archivePathPrefix; commandMapItem.Folder = archivePathPrefix;
commandMapItem.Archive = archiveName; commandMapItem.ArcName = archiveName;
FillCommand(kCompress, mainString, commandMapItem); FillCommand(kCompress, mainString, commandMapItem);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
@@ -553,7 +570,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if ((contextMenuFlags & NContextMenuFlags::kCompressEmail) != 0 && !_dropMode) if ((contextMenuFlags & NContextMenuFlags::kCompressEmail) != 0 && !_dropMode)
{ {
CCommandMapItem commandMapItem; CCommandMapItem commandMapItem;
commandMapItem.Archive = archiveName; commandMapItem.ArcName = archiveName;
FillCommand(kCompressEmail, mainString, commandMapItem); FillCommand(kCompressEmail, mainString, commandMapItem);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
@@ -570,8 +587,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Folder = _dropPath; commandMapItem.Folder = _dropPath;
else else
commandMapItem.Folder = archivePathPrefix; commandMapItem.Folder = archivePathPrefix;
commandMapItem.Archive = archiveName7z; commandMapItem.ArcName = archiveName7z;
commandMapItem.ArchiveType = L"7z"; commandMapItem.ArcType = L"7z";
s = MyFormatNew(s, GetQuotedReducedString(archiveName7z)); s = MyFormatNew(s, GetQuotedReducedString(archiveName7z));
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
@@ -584,8 +601,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
CCommandMapItem commandMapItem; CCommandMapItem commandMapItem;
UString s; UString s;
FillCommand(kCompressTo7zEmail, s, commandMapItem); FillCommand(kCompressTo7zEmail, s, commandMapItem);
commandMapItem.Archive = archiveName7z; commandMapItem.ArcName = archiveName7z;
commandMapItem.ArchiveType = L"7z"; commandMapItem.ArcType = L"7z";
s = MyFormatNew(s, GetQuotedReducedString(archiveName7z)); s = MyFormatNew(s, GetQuotedReducedString(archiveName7z));
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
@@ -602,8 +619,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Folder = _dropPath; commandMapItem.Folder = _dropPath;
else else
commandMapItem.Folder = archivePathPrefix; commandMapItem.Folder = archivePathPrefix;
commandMapItem.Archive = archiveNameZip; commandMapItem.ArcName = archiveNameZip;
commandMapItem.ArchiveType = L"zip"; commandMapItem.ArcType = L"zip";
s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip)); s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip));
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
@@ -616,8 +633,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
CCommandMapItem commandMapItem; CCommandMapItem commandMapItem;
UString s; UString s;
FillCommand(kCompressToZipEmail, s, commandMapItem); FillCommand(kCompressToZipEmail, s, commandMapItem);
commandMapItem.Archive = archiveNameZip; commandMapItem.ArcName = archiveNameZip;
commandMapItem.ArchiveType = L"zip"; commandMapItem.ArcType = L"zip";
s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip)); s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip));
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
@@ -691,15 +708,21 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
return E_FAIL; return E_FAIL;
const CCommandMapItem commandMapItem = _commandMap[commandOffset]; const CCommandMapItem commandMapItem = _commandMap[commandOffset];
ECommandInternalID commandInternalID = commandMapItem.CommandInternalID; ECommandInternalID cmdID = commandMapItem.CommandInternalID;
try try
{ {
switch(commandInternalID) switch(cmdID)
{ {
case kOpen: case kOpen:
{ {
UString params = GetQuotedString(_fileNames[0]); UString params;
params = GetQuotedString(_fileNames[0]);
if (commandMapItem.ArcType)
{
params += L" -t";
params += commandMapItem.ArcType;
}
MyCreateProcess(Get7zFmPath(), params); MyCreateProcess(Get7zFmPath(), params);
break; break;
} }
@@ -707,7 +730,7 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
case kExtractHere: case kExtractHere:
case kExtractTo: case kExtractTo:
{ {
ExtractArchives(_fileNames, commandMapItem.Folder, (commandInternalID == kExtract)); ExtractArchives(_fileNames, commandMapItem.Folder, (cmdID == kExtract));
break; break;
} }
case kTest: case kTest:
@@ -723,14 +746,14 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
case kCompressToZipEmail: case kCompressToZipEmail:
{ {
bool email = bool email =
(commandInternalID == kCompressEmail) || (cmdID == kCompressEmail) ||
(commandInternalID == kCompressTo7zEmail) || (cmdID == kCompressTo7zEmail) ||
(commandInternalID == kCompressToZipEmail); (cmdID == kCompressToZipEmail);
bool showDialog = bool showDialog =
(commandInternalID == kCompress) || (cmdID == kCompress) ||
(commandInternalID == kCompressEmail); (cmdID == kCompressEmail);
CompressFiles(commandMapItem.Folder, CompressFiles(commandMapItem.Folder,
commandMapItem.Archive, commandMapItem.ArchiveType, commandMapItem.ArcName, commandMapItem.ArcType,
_fileNames, email, showDialog, false); _fileNames, email, showDialog, false);
break; break;
} }

View File

@@ -3,20 +3,13 @@
#ifndef __CONTEXT_MENU_H #ifndef __CONTEXT_MENU_H
#define __CONTEXT_MENU_H #define __CONTEXT_MENU_H
// {23170F69-40C1-278A-1000-000100020000}
DEFINE_GUID(CLSID_CZipContextMenu,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
#include "Common/MyString.h" #include "Common/MyString.h"
#include "../FileManager/PluginInterface.h"
#include "../FileManager/MyCom2.h" #include "../FileManager/MyCom2.h"
class CZipContextMenu: class CZipContextMenu:
public IContextMenu, public IContextMenu,
public IShellExtInit, public IShellExtInit,
public IInitContextMenu,
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
@@ -37,17 +30,7 @@ public:
kCompressToZipEmail kCompressToZipEmail
}; };
struct CCommandMapItem MY_UNKNOWN_IMP2_MT(IContextMenu, IShellExtInit)
{
ECommandInternalID CommandInternalID;
UString Verb;
UString HelpString;
UString Folder;
UString Archive;
UString ArchiveType;
};
MY_UNKNOWN_IMP3_MT(IContextMenu, IShellExtInit, IInitContextMenu)
// IShellExtInit // IShellExtInit
STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT dataObject, HKEY hkeyProgID); STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT dataObject, HKEY hkeyProgID);
@@ -57,22 +40,31 @@ public:
STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici); STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici);
STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax); STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);
// IInitContextMenu HRESULT InitContextMenu(const wchar_t *folder, const wchar_t **names, UINT32 numFiles);
STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UINT32 numFiles);
CZipContextMenu();
~CZipContextMenu();
private: private:
struct CCommandMapItem
{
ECommandInternalID CommandInternalID;
UString Verb;
UString HelpString;
UString Folder;
UString ArcName;
UString ArcType;
};
UStringVector _fileNames; UStringVector _fileNames;
bool _dropMode; bool _dropMode;
UString _dropPath; UString _dropPath;
CObjectVector<CCommandMapItem> _commandMap; CObjectVector<CCommandMapItem> _commandMap;
HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames); HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames);
int FindVerb(const UString &verb); int FindVerb(const UString &verb);
void FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem); void FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem);
public:
CZipContextMenu();
~CZipContextMenu();
}; };
#endif #endif

View File

@@ -1,34 +1,24 @@
// ContextMenuFlags.h // ContextMenuFlags.h
#ifndef __SEVENZIP_CONTEXTMENUFLAGS_H #ifndef __CONTEXT_MENU_FLAGS_H
#define __SEVENZIP_CONTEXTMENUFLAGS_H #define __CONTEXT_MENU_FLAGS_H
namespace NContextMenuFlags namespace NContextMenuFlags
{ {
const UINT32 kExtract = 1 << 0; const UInt32 kExtract = 1 << 0;
const UINT32 kExtractHere = 1 << 1; const UInt32 kExtractHere = 1 << 1;
const UINT32 kExtractTo = 1 << 2; const UInt32 kExtractTo = 1 << 2;
// const UINT32 kExtractEach = 1 << 3;
const UINT32 kTest = 1 << 4; const UInt32 kTest = 1 << 4;
const UInt32 kOpen = 1 << 5;
const UInt32 kOpenAs = 1 << 6;
const UINT32 kOpen = 1 << 5; const UInt32 kCompress = 1 << 8;
const UInt32 kCompressTo7z = 1 << 9;
const UINT32 kCompress = 1 << 8; const UInt32 kCompressEmail = 1 << 10;
const UINT32 kCompressTo7z = 1 << 9; const UInt32 kCompressTo7zEmail = 1 << 11;
const UINT32 kCompressEmail = 1 << 10; const UInt32 kCompressToZip = 1 << 12;
const UINT32 kCompressTo7zEmail = 1 << 11; const UInt32 kCompressToZipEmail = 1 << 13;
const UINT32 kCompressToZip = 1 << 12;
const UINT32 kCompressToZipEmail = 1 << 13;
inline UINT32 GetDefaultFlags() {
return
kOpen | kTest |
kExtract | kExtractHere | kExtractTo |
kCompress | kCompressEmail |
kCompressTo7z | kCompressTo7zEmail |
kCompressToZip | kCompressToZipEmail; }
} }
#endif #endif

View File

@@ -26,6 +26,10 @@
#include "ContextMenu.h" #include "ContextMenu.h"
// {23170F69-40C1-278A-1000-000100020000}
DEFINE_GUID(CLSID_CZipContextMenu,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
using namespace NWindows; using namespace NWindows;
HINSTANCE g_hInstance = 0; HINSTANCE g_hInstance = 0;

View File

@@ -365,7 +365,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
archiveHandler = new CAgent; archiveHandler = new CAgent;
CMyComBSTR archiveType; CMyComBSTR archiveType;
HRESULT result = archiveHandler->Open(NULL, HRESULT result = archiveHandler->Open(NULL,
GetUnicodeString(fullName, CP_OEMCP), &archiveType, openArchiveCallback); GetUnicodeString(fullName, CP_OEMCP), UString(), &archiveType, openArchiveCallback);
/* /*
HRESULT result = ::OpenArchive(fullName, &archiveHandler, HRESULT result = ::OpenArchive(fullName, &archiveHandler,
archiverInfoResult, defaultName, openArchiveCallback); archiverInfoResult, defaultName, openArchiveCallback);

View File

@@ -20,6 +20,7 @@ enum EEnum
kYes, kYes,
kNo, kNo,
kPath,
kName, kName,
kExtension, kExtension,
kIsFolder, kIsFolder,

View File

@@ -275,6 +275,7 @@ struct CPROPIDToName
static CPROPIDToName kPROPIDToName[] = static CPROPIDToName kPROPIDToName[] =
{ {
{ kpidPath, NMessageID::kPath },
{ kpidName, NMessageID::kName }, { kpidName, NMessageID::kName },
{ kpidExtension, NMessageID::kExtension }, { kpidExtension, NMessageID::kExtension },
{ kpidIsDir, NMessageID::kIsFolder }, { kpidIsDir, NMessageID::kIsFolder },
@@ -501,6 +502,32 @@ static AString PropToString2(const NCOM::CPropVariant &prop, PROPID propID)
return s; return s;
} }
static void AddPropertyString(InfoPanelLine *lines, int &numItems, PROPID propID, const wchar_t *name,
const NCOM::CPropVariant &prop)
{
if (prop.vt != VT_EMPTY)
{
AString val = PropToString2(prop, propID);
if (!val.IsEmpty())
{
InfoPanelLine &item = lines[numItems++];
COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name));
COPY_STR_LIMITED(item.Data, val);
}
}
}
static void InsertSeparator(InfoPanelLine *lines, int &numItems)
{
if (numItems < kNumInfoLinesMax)
{
InfoPanelLine &item = lines[numItems++];
MyStringCopy(item.Text, "");
MyStringCopy(item.Data, "");
item.Separator = TRUE;
}
}
void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
{ {
info->StructSize = sizeof(*info); info->StructSize = sizeof(*info);
@@ -574,44 +601,71 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
} }
} }
/*
if (numItems < kNumInfoLinesMax) if (numItems < kNumInfoLinesMax)
{ {
InfoPanelLine &item = m_InfoLines[numItems++]; InsertSeparator(m_InfoLines, numItems);
MyStringCopy(item.Text, "");
MyStringCopy(item.Data, "");
item.Separator = TRUE;
} }
*/
{ {
CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties; CMyComPtr<IGetFolderArcProps> getFolderArcProps;
_folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties); _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
if (getFolderArchiveProperties) if (getFolderArcProps)
{ {
CMyComPtr<IFolderArchiveProperties> getProps; CMyComPtr<IFolderArcProps> getProps;
getFolderArchiveProperties->GetFolderArchiveProperties(&getProps); getFolderArcProps->GetFolderArcProps(&getProps);
if (getProps) if (getProps)
{ {
UInt32 numProps; UInt32 numLevels;
if (getProps->GetNumberOfArchiveProperties(&numProps) == S_OK) if (getProps->GetArcNumLevels(&numLevels) != S_OK)
numLevels = 0;
for (UInt32 level2 = 0; level2 < numLevels; level2++)
{ {
/*
if (numProps > 0)
message += kSeparator;
*/
for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++)
{ {
CMyComBSTR name; UInt32 level = numLevels - 1 - level2;
PROPID propID; UInt32 numProps;
VARTYPE vt; if (getProps->GetArcNumProps(level, &numProps) == S_OK)
if (getProps->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK) {
continue; InsertSeparator(m_InfoLines, numItems);
NCOM::CPropVariant prop; for (Int32 i = -2; i < (Int32)numProps && numItems < kNumInfoLinesMax; i++)
if (getProps->GetArchiveProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY) {
continue; CMyComBSTR name;
InfoPanelLine &item = m_InfoLines[numItems++]; PROPID propID;
COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name)); VARTYPE vt;
COPY_STR_LIMITED(item.Data, PropToString2(prop, propID)); if (i == -2)
propID = kpidPath;
else if (i == -1)
propID = kpidType;
else if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK)
continue;
NCOM::CPropVariant prop;
if (getProps->GetArcProp(level, propID, &prop) != S_OK)
continue;
AddPropertyString(m_InfoLines, numItems, propID, name, prop);
}
}
}
if (level2 != numLevels - 1)
{
UInt32 level = numLevels - 1 - level2;
UInt32 numProps;
if (getProps->GetArcNumProps2(level, &numProps) == S_OK)
{
InsertSeparator(m_InfoLines, numItems);
for (Int32 i = 0; i < (Int32)numProps && numItems < kNumInfoLinesMax; i++)
{
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
if (getProps->GetArcPropInfo2(level, i, &name, &propID, &vt) != S_OK)
continue;
NCOM::CPropVariant prop;
if (getProps->GetArcProp2(level, propID, &prop) != S_OK)
continue;
AddPropertyString(m_InfoLines, numItems, propID, name, prop);
}
}
} }
} }
} }

View File

@@ -692,7 +692,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
// CLSID realClassID; // CLSID realClassID;
CMyComBSTR archiveType; CMyComBSTR archiveType;
RINOK(agentSpec->Open(NULL, RINOK(agentSpec->Open(NULL,
GetUnicodeString(fullArchiveName, CP_OEMCP), GetUnicodeString(fullArchiveName, CP_OEMCP), UString(),
// &realClassID, // &realClassID,
&archiveType, &archiveType,
NULL)); NULL));

View File

@@ -107,7 +107,8 @@ void CApp::SetShowSystemMenu()
#define ILC_COLOR32 0x0020 #define ILC_COLOR32 0x0020
#endif #endif
HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted) HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat,
bool &archiveIsOpened, bool &encrypted)
{ {
if (PanelsCreated[panelIndex]) if (PanelsCreated[panelIndex])
return S_OK; return S_OK;
@@ -122,7 +123,7 @@ HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &arch
path = mainPath; path = mainPath;
int id = 1000 + 100 * panelIndex; int id = 1000 + 100 * panelIndex;
RINOK(Panels[panelIndex].Create(_window, _window, RINOK(Panels[panelIndex].Create(_window, _window,
id, path, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted)); id, path, arcFormat, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted));
PanelsCreated[panelIndex] = true; PanelsCreated[panelIndex] = true;
return S_OK; return S_OK;
} }
@@ -269,7 +270,7 @@ void CApp::SaveToolbarChanges()
void MyLoadMenu(); void MyLoadMenu();
HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted) HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool &archiveIsOpened, bool &encrypted)
{ {
_window.Attach(hwnd); _window.Attach(hwnd);
#ifdef UNDER_CE #ifdef UNDER_CE
@@ -310,7 +311,7 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &ar
bool archiveIsOpened2 = false; bool archiveIsOpened2 = false;
bool encrypted2 = false; bool encrypted2 = false;
bool mainPanel = (i == LastFocusedPanel); bool mainPanel = (i == LastFocusedPanel);
RINOK(CreateOnePanel(i, mainPanel ? mainPath : L"", archiveIsOpened2, encrypted2)); RINOK(CreateOnePanel(i, mainPanel ? mainPath : L"", arcFormat, archiveIsOpened2, encrypted2));
if (mainPanel) if (mainPanel)
{ {
archiveIsOpened = archiveIsOpened2; archiveIsOpened = archiveIsOpened2;
@@ -328,7 +329,7 @@ HRESULT CApp::SwitchOnOffOnePanel()
{ {
NumPanels++; NumPanels++;
bool archiveIsOpened, encrypted; bool archiveIsOpened, encrypted;
RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), archiveIsOpened, encrypted)); RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), UString(), archiveIsOpened, encrypted));
Panels[1 - LastFocusedPanel].Enable(true); Panels[1 - LastFocusedPanel].Enable(true);
Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL); Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
} }
@@ -596,8 +597,10 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
} }
#endif #endif
if (indices.Size() > 1 || (!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) || if (indices.Size() > 1 ||
NFind::DoesDirExist(destPath)) (!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) ||
NFind::DoesDirExist(destPath) ||
srcPanel.IsArcFolder())
{ {
NDirectory::CreateComplexDirectory(destPath); NDirectory::CreateComplexDirectory(destPath);
NName::NormalizeDirPathPrefix(destPath); NName::NormalizeDirPathPrefix(destPath);

View File

@@ -161,8 +161,8 @@ public:
void OnSetSameFolder(int srcPanelIndex); void OnSetSameFolder(int srcPanelIndex);
void OnSetSubFolder(int srcPanelIndex); void OnSetSubFolder(int srcPanelIndex);
HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted); HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted);
HRESULT Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted); HRESULT Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool &archiveIsOpened, bool &encrypted);
void Read(); void Read();
void Save(); void Save();
void Release(); void Release();

View File

@@ -4,8 +4,4 @@
#include "Common/MyInitGuid.h" #include "Common/MyInitGuid.h"
#include "PluginInterface.h"
#include "../Agent/Agent.h" #include "../Agent/Agent.h"
DEFINE_GUID(CLSID_CZipContextMenu,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);

View File

@@ -37,6 +37,7 @@ HINSTANCE g_hInstance;
HWND g_HWND; HWND g_HWND;
bool g_OpenArchive = false; bool g_OpenArchive = false;
static UString g_MainPath; static UString g_MainPath;
static UString g_ArcFormat;
static bool g_Maximized = false; static bool g_Maximized = false;
#ifndef UNDER_CE #ifndef UNDER_CE
@@ -443,7 +444,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
UString paramString, tailString; UString paramString, tailString;
SplitStringToTwoStrings(commandsString, paramString, tailString); SplitStringToTwoStrings(commandsString, paramString, tailString);
paramString.Trim(); paramString.Trim();
tailString.Trim();
if (tailString.Left(2) == L"-t")
g_ArcFormat = tailString.Mid(2);
if (!paramString.IsEmpty()) if (!paramString.IsEmpty())
{ {
g_MainPath = paramString; g_MainPath = paramString;
@@ -639,7 +642,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (NFile::NFind::DoesFileExist(g_MainPath)) if (NFile::NFind::DoesFileExist(g_MainPath))
needOpenFile = true; needOpenFile = true;
} }
HRESULT res = g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted); HRESULT res = g_App.Create(hWnd, g_MainPath, g_ArcFormat, xSizes, archiveIsOpened, encrypted);
if (res == E_ABORT) if (res == E_ABORT)
{ {

View File

@@ -442,14 +442,6 @@ SOURCE=.\OptionsDialog.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\PluginsPage.cpp
# End Source File
# Begin Source File
SOURCE=.\PluginsPage.h
# End Source File
# Begin Source File
SOURCE=.\SettingsPage.cpp SOURCE=.\SettingsPage.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -20,6 +20,7 @@ using namespace NRegistryAssociations;
struct CThreadArchiveOpen struct CThreadArchiveOpen
{ {
UString Path; UString Path;
UString ArcFormat;
CMyComPtr<IInStream> InStream; CMyComPtr<IInStream> InStream;
CMyComPtr<IFolderManager> FolderManager; CMyComPtr<IFolderManager> FolderManager;
CMyComPtr<IProgress> OpenCallback; CMyComPtr<IProgress> OpenCallback;
@@ -33,7 +34,7 @@ struct CThreadArchiveOpen
try try
{ {
CProgressCloser closer(OpenCallbackSpec->ProgressDialog); CProgressCloser closer(OpenCallbackSpec->ProgressDialog);
Result = FolderManager->OpenFolderFile(InStream, Path, &Folder, OpenCallback); Result = FolderManager->OpenFolderFile(InStream, Path, ArcFormat, &Folder, OpenCallback);
} }
catch(...) { Result = E_FAIL; } catch(...) { Result = E_FAIL; }
} }
@@ -58,6 +59,7 @@ static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &
HRESULT OpenFileFolderPlugin( HRESULT OpenFileFolderPlugin(
IInStream *inStream, IInStream *inStream,
const UString &path, const UString &path,
const UString &arcFormat,
HMODULE *module, HMODULE *module,
IFolderFolder **resultFolder, IFolderFolder **resultFolder,
HWND parentWindow, HWND parentWindow,
@@ -128,6 +130,7 @@ HRESULT OpenFileFolderPlugin(
t.InStream = inStream; t.InStream = inStream;
t.Path = path; t.Path = path;
t.ArcFormat = arcFormat;
UString progressTitle = LangString(IDS_OPENNING, 0x03020283); UString progressTitle = LangString(IDS_OPENNING, 0x03020283);
t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow; t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow;

View File

@@ -3,7 +3,7 @@
#ifndef __FILE_FOLDER_PLUGIN_OPEN_H #ifndef __FILE_FOLDER_PLUGIN_OPEN_H
#define __FILE_FOLDER_PLUGIN_OPEN_H #define __FILE_FOLDER_PLUGIN_OPEN_H
HRESULT OpenFileFolderPlugin(IInStream *inStream, const UString &path, HRESULT OpenFileFolderPlugin(IInStream *inStream, const UString &path, const UString &arcFormat,
HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password); HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password);
#endif #endif

View File

@@ -112,32 +112,36 @@ FOLDER_INTERFACE(IFolderProperties, 0x0E)
INTERFACE_FolderProperties(PURE) INTERFACE_FolderProperties(PURE)
}; };
#define INTERFACE_IFolderArchiveProperties(x) \ #define INTERFACE_IFolderArcProps(x) \
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) x; \ STDMETHOD(GetArcNumLevels)(UInt32 *numLevels) x; \
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) x; \ STDMETHOD(GetArcProp)(UInt32 level, PROPID propID, PROPVARIANT *value) x; \
STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; STDMETHOD(GetArcNumProps)(UInt32 level, UInt32 *numProps) x; \
STDMETHOD(GetArcPropInfo)(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
STDMETHOD(GetArcProp2)(UInt32 level, PROPID propID, PROPVARIANT *value) x; \
STDMETHOD(GetArcNumProps2)(UInt32 level, UInt32 *numProps) x; \
STDMETHOD(GetArcPropInfo2)(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
FOLDER_INTERFACE(IFolderArchiveProperties, 0x0C) FOLDER_INTERFACE(IFolderArcProps, 0x10)
{ {
INTERFACE_IFolderArchiveProperties(PURE) INTERFACE_IFolderArcProps(PURE)
}; };
FOLDER_INTERFACE(IGetFolderArchiveProperties, 0x0D) FOLDER_INTERFACE(IGetFolderArcProps, 0x11)
{ {
STDMETHOD(GetFolderArchiveProperties)(IFolderArchiveProperties **object) PURE; STDMETHOD(GetFolderArcProps)(IFolderArcProps **object) PURE;
}; };
#define FOLDER_MANAGER_INTERFACE(i, x) DECL_INTERFACE(i, 9, x) #define FOLDER_MANAGER_INTERFACE(i, x) DECL_INTERFACE(i, 9, x)
#define INTERFACE_IFolderManager(x) \ #define INTERFACE_IFolderManager(x) \
STDMETHOD(OpenFolderFile)(IInStream *inStream, const wchar_t *filePath, IFolderFolder **resultFolder, IProgress *progress) x; \ STDMETHOD(OpenFolderFile)(IInStream *inStream, const wchar_t *filePath, const wchar_t *arcFormat, IFolderFolder **resultFolder, IProgress *progress) x; \
STDMETHOD(GetExtensions)(BSTR *extensions) x; \ STDMETHOD(GetExtensions)(BSTR *extensions) x; \
STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex) x; \ STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex) x; \
// STDMETHOD(GetTypes)(BSTR *types) PURE; // STDMETHOD(GetTypes)(BSTR *types) PURE;
// STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress) PURE; // STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress) PURE;
FOLDER_MANAGER_INTERFACE(IFolderManager, 0x04) FOLDER_MANAGER_INTERFACE(IFolderManager, 0x05)
{ {
INTERFACE_IFolderManager(PURE); INTERFACE_IFolderManager(PURE);
}; };

View File

@@ -35,6 +35,7 @@ struct CContextMenuItem
static CContextMenuItem kMenuItems[] = static CContextMenuItem kMenuItems[] =
{ {
{ IDS_CONTEXT_OPEN, 0x02000103, kOpen}, { IDS_CONTEXT_OPEN, 0x02000103, kOpen},
{ IDS_CONTEXT_OPEN, 0x02000103, kOpenAs},
{ IDS_CONTEXT_EXTRACT, 0x02000105, kExtract}, { IDS_CONTEXT_EXTRACT, 0x02000105, kExtract},
{ IDS_CONTEXT_EXTRACT_HERE, 0x0200010B, kExtractHere }, { IDS_CONTEXT_EXTRACT_HERE, 0x0200010B, kExtractHere },
{ IDS_CONTEXT_EXTRACT_TO, 0x0200010D, kExtractTo }, { IDS_CONTEXT_EXTRACT_TO, 0x0200010D, kExtractTo },
@@ -83,6 +84,8 @@ bool CMenuPage::OnInit()
CContextMenuItem &menuItem = kMenuItems[i]; CContextMenuItem &menuItem = kMenuItems[i];
UString s = LangString(menuItem.ControlID, menuItem.LangID); UString s = LangString(menuItem.ControlID, menuItem.LangID);
if (menuItem.Flag == kOpenAs)
s += L" >";
switch(menuItem.ControlID) switch(menuItem.ControlID)
{ {

View File

@@ -2,7 +2,7 @@
#include "../../GuiCommon.rc" #include "../../GuiCommon.rc"
#define xc 196 #define xc 196
#define yc 164 #define yc 174
IDD_MENU MY_PAGE IDD_MENU MY_PAGE
#include "MenuPage2.rc" #include "MenuPage2.rc"

View File

@@ -71,7 +71,9 @@ static LPCWSTR kClassName = L"7-Zip::Panel";
HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id, HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
const UString &currentFolderPrefix, CPanelCallback *panelCallback, CAppState *appState, const UString &currentFolderPrefix,
const UString &arcFormat,
CPanelCallback *panelCallback, CAppState *appState,
bool &archiveIsOpened, bool &encrypted) bool &archiveIsOpened, bool &encrypted)
{ {
_mainWindow = mainWindow; _mainWindow = mainWindow;
@@ -91,7 +93,7 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
if (currentFolderPrefix[0] == L'.') if (currentFolderPrefix[0] == L'.')
if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp)) if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp))
cfp = currentFolderPrefix; cfp = currentFolderPrefix;
RINOK(BindToPath(cfp, archiveIsOpened, encrypted)); RINOK(BindToPath(cfp, arcFormat, archiveIsOpened, encrypted));
if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE, if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
0, 0, _xSize, 260, 0, 0, _xSize, 260,
@@ -715,19 +717,18 @@ UString CPanel::GetFolderTypeID() const
return L""; return L"";
} }
bool CPanel::IsRootFolder() const bool CPanel::IsFolderTypeEqTo(const wchar_t *s) const
{ {
return (GetFolderTypeID() == L"RootFolder"); return GetFolderTypeID() == s;
} }
bool CPanel::IsFSFolder() const bool CPanel::IsRootFolder() const { return IsFolderTypeEqTo(L"RootFolder"); }
bool CPanel::IsFSFolder() const { return IsFolderTypeEqTo(L"FSFolder"); }
bool CPanel::IsFSDrivesFolder() const { return IsFolderTypeEqTo(L"FSDrives"); }
bool CPanel::IsArcFolder() const
{ {
return (GetFolderTypeID() == L"FSFolder"); UString s = GetFolderTypeID();
} return s.Left(5) == L"7-Zip";
bool CPanel::IsFSDrivesFolder() const
{
return (GetFolderTypeID() == L"FSDrives");
} }
UString CPanel::GetFsPath() const UString CPanel::GetFsPath() const

View File

@@ -349,7 +349,7 @@ public:
// PanelFolderChange.cpp // PanelFolderChange.cpp
void SetToRootFolder(); void SetToRootFolder();
HRESULT BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted); // can be prefix HRESULT BindToPath(const UString &fullPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted); // can be prefix
HRESULT BindToPathAndRefresh(const UString &path); HRESULT BindToPathAndRefresh(const UString &path);
void OpenDrivesFolder(); void OpenDrivesFolder();
@@ -367,6 +367,7 @@ public:
HRESULT Create(HWND mainWindow, HWND parentWindow, HRESULT Create(HWND mainWindow, HWND parentWindow,
UINT id, UINT id,
const UString &currentFolderPrefix, const UString &currentFolderPrefix,
const UString &arcFormat,
CPanelCallback *panelCallback, CPanelCallback *panelCallback,
CAppState *appState, bool &archiveIsOpened, bool &encrypted); CAppState *appState, bool &archiveIsOpened, bool &encrypted);
void SetFocusToList(); void SetFocusToList();
@@ -465,9 +466,11 @@ public:
void KillSelection(); void KillSelection();
UString GetFolderTypeID() const; UString GetFolderTypeID() const;
bool IsFolderTypeEqTo(const wchar_t *s) const;
bool IsRootFolder() const; bool IsRootFolder() const;
bool IsFSFolder() const; bool IsFSFolder() const;
bool IsFSDrivesFolder() const; bool IsFSDrivesFolder() const;
bool IsArcFolder() const;
bool IsFsOrDrivesFolder() const { return IsFSFolder() || IsFSDrivesFolder(); } bool IsFsOrDrivesFolder() const { return IsFSFolder() || IsFSDrivesFolder(); }
bool IsDeviceDrivesPrefix() const { return _currentFolderPrefix == L"\\\\.\\"; } bool IsDeviceDrivesPrefix() const { return _currentFolderPrefix == L"\\\\.\\"; }
bool IsFsOrPureDrivesFolder() const { return IsFSFolder() || (IsFSDrivesFolder() && !IsDeviceDrivesPrefix()); } bool IsFsOrPureDrivesFolder() const { return IsFSFolder() || (IsFSDrivesFolder() && !IsDeviceDrivesPrefix()); }
@@ -539,8 +542,9 @@ public:
HRESULT OpenItemAsArchive(IInStream *inStream, HRESULT OpenItemAsArchive(IInStream *inStream,
const CTempFileInfo &tempFileInfo, const CTempFileInfo &tempFileInfo,
const UString &virtualFilePath, const UString &virtualFilePath,
const UString &arcFormat,
bool &encrypted); bool &encrypted);
HRESULT OpenItemAsArchive(const UString &name, bool &encrypted); HRESULT OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted);
HRESULT OpenItemAsArchive(int index); HRESULT OpenItemAsArchive(int index);
void OpenItemInArchive(int index, bool tryInternal, bool tryExternal, void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
bool editMode); bool editMode);

View File

@@ -35,7 +35,7 @@ void CPanel::SetToRootFolder()
rootFolderSpec->Init(); rootFolderSpec->Init();
} }
HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted) HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted)
{ {
archiveIsOpened = false; archiveIsOpened = false;
encrypted = false; encrypted = false;
@@ -114,7 +114,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool
UString fileName; UString fileName;
if (NDirectory::GetOnlyName(sysPath, fileName)) if (NDirectory::GetOnlyName(sysPath, fileName))
{ {
HRESULT res = OpenItemAsArchive(fileName, encrypted); HRESULT res = OpenItemAsArchive(fileName, arcFormat, encrypted);
if (res != S_FALSE) if (res != S_FALSE)
{ {
RINOK(res); RINOK(res);
@@ -145,7 +145,7 @@ HRESULT CPanel::BindToPathAndRefresh(const UString &path)
{ {
CDisableTimerProcessing disableTimerProcessing1(*this); CDisableTimerProcessing disableTimerProcessing1(*this);
bool archiveIsOpened, encrypted; bool archiveIsOpened, encrypted;
RINOK(BindToPath(path, archiveIsOpened, encrypted)); RINOK(BindToPath(path, UString(), archiveIsOpened, encrypted));
RefreshListCtrl(UString(), -1, true, UStringVector()); RefreshListCtrl(UString(), -1, true, UStringVector());
return S_OK; return S_OK;
} }

View File

@@ -67,6 +67,7 @@ public:
HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
const CTempFileInfo &tempFileInfo, const CTempFileInfo &tempFileInfo,
const UString &virtualFilePath, const UString &virtualFilePath,
const UString &arcFormat,
bool &encrypted) bool &encrypted)
{ {
encrypted = false; encrypted = false;
@@ -95,6 +96,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
UString password; UString password;
RINOK(OpenFileFolderPlugin(inStream, RINOK(OpenFileFolderPlugin(inStream,
folderLink.FilePath.IsEmpty() ? virtualFilePath : folderLink.FilePath, folderLink.FilePath.IsEmpty() ? virtualFilePath : folderLink.FilePath,
arcFormat,
&library, &newFolder, GetParent(), encrypted, password)); &library, &newFolder, GetParent(), encrypted, password));
folderLink.Password = password; folderLink.Password = password;
@@ -114,20 +116,20 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
return S_OK; return S_OK;
} }
HRESULT CPanel::OpenItemAsArchive(const UString &name, bool &encrypted) HRESULT CPanel::OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted)
{ {
CTempFileInfo tfi; CTempFileInfo tfi;
tfi.ItemName = name; tfi.ItemName = name;
tfi.FolderPath = _currentFolderPrefix; tfi.FolderPath = _currentFolderPrefix;
tfi.FilePath = _currentFolderPrefix + name; tfi.FilePath = _currentFolderPrefix + name;
return OpenItemAsArchive(NULL, tfi, _currentFolderPrefix + name, encrypted); return OpenItemAsArchive(NULL, tfi, _currentFolderPrefix + name, arcFormat, encrypted);
} }
HRESULT CPanel::OpenItemAsArchive(int index) HRESULT CPanel::OpenItemAsArchive(int index)
{ {
CDisableTimerProcessing disableTimerProcessing1(*this); CDisableTimerProcessing disableTimerProcessing1(*this);
bool encrypted; bool encrypted;
RINOK(OpenItemAsArchive(GetItemRelPath(index), encrypted)); RINOK(OpenItemAsArchive(GetItemRelPath(index), UString(), encrypted));
RefreshListCtrl(); RefreshListCtrl();
return S_OK; return S_OK;
} }
@@ -575,7 +577,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
if (subStream) if (subStream)
{ {
bool encrypted; bool encrypted;
if (OpenItemAsArchive(subStream, tempFileInfo, fullVirtPath, encrypted) == S_OK) if (OpenItemAsArchive(subStream, tempFileInfo, fullVirtPath, UString(), encrypted) == S_OK)
{ {
tempDirectory.DisableDeleting(); tempDirectory.DisableDeleting();
RefreshListCtrl(); RefreshListCtrl();
@@ -623,7 +625,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
if (tryAsArchive) if (tryAsArchive)
{ {
bool encrypted; bool encrypted;
if (OpenItemAsArchive(NULL, tempFileInfo, fullVirtPath, encrypted) == S_OK) if (OpenItemAsArchive(NULL, tempFileInfo, fullVirtPath, UString(), encrypted) == S_OK)
{ {
tempDirectory.DisableDeleting(); tempDirectory.DisableDeleting();
RefreshListCtrl(); RefreshListCtrl();

View File

@@ -15,7 +15,6 @@
#include "App.h" #include "App.h"
#include "LangUtils.h" #include "LangUtils.h"
#include "MyLoadMenu.h" #include "MyLoadMenu.h"
#include "PluginInterface.h"
#include "PropertyName.h" #include "PropertyName.h"
#include "resource.h" #include "resource.h"
@@ -24,11 +23,6 @@
using namespace NWindows; using namespace NWindows;
LONG g_DllRefCount = 0; LONG g_DllRefCount = 0;
/*
// {23170F69-40C1-278A-1000-000100020000}
DEFINE_GUID(CLSID_CZipContextMenu,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
*/
static const UINT kSevenZipStartMenuID = kPluginMenuStartID ; static const UINT kSevenZipStartMenuID = kPluginMenuStartID ;
static const UINT kSystemStartMenuID = kPluginMenuStartID + 100; static const UINT kSystemStartMenuID = kPluginMenuStartID + 100;
@@ -55,6 +49,7 @@ void CPanel::InvokeSystemCommand(const char *command)
} }
static const wchar_t *kSeparator = L"----------------------------\n"; static const wchar_t *kSeparator = L"----------------------------\n";
static const wchar_t *kSeparatorSmall = L"----\n";
static const wchar_t *kPropValueSeparator = L": "; static const wchar_t *kPropValueSeparator = L": ";
extern UString ConvertSizeToString(UInt64 value); extern UString ConvertSizeToString(UInt64 value);
@@ -99,9 +94,9 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
void CPanel::Properties() void CPanel::Properties()
{ {
CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties; CMyComPtr<IGetFolderArcProps> getFolderArcProps;
_folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties); _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
if (!getFolderArchiveProperties) if (!getFolderArcProps)
{ {
InvokeSystemCommand("properties"); InvokeSystemCommand("properties");
return; return;
@@ -137,10 +132,12 @@ void CPanel::Properties()
message += kSeparator; message += kSeparator;
} }
/*
message += LangString(IDS_PROP_FILE_TYPE, 0x02000214); message += LangString(IDS_PROP_FILE_TYPE, 0x02000214);
message += kPropValueSeparator; message += kPropValueSeparator;
message += GetFolderTypeID(); message += GetFolderTypeID();
message += L"\n"; message += L"\n";
*/
{ {
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
@@ -172,30 +169,63 @@ void CPanel::Properties()
} }
} }
CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties; CMyComPtr<IGetFolderArcProps> getFolderArcProps;
_folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties); _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
if (getFolderArchiveProperties) if (getFolderArcProps)
{ {
CMyComPtr<IFolderArchiveProperties> getProps; CMyComPtr<IFolderArcProps> getProps;
getFolderArchiveProperties->GetFolderArchiveProperties(&getProps); getFolderArcProps->GetFolderArcProps(&getProps);
if (getProps) if (getProps)
{ {
UInt32 numProps; UInt32 numLevels;
if (getProps->GetNumberOfArchiveProperties(&numProps) == S_OK) if (getProps->GetArcNumLevels(&numLevels) != S_OK)
numLevels = 0;
for (UInt32 level2 = 0; level2 < numLevels; level2++)
{ {
if (numProps > 0)
message += kSeparator;
for (UInt32 i = 0; i < numProps; i++)
{ {
CMyComBSTR name; UInt32 level = numLevels - 1 - level2;
PROPID propID; UInt32 numProps;
VARTYPE vt; if (getProps->GetArcNumProps(level, &numProps) == S_OK)
if (getProps->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK) {
continue; message += kSeparator;
NCOM::CPropVariant prop; for (Int32 i = -2; i < (Int32)numProps; i++)
if (getProps->GetArchiveProperty(propID, &prop) != S_OK) {
continue; CMyComBSTR name;
AddPropertyString(propID, name, prop, message); PROPID propID;
VARTYPE vt;
if (i == -2)
propID = kpidPath;
else if (i == -1)
propID = kpidType;
else if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK)
continue;
NCOM::CPropVariant prop;
if (getProps->GetArcProp(level, propID, &prop) != S_OK)
continue;
AddPropertyString(propID, name, prop, message);
}
}
}
if (level2 != numLevels - 1)
{
UInt32 level = numLevels - 1 - level2;
UInt32 numProps;
if (getProps->GetArcNumProps2(level, &numProps) == S_OK)
{
message += kSeparatorSmall;
for (Int32 i = 0; i < (Int32)numProps; i++)
{
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
if (getProps->GetArcPropInfo2(level, i, &name, &propID, &vt) != S_OK)
continue;
NCOM::CPropVariant prop;
if (getProps->GetArcProp2(level, propID, &prop) != S_OK)
continue;
AddPropertyString(propID, name, prop, message);
}
}
} }
} }
} }
@@ -212,9 +242,9 @@ void CPanel::EditCut()
void CPanel::EditCopy() void CPanel::EditCopy()
{ {
/* /*
CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties; CMyComPtr<IGetFolderArcProps> getFolderArcProps;
_folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties); _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
if (!getFolderArchiveProperties) if (!getFolderArcProps)
{ {
InvokeSystemCommand("copy"); InvokeSystemCommand("copy");
return; return;
@@ -445,13 +475,15 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec,
bool sevenZipMenuCreated = false; bool sevenZipMenuCreated = false;
CMyComPtr<IContextMenu> contextMenu; CZipContextMenu *contextMenuSpec = new CZipContextMenu;
contextMenu = new CZipContextMenu; CMyComPtr<IContextMenu> contextMenu = contextMenuSpec;
// if (contextMenu.CoCreateInstance(CLSID_CZipContextMenu, IID_IContextMenu) == S_OK) // if (contextMenu.CoCreateInstance(CLSID_CZipContextMenu, IID_IContextMenu) == S_OK)
{ {
/*
CMyComPtr<IInitContextMenu> initContextMenu; CMyComPtr<IInitContextMenu> initContextMenu;
if (contextMenu.QueryInterface(IID_IInitContextMenu, &initContextMenu) != S_OK) if (contextMenu.QueryInterface(IID_IInitContextMenu, &initContextMenu) != S_OK)
return; return;
*/
UString currentFolderUnicode = _currentFolderPrefix; UString currentFolderUnicode = _currentFolderPrefix;
UStringVector names; UStringVector names;
int i; int i;
@@ -462,7 +494,7 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec,
namePointers.Add(names[i]); namePointers.Add(names[i]);
// NFile::NDirectory::MySetCurrentDirectory(currentFolderUnicode); // NFile::NDirectory::MySetCurrentDirectory(currentFolderUnicode);
if (initContextMenu->InitContextMenu(currentFolderUnicode, &namePointers.Front(), if (contextMenuSpec->InitContextMenu(currentFolderUnicode, &namePointers.Front(),
operatedIndices.Size()) == S_OK) operatedIndices.Size()) == S_OK)
{ {
HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID, HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID,

View File

@@ -1,42 +1,31 @@
// PluginInterface.h // PluginInterface.h
#ifndef __PLUGININTERFACE_H #ifndef __PLUGIN_INTERFACE_H
#define __PLUGININTERFACE_H #define __PLUGIN_INTERFACE_H
#include "Common/MyString.h" /*
#include "../../../Common/Types.h"
#include "../../IDecl.h"
// {23170F69-40C1-278D-0000-000100010000} #define PLUGIN_INTERFACE(i, x) DECL_INTERFACE(i, 0x0A, x)
DEFINE_GUID(IID_IInitContextMenu,
0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00); PLUGIN_INTERFACE(IInitContextMenu, 0x00)
MIDL_INTERFACE("23170F69-40C1-278D-0000-000100010000")
IInitContextMenu: public IUnknown
{ {
public: STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UINT32 numFiles) PURE;
STDMETHOD(InitContextMenu)(const wchar_t *aFolder, const wchar_t **aNames, UINT32 aNumFiles) PURE;
}; };
// {23170F69-40C1-278D-0000-000100020100} PLUGIN_INTERFACE(IPluginOptionsCallback, 0x01)
DEFINE_GUID(IID_IPluginOptionsCallback,
0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000")
IPluginOptionsCallback: public IUnknown
{ {
public:
STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE; STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE;
STDMETHOD(GetProgramPath)(BSTR *value) PURE; STDMETHOD(GetProgramPath)(BSTR *value) PURE;
STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE; STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE;
}; };
// {23170F69-40C1-278D-0000-000100020000} PLUGIN_INTERFACE(IPluginOptions, 0x02)
DEFINE_GUID(IID_IPluginOptions,
0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000")
IPluginOptions: public IUnknown
{ {
public:
STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE; STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE;
// STDMETHOD(GetFileExtensions)(BSTR *extensions) PURE; // STDMETHOD(GetFileExtensions)(BSTR *extensions) PURE;
}; };
*/
#endif #endif

View File

@@ -65,7 +65,6 @@ FM_OBJS = \
$O\MessagesDialog.obj \ $O\MessagesDialog.obj \
$O\OverwriteDialog.obj \ $O\OverwriteDialog.obj \
$O\PasswordDialog.obj \ $O\PasswordDialog.obj \
$O\PluginsPage.obj \
$O\ProgressDialog2.obj \ $O\ProgressDialog2.obj \
$O\SettingsPage.obj \ $O\SettingsPage.obj \
$O\SplitDialog.obj \ $O\SplitDialog.obj \

View File

@@ -9,13 +9,13 @@
namespace NWindows { namespace NWindows {
namespace NCOM { namespace NCOM {
CPropVariant::CPropVariant(const PROPVARIANT& varSrc) CPropVariant::CPropVariant(const PROPVARIANT &varSrc)
{ {
vt = VT_EMPTY; vt = VT_EMPTY;
InternalCopy(&varSrc); InternalCopy(&varSrc);
} }
CPropVariant::CPropVariant(const CPropVariant& varSrc) CPropVariant::CPropVariant(const CPropVariant &varSrc)
{ {
vt = VT_EMPTY; vt = VT_EMPTY;
InternalCopy(&varSrc); InternalCopy(&varSrc);
@@ -33,12 +33,12 @@ CPropVariant::CPropVariant(LPCOLESTR lpszSrc)
*this = lpszSrc; *this = lpszSrc;
} }
CPropVariant& CPropVariant::operator=(const CPropVariant& varSrc) CPropVariant& CPropVariant::operator=(const CPropVariant &varSrc)
{ {
InternalCopy(&varSrc); InternalCopy(&varSrc);
return *this; return *this;
} }
CPropVariant& CPropVariant::operator=(const PROPVARIANT& varSrc) CPropVariant& CPropVariant::operator=(const PROPVARIANT &varSrc)
{ {
InternalCopy(&varSrc); InternalCopy(&varSrc);
return *this; return *this;
@@ -96,89 +96,21 @@ CPropVariant& CPropVariant::operator=(bool bSrc)
return *this; return *this;
} }
CPropVariant& CPropVariant::operator=(UInt32 value) #define SET_PROP_FUNC(type, id, dest) \
{ CPropVariant& CPropVariant::operator=(type value) \
if (vt != VT_UI4) { if (vt != id) { InternalClear(); vt = id; } \
{ dest = value; return *this; }
InternalClear();
vt = VT_UI4;
}
ulVal = value;
return *this;
}
CPropVariant& CPropVariant::operator=(UInt64 value) SET_PROP_FUNC(Byte, VT_UI1, bVal)
{ SET_PROP_FUNC(Int16, VT_I2, iVal)
if (vt != VT_UI8) SET_PROP_FUNC(Int32, VT_I4, lVal)
{ SET_PROP_FUNC(UInt32, VT_UI4, ulVal)
InternalClear(); SET_PROP_FUNC(UInt64, VT_UI8, uhVal.QuadPart)
vt = VT_UI8; SET_PROP_FUNC(const FILETIME &, VT_FILETIME, filetime)
}
uhVal.QuadPart = value;
return *this;
}
CPropVariant& CPropVariant::operator=(const FILETIME &value) static HRESULT MyPropVariantClear(PROPVARIANT *prop)
{ {
if (vt != VT_FILETIME) switch(prop->vt)
{
InternalClear();
vt = VT_FILETIME;
}
filetime = value;
return *this;
}
CPropVariant& CPropVariant::operator=(Int32 value)
{
if (vt != VT_I4)
{
InternalClear();
vt = VT_I4;
}
lVal = value;
return *this;
}
CPropVariant& CPropVariant::operator=(Byte value)
{
if (vt != VT_UI1)
{
InternalClear();
vt = VT_UI1;
}
bVal = value;
return *this;
}
CPropVariant& CPropVariant::operator=(Int16 value)
{
if (vt != VT_I2)
{
InternalClear();
vt = VT_I2;
}
iVal = value;
return *this;
}
/*
CPropVariant& CPropVariant::operator=(LONG value)
{
if (vt != VT_I4)
{
InternalClear();
vt = VT_I4;
}
lVal = value;
return *this;
}
*/
static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
{
switch(propVariant->vt)
{ {
case VT_UI1: case VT_UI1:
case VT_I1: case VT_I1:
@@ -196,11 +128,11 @@ static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
case VT_R8: case VT_R8:
case VT_CY: case VT_CY:
case VT_DATE: case VT_DATE:
propVariant->vt = VT_EMPTY; prop->vt = VT_EMPTY;
propVariant->wReserved1 = 0; prop->wReserved1 = 0;
return S_OK; return S_OK;
} }
return ::VariantClear((VARIANTARG *)propVariant); return ::VariantClear((VARIANTARG *)prop);
} }
HRESULT CPropVariant::Clear() HRESULT CPropVariant::Clear()
@@ -236,7 +168,7 @@ HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
} }
HRESULT CPropVariant::Attach(PROPVARIANT* pSrc) HRESULT CPropVariant::Attach(PROPVARIANT *pSrc)
{ {
HRESULT hr = Clear(); HRESULT hr = Clear();
if (FAILED(hr)) if (FAILED(hr))
@@ -246,7 +178,7 @@ HRESULT CPropVariant::Attach(PROPVARIANT* pSrc)
return S_OK; return S_OK;
} }
HRESULT CPropVariant::Detach(PROPVARIANT* pDest) HRESULT CPropVariant::Detach(PROPVARIANT *pDest)
{ {
HRESULT hr = MyPropVariantClear(pDest); HRESULT hr = MyPropVariantClear(pDest);
if (FAILED(hr)) if (FAILED(hr))
@@ -267,7 +199,7 @@ HRESULT CPropVariant::InternalClear()
return hr; return hr;
} }
void CPropVariant::InternalCopy(const PROPVARIANT* pSrc) void CPropVariant::InternalCopy(const PROPVARIANT *pSrc)
{ {
HRESULT hr = Copy(pSrc); HRESULT hr = Copy(pSrc);
if (FAILED(hr)) if (FAILED(hr))
@@ -280,52 +212,25 @@ void CPropVariant::InternalCopy(const PROPVARIANT* pSrc)
int CPropVariant::Compare(const CPropVariant &a) int CPropVariant::Compare(const CPropVariant &a)
{ {
if (vt != a.vt) if (vt != a.vt)
return 0; // it's mean some bug return 0; // it's bug case
switch (vt) switch (vt)
{ {
case VT_EMPTY: case VT_EMPTY: return 0;
return 0; // case VT_I1: return MyCompare(cVal, a.cVal);
case VT_UI1: return MyCompare(bVal, a.bVal);
/* case VT_I2: return MyCompare(iVal, a.iVal);
case VT_I1: case VT_UI2: return MyCompare(uiVal, a.uiVal);
return MyCompare(cVal, a.cVal); case VT_I4: return MyCompare(lVal, a.lVal);
*/ case VT_UI4: return MyCompare(ulVal, a.ulVal);
case VT_UI1: // case VT_UINT: return MyCompare(uintVal, a.uintVal);
return MyCompare(bVal, a.bVal); case VT_I8: return MyCompare(hVal.QuadPart, a.hVal.QuadPart);
case VT_UI8: return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart);
case VT_I2: case VT_BOOL: return -MyCompare(boolVal, a.boolVal);
return MyCompare(iVal, a.iVal); case VT_FILETIME: return ::CompareFileTime(&filetime, &a.filetime);
case VT_UI2:
return MyCompare(uiVal, a.uiVal);
case VT_I4:
return MyCompare(lVal, a.lVal);
/*
case VT_INT:
return MyCompare(intVal, a.intVal);
*/
case VT_UI4:
return MyCompare(ulVal, a.ulVal);
/*
case VT_UINT:
return MyCompare(uintVal, a.uintVal);
*/
case VT_I8:
return MyCompare(hVal.QuadPart, a.hVal.QuadPart);
case VT_UI8:
return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart);
case VT_BOOL:
return -MyCompare(boolVal, a.boolVal);
case VT_FILETIME:
return ::CompareFileTime(&filetime, &a.filetime);
case VT_BSTR: case VT_BSTR:
return 0; // Not implemented return 0; // Not implemented
// return MyCompare(aPropVarint.cVal); // return MyCompare(aPropVarint.cVal);
default: return 0;
default:
return 0;
} }
} }

View File

@@ -14,41 +14,39 @@ class CPropVariant : public tagPROPVARIANT
public: public:
CPropVariant() { vt = VT_EMPTY; wReserved1 = 0; } CPropVariant() { vt = VT_EMPTY; wReserved1 = 0; }
~CPropVariant() { Clear(); } ~CPropVariant() { Clear(); }
CPropVariant(const PROPVARIANT& varSrc); CPropVariant(const PROPVARIANT &varSrc);
CPropVariant(const CPropVariant& varSrc); CPropVariant(const CPropVariant &varSrc);
CPropVariant(BSTR bstrSrc); CPropVariant(BSTR bstrSrc);
CPropVariant(LPCOLESTR lpszSrc); CPropVariant(LPCOLESTR lpszSrc);
CPropVariant(bool bSrc) { vt = VT_BOOL; wReserved1 = 0; boolVal = (bSrc ? VARIANT_TRUE : VARIANT_FALSE); }; CPropVariant(bool bSrc) { vt = VT_BOOL; wReserved1 = 0; boolVal = (bSrc ? VARIANT_TRUE : VARIANT_FALSE); };
CPropVariant(UInt32 value) { vt = VT_UI4; wReserved1 = 0; ulVal = value; }
CPropVariant(UInt64 value) { vt = VT_UI8; wReserved1 = 0; uhVal = *(ULARGE_INTEGER*)&value; }
CPropVariant(const FILETIME &value) { vt = VT_FILETIME; wReserved1 = 0; filetime = value; }
CPropVariant(Int32 value) { vt = VT_I4; wReserved1 = 0; lVal = value; }
CPropVariant(Byte value) { vt = VT_UI1; wReserved1 = 0; bVal = value; } CPropVariant(Byte value) { vt = VT_UI1; wReserved1 = 0; bVal = value; }
CPropVariant(Int16 value) { vt = VT_I2; wReserved1 = 0; iVal = value; } CPropVariant(Int16 value) { vt = VT_I2; wReserved1 = 0; iVal = value; }
// CPropVariant(LONG value, VARTYPE vtSrc = VT_I4) { vt = vtSrc; lVal = value; } CPropVariant(Int32 value) { vt = VT_I4; wReserved1 = 0; lVal = value; }
CPropVariant(UInt32 value) { vt = VT_UI4; wReserved1 = 0; ulVal = value; }
CPropVariant(UInt64 value) { vt = VT_UI8; wReserved1 = 0; uhVal.QuadPart = value; }
CPropVariant(const FILETIME &value) { vt = VT_FILETIME; wReserved1 = 0; filetime = value; }
CPropVariant& operator=(const CPropVariant& varSrc); CPropVariant& operator=(const CPropVariant &varSrc);
CPropVariant& operator=(const PROPVARIANT& varSrc); CPropVariant& operator=(const PROPVARIANT &varSrc);
CPropVariant& operator=(BSTR bstrSrc); CPropVariant& operator=(BSTR bstrSrc);
CPropVariant& operator=(LPCOLESTR lpszSrc); CPropVariant& operator=(LPCOLESTR lpszSrc);
CPropVariant& operator=(const char *s); CPropVariant& operator=(const char *s);
CPropVariant& operator=(bool bSrc); CPropVariant& operator=(bool bSrc);
CPropVariant& operator=(Byte value);
CPropVariant& operator=(Int16 value);
CPropVariant& operator=(Int32 value);
CPropVariant& operator=(UInt32 value); CPropVariant& operator=(UInt32 value);
CPropVariant& operator=(Int64 value);
CPropVariant& operator=(UInt64 value); CPropVariant& operator=(UInt64 value);
CPropVariant& operator=(const FILETIME &value); CPropVariant& operator=(const FILETIME &value);
CPropVariant& operator=(Int32 value);
CPropVariant& operator=(Byte value);
CPropVariant& operator=(Int16 value);
// CPropVariant& operator=(LONG value);
HRESULT Clear(); HRESULT Clear();
HRESULT Copy(const PROPVARIANT* pSrc); HRESULT Copy(const PROPVARIANT *pSrc);
HRESULT Attach(PROPVARIANT* pSrc); HRESULT Attach(PROPVARIANT *pSrc);
HRESULT Detach(PROPVARIANT* pDest); HRESULT Detach(PROPVARIANT *pDest);
HRESULT InternalClear(); HRESULT InternalClear();
void InternalCopy(const PROPVARIANT* pSrc); void InternalCopy(const PROPVARIANT *pSrc);
int Compare(const CPropVariant &a1); int Compare(const CPropVariant &a1);
}; };

View File

@@ -10,8 +10,8 @@ AppName = "7-Zip"
InstallDir = %CE1%\%AppName% InstallDir = %CE1%\%AppName%
[Strings] [Strings]
AppVer = "9.12" AppVer = "9.13"
AppDate = "2010-03-24" AppDate = "2010-04-15"
[CEDevice] [CEDevice]
; ProcessorType = 2577 ; ARM ; ProcessorType = 2577 ; ARM

View File

@@ -2,7 +2,7 @@
;Defines ;Defines
!define VERSION_MAJOR 9 !define VERSION_MAJOR 9
!define VERSION_MINOR 12 !define VERSION_MINOR 13
!define VERSION_POSTFIX_FULL " beta" !define VERSION_POSTFIX_FULL " beta"
!ifdef WIN64 !ifdef WIN64
!ifdef IA64 !ifdef IA64
@@ -248,6 +248,7 @@ Section
File th.txt File th.txt
File tr.txt File tr.txt
File tt.txt File tt.txt
File ug.txt
File uk.txt File uk.txt
File uz.txt File uz.txt
File va.txt File va.txt
@@ -439,6 +440,7 @@ Section "Uninstall"
Delete $INSTDIR\Lang\th.txt Delete $INSTDIR\Lang\th.txt
Delete $INSTDIR\Lang\tr.txt Delete $INSTDIR\Lang\tr.txt
Delete $INSTDIR\Lang\tt.txt Delete $INSTDIR\Lang\tt.txt
Delete $INSTDIR\Lang\ug.txt
Delete $INSTDIR\Lang\uk.txt Delete $INSTDIR\Lang\uk.txt
Delete $INSTDIR\Lang\uz.txt Delete $INSTDIR\Lang\uz.txt
Delete $INSTDIR\Lang\va.txt Delete $INSTDIR\Lang\va.txt

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<?define VerMajor = "9" ?> <?define VerMajor = "9" ?>
<?define VerMinor = "12" ?> <?define VerMinor = "13" ?>
<?define VerBuild = "00" ?> <?define VerBuild = "00" ?>
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?> <?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
<?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?> <?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?>
@@ -290,6 +290,7 @@
<File Id="th.txt" Name="th.txt" /> <File Id="th.txt" Name="th.txt" />
<File Id="tr.txt" Name="tr.txt" /> <File Id="tr.txt" Name="tr.txt" />
<File Id="tt.txt" Name="tt.txt" /> <File Id="tt.txt" Name="tt.txt" />
<File Id="ug.txt" Name="ug.txt" />
<File Id="uk.txt" Name="uk.txt" /> <File Id="uk.txt" Name="uk.txt" />
<File Id="uz.txt" Name="uz.txt" /> <File Id="uz.txt" Name="uz.txt" />
<File Id="va.txt" Name="va.txt" /> <File Id="va.txt" Name="va.txt" />

View File

@@ -1,4 +1,4 @@
7-Zip 9.11 Sources 7-Zip 9.13 Sources
------------------ ------------------
7-Zip is a file archiver for Windows. 7-Zip is a file archiver for Windows.