Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-08-27 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:54 +0300
commit051769bbc577aeede90558b6ab5c9be187940ca0 (patch)
treee6330cb80f2d4a526d8aa27812528e053b0cda90 /CPP/7zip/Archive/Nsis
parent33ccab7e728a996800e166d849fe1e92a17e1afe (diff)
4.53 beta
Diffstat (limited to 'CPP/7zip/Archive/Nsis')
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisHandler.cpp121
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisHandler.h1
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisIn.cpp4
3 files changed, 66 insertions, 60 deletions
diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.cpp b/CPP/7zip/Archive/Nsis/NsisHandler.cpp
index 07fd2c4e..62c7ab38 100755
--- a/CPP/7zip/Archive/Nsis/NsisHandler.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisHandler.cpp
@@ -31,7 +31,7 @@ static const wchar_t *kMethods[] =
static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
-STATPROPSTG kProperties[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
{ NULL, kpidIsFolder, VT_BOOL},
@@ -42,43 +42,44 @@ STATPROPSTG kProperties[] =
{ NULL, kpidSolid, VT_BOOL}
};
-STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value)
+STATPROPSTG kArcProps[] =
{
- value->vt = VT_EMPTY;
- return S_OK;
-}
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidSolid, VT_BOOL}
+};
-STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
-{
- *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
- return S_OK;
-}
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
-STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
- if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
- return E_INVALIDARG;
- const STATPROPSTG &srcItem = kProperties[index];
- *propID = srcItem.propid;
- *varType = srcItem.vt;
- *name = 0;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
-{
- *numProperties = 0;
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ UInt32 dict = 1;
+ bool filter = false;
+ for (int i = 0; i < _archive.Items.Size(); i++)
+ {
+ const CItem &item = _archive.Items[i];
+ filter |= item.UseFilter;
+ if (item.DictionarySize > dict)
+ dict = item.DictionarySize;
+ }
+ prop = GetMethod(filter, dict);
+ break;
+ }
+ case kpidSolid: prop = _archive.IsSolid; break;
+ }
+ prop.Detach(value);
return S_OK;
+ COM_TRY_END
}
-STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 /* index */,
- BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */)
-{
- return E_INVALIDARG;
-}
-STDMETHODIMP CHandler::Open(
- IInStream *stream, const UInt64 * maxCheckStartPosition, IArchiveOpenCallback * /* openArchiveCallback */)
+STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 * maxCheckStartPosition, IArchiveOpenCallback * /* openArchiveCallback */)
{
COM_TRY_BEGIN
Close();
@@ -142,6 +143,24 @@ static UString GetStringForSizeValue(UInt32 value)
return result;
}
+UString CHandler::GetMethod(bool useItemFilter, UInt32 dictionary) const
+{
+ NMethodType::EEnum methodIndex = _archive.Method;
+ UString method;
+ if (_archive.IsSolid && _archive.UseFilter || !_archive.IsSolid && useItemFilter)
+ {
+ method += kBcjMethod;
+ method += L" ";
+ }
+ method += (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
+ if (methodIndex == NMethodType::kLZMA)
+ {
+ method += L":";
+ method += GetStringForSizeValue(_archive.IsSolid ? _archive.DictionarySize: dictionary);
+ }
+ return method;
+}
+
bool CHandler::GetUncompressedSize(int index, UInt32 &size)
{
size = 0;
@@ -185,24 +204,24 @@ bool CHandler::GetCompressedSize(int index, UInt32 &size)
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
- NWindows::NCOM::CPropVariant propVariant;
+ NWindows::NCOM::CPropVariant prop;
#ifdef NSIS_SCRIPT
if (index >= (UInt32)_archive.Items.Size())
{
switch(propID)
{
case kpidPath:
- propVariant = L"[NSIS].nsi";
+ prop = L"[NSIS].nsi";
break;
case kpidIsFolder:
- propVariant = false;
+ prop = false;
break;
case kpidSize:
case kpidPackedSize:
- propVariant = (UInt64)_archive.Script.Length();
+ prop = (UInt64)_archive.Script.Length();
break;
case kpidSolid:
- propVariant = false;
+ prop = false;
break;
}
}
@@ -215,57 +234,44 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
case kpidPath:
{
const UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetReducedName(), CP_ACP));
- propVariant = (const wchar_t *)s;
+ prop = (const wchar_t *)s;
break;
}
case kpidIsFolder:
- propVariant = false;
+ prop = false;
break;
case kpidSize:
{
UInt32 size;
if (GetUncompressedSize(index, size))
- propVariant = (UInt64)size;
+ prop = (UInt64)size;
break;
}
case kpidPackedSize:
{
UInt32 size;
if (GetCompressedSize(index, size))
- propVariant = (UInt64)size;
+ prop = (UInt64)size;
break;
}
case kpidLastWriteTime:
{
if (item.DateTime.dwHighDateTime > 0x01000000 &&
item.DateTime.dwHighDateTime < 0xFF000000)
- propVariant = item.DateTime;
+ prop = item.DateTime;
break;
}
case kpidMethod:
{
- NMethodType::EEnum methodIndex = _archive.Method;
- UString method;
- if (_archive.IsSolid && _archive.UseFilter || !_archive.IsSolid && item.UseFilter)
- {
- method += kBcjMethod;
- method += L" ";
- }
- method += (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
- if (methodIndex == NMethodType::kLZMA)
- {
- method += L":";
- method += GetStringForSizeValue(_archive.IsSolid ? _archive.DictionarySize: item.DictionarySize);
- }
- propVariant = method;
+ prop = GetMethod(item.UseFilter, item.DictionarySize);
break;
}
case kpidSolid:
- propVariant = _archive.IsSolid;
+ prop = _archive.IsSolid;
break;
}
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
COM_TRY_END
}
@@ -478,8 +484,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
}
}
}
- if (!testMode)
- realOutStream.Release();
+ realOutStream.Release();
RINOK(extractCallback->SetOperationResult(dataError ?
NArchive::NExtract::NOperationResult::kDataError :
NArchive::NExtract::NOperationResult::kOK));
diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.h b/CPP/7zip/Archive/Nsis/NsisHandler.h
index 82e76139..5dc30107 100755
--- a/CPP/7zip/Archive/Nsis/NsisHandler.h
+++ b/CPP/7zip/Archive/Nsis/NsisHandler.h
@@ -26,6 +26,7 @@ class CHandler:
bool GetUncompressedSize(int index, UInt32 &size);
bool GetCompressedSize(int index, UInt32 &size);
+ UString GetMethod(bool useItemFilter, UInt32 dictionary) const;
public:
MY_QUERYINTERFACE_BEGIN2(IInArchive)
QUERY_ENTRY_ISetCompressCodecsInfo
diff --git a/CPP/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp
index aa1e456f..83080448 100755
--- a/CPP/7zip/Archive/Nsis/NsisIn.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp
@@ -905,10 +905,10 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
{
Items.Sort(CompareItems, 0);
int i;
- if (IsSolid)
+ // if (IsSolid)
for (i = 0; i + 1 < Items.Size();)
{
- if (Items[i].Pos == Items[i + 1].Pos)
+ if (Items[i].Pos == Items[i + 1].Pos && (IsSolid || Items[i].Name == Items[i + 1].Name))
Items.Delete(i + 1);
else
i++;