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>2018-03-12 14:19:17 +0300
committerKornel <kornel@geekhood.net>2018-03-12 14:19:46 +0300
commitf19b649c73cd8b74c4e0b8a3a728a82c6bda47b4 (patch)
tree3725026df472886583a019239ed169e356ce1f63 /CPP/7zip/Archive/Zip
parent866a06f5a0c0ede11979504a318e150030aa7a11 (diff)
18.0318.03
Diffstat (limited to 'CPP/7zip/Archive/Zip')
-rw-r--r--CPP/7zip/Archive/Zip/ZipAddCommon.cpp2
-rw-r--r--CPP/7zip/Archive/Zip/ZipHandler.cpp153
-rw-r--r--CPP/7zip/Archive/Zip/ZipHandler.h7
-rw-r--r--CPP/7zip/Archive/Zip/ZipHandlerOut.cpp3
4 files changed, 148 insertions, 17 deletions
diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
index 0baa254d..1ee7e22f 100644
--- a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
@@ -384,7 +384,7 @@ HRESULT CAddCommon::Compress(
methodId = kMethodId_ZipBase + method;
break;
}
- RINOK(CreateCoder(
+ RINOK(CreateCoder_Id(
EXTERNAL_CODECS_LOC_VARS
methodId, true, _compressEncoder));
if (!_compressEncoder)
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp
index 927b3749..494b9d70 100644
--- a/CPP/7zip/Archive/Zip/ZipHandler.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp
@@ -112,7 +112,8 @@ static const CUInt32PCharPair g_HeaderCharacts[] =
{ 3, "Descriptor" },
// { 5, "Patched" },
{ 6, kMethod_StrongCrypto },
- { 11, "UTF8" }
+ { 11, "UTF8" },
+ { 14, "Alt" }
};
struct CIdToNamePair
@@ -169,6 +170,7 @@ static const Byte kProps[] =
kpidUnpackVer,
kpidVolumeIndex,
kpidOffset
+ // kpidIsAltStream
};
static const Byte kArcProps[] =
@@ -307,6 +309,8 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
prop = true;
break;
}
+
+ // case kpidIsAltStream: prop = true; break;
}
prop.Detach(value);
COM_TRY_END
@@ -333,6 +337,21 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
UString res;
item.GetUnicodeString(res, item.Name, false, _forceCodePage, _specifiedCodePage);
NItemName::ReplaceToOsSlashes_Remove_TailSlash(res);
+ /*
+ if (item.ParentOfAltStream >= 0)
+ {
+ const CItemEx &prevItem = m_Items[item.ParentOfAltStream];
+ UString prevName;
+ prevItem.GetUnicodeString(prevName, prevItem.Name, false, _forceCodePage, _specifiedCodePage);
+ NItemName::ReplaceToOsSlashes_Remove_TailSlash(prevName);
+ if (res.IsPrefixedBy(prevName))
+ if (IsString1PrefixedByString2(res.Ptr(prevName.Len()), k_SpecName_NTFS_STREAM))
+ {
+ res.Delete(prevName.Len(), (unsigned)strlen(k_SpecName_NTFS_STREAM));
+ res.Insert(prevName.Len(), L":");
+ }
+ }
+ */
prop = res;
break;
}
@@ -596,6 +615,19 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
case kpidOffset:
prop = item.LocalHeaderPos;
break;
+
+ /*
+ case kpidIsAltStream:
+ prop = (bool)(item.ParentOfAltStream >= 0); // item.IsAltStream();
+ break;
+
+ case kpidName:
+ if (item.ParentOfAltStream >= 0)
+ {
+ // extract name of stream here
+ }
+ break;
+ */
}
prop.Detach(value);
@@ -604,6 +636,85 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
}
+
+/*
+STDMETHODIMP CHandler::GetNumRawProps(UInt32 *numProps)
+{
+ *numProps = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID)
+{
+ UNUSED_VAR(index);
+ *propID = 0;
+ *name = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentType)
+{
+ *parentType = NParentType::kDir;
+ *parent = (UInt32)(Int32)-1;
+ if (index >= m_Items.Size())
+ return S_OK;
+ const CItemEx &item = m_Items[index];
+
+ if (item.ParentOfAltStream >= 0)
+ {
+ *parentType = NParentType::kAltStream;
+ *parent = item.ParentOfAltStream;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)
+{
+ UNUSED_VAR(index);
+ UNUSED_VAR(propID);
+ *data = NULL;
+ *dataSize = 0;
+ *propType = 0;
+ return S_OK;
+}
+
+
+void CHandler::MarkAltStreams(CObjectVector<CItemEx> &items)
+{
+ int prevIndex = -1;
+ UString prevName;
+ UString name;
+
+ for (unsigned i = 0; i < items.Size(); i++)
+ {
+ CItemEx &item = m_Items[i];
+ if (item.IsAltStream())
+ {
+ if (prevIndex == -1)
+ continue;
+ if (prevName.IsEmpty())
+ {
+ const CItemEx &prevItem = m_Items[prevIndex];
+ prevItem.GetUnicodeString(prevName, prevItem.Name, false, _forceCodePage, _specifiedCodePage);
+ NItemName::ReplaceToOsSlashes_Remove_TailSlash(prevName);
+ }
+ name.Empty();
+ item.GetUnicodeString(name, item.Name, false, _forceCodePage, _specifiedCodePage);
+ NItemName::ReplaceToOsSlashes_Remove_TailSlash(name);
+
+ if (name.IsPrefixedBy(prevName))
+ if (IsString1PrefixedByString2(name.Ptr(prevName.Len()), k_SpecName_NTFS_STREAM))
+ item.ParentOfAltStream = prevIndex;
+ }
+ else
+ {
+ prevIndex = i;
+ prevName.Empty();
+ }
+ }
+}
+*/
+
STDMETHODIMP CHandler::Open(IInStream *inStream,
const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *callback)
{
@@ -617,6 +728,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
m_Items.Clear();
m_Archive.ClearRefs(); // we don't want to clear error flags
}
+ // MarkAltStreams(m_Items);
return res;
}
catch(...) { Close(); throw; }
@@ -738,7 +850,7 @@ public:
IArchiveExtractCallback *extractCallback,
ICompressProgressInfo *compressProgress,
#ifndef _7ZIP_ST
- UInt32 numThreads,
+ UInt32 numThreads, UInt64 memUsage,
#endif
Int32 &res);
};
@@ -767,7 +879,7 @@ HRESULT CZipDecoder::Decode(
IArchiveExtractCallback *extractCallback,
ICompressProgressInfo *compressProgress,
#ifndef _7ZIP_ST
- UInt32 numThreads,
+ UInt32 numThreads, UInt64 memUsage,
#endif
Int32 &res)
{
@@ -962,7 +1074,7 @@ HRESULT CZipDecoder::Decode(
szMethodID = kMethodId_ZipBase + (Byte)id;
}
- RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS szMethodID, false, mi.Coder));
+ RINOK(CreateCoder_Id(EXTERNAL_CODECS_LOC_VARS szMethodID, false, mi.Coder));
if (!mi.Coder)
{
@@ -974,16 +1086,7 @@ HRESULT CZipDecoder::Decode(
}
ICompressCoder *coder = methodItems[m].Coder;
-
- {
- CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
- coder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
- if (setDecoderProperties)
- {
- Byte properties = (Byte)item.Flags;
- RINOK(setDecoderProperties->SetDecoderProperties2(&properties, 1));
- }
- }
+
#ifndef _7ZIP_ST
{
@@ -994,7 +1097,27 @@ HRESULT CZipDecoder::Decode(
RINOK(setCoderMt->SetNumberOfThreads(numThreads));
}
}
+ // if (memUsage != 0)
+ {
+ CMyComPtr<ICompressSetMemLimit> setMemLimit;
+ coder->QueryInterface(IID_ICompressSetMemLimit, (void **)&setMemLimit);
+ if (setMemLimit)
+ {
+ RINOK(setMemLimit->SetMemLimit(memUsage));
+ }
+ }
#endif
+
+ {
+ CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
+ coder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
+ if (setDecoderProperties)
+ {
+ Byte properties = (Byte)item.Flags;
+ RINOK(setDecoderProperties->SetDecoderProperties2(&properties, 1));
+ }
+ }
+
CMyComPtr<ISequentialInStream> inStreamNew;
@@ -1319,7 +1442,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
m_Archive, item, realOutStream, extractCallback,
progress,
#ifndef _7ZIP_ST
- _props._numThreads,
+ _props._numThreads, _props._memUsage,
#endif
res);
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h
index 53e6a460..bee57c00 100644
--- a/CPP/7zip/Archive/Zip/ZipHandler.h
+++ b/CPP/7zip/Archive/Zip/ZipHandler.h
@@ -25,6 +25,7 @@ extern const char * const kMethodNames2[kNumMethodNames2];
class CHandler:
public IInArchive,
+ // public IArchiveGetRawProps,
public IOutArchive,
public ISetProperties,
PUBLIC_ISetCompressCodecsInfo
@@ -32,6 +33,7 @@ class CHandler:
{
public:
MY_QUERYINTERFACE_BEGIN2(IInArchive)
+ // MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps)
MY_QUERYINTERFACE_ENTRY(IOutArchive)
MY_QUERYINTERFACE_ENTRY(ISetProperties)
QUERY_ENTRY_ISetCompressCodecsInfo
@@ -39,6 +41,7 @@ public:
MY_ADDREF_RELEASE
INTERFACE_IInArchive(;)
+ // INTERFACE_IArchiveGetRawProps(;)
INTERFACE_IOutArchive(;)
STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
@@ -75,6 +78,10 @@ private:
_forceCodePage = false;
_specifiedCodePage = CP_OEMCP;
}
+
+ // void MarkAltStreams(CObjectVector<CItemEx> &items);
+
+ HRESULT GetOutProperty(IArchiveUpdateCallback *callback, UInt32 callbackIndex, Int32 arcIndex, PROPID propID, PROPVARIANT *value);
};
}}
diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
index 5acbb6d4..c21b5605 100644
--- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -376,7 +376,8 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
{
CMethodId methodId;
UInt32 numStreams;
- if (!FindMethod(EXTERNAL_CODECS_VARS methodName, methodId, numStreams))
+ if (FindMethod_Index(EXTERNAL_CODECS_VARS methodName, true,
+ methodId, numStreams) < 0)
return E_NOTIMPL;
if (numStreams != 1)
return E_NOTIMPL;