7zUpdate.cpp (p7zip_15.14.1_src_all) | : | 7zUpdate.cpp (p7zip_16.02_src_all) | ||
---|---|---|---|---|
skipping to change at line 378 | skipping to change at line 378 | |||
case k_ARM: | case k_ARM: | |||
case k_ARMT: | case k_ARMT: | |||
case k_PPC: | case k_PPC: | |||
case k_SPARC: | case k_SPARC: | |||
case k_IA64: | case k_IA64: | |||
return true; | return true; | |||
} | } | |||
return false; | return false; | |||
} | } | |||
static unsigned Get_FilterGroup_for_Folder(CRecordVector<CFilterMode2> &filters, | static unsigned Get_FilterGroup_for_Folder( | |||
const CFolderEx &f) | CRecordVector<CFilterMode2> &filters, const CFolderEx &f, bool extractFilter | |||
) | ||||
{ | { | |||
CFilterMode2 m; | CFilterMode2 m; | |||
m.Id = 0; | m.Id = 0; | |||
m.Delta = 0; | m.Delta = 0; | |||
m.Encrypted = f.IsEncrypted(); | m.Encrypted = f.IsEncrypted(); | |||
const CCoderInfo &coder = f.Coders[f.UnpackCoder]; | if (extractFilter) | |||
if (coder.MethodID == k_Delta) | ||||
{ | { | |||
if (coder.Props.Size() == 1) | const CCoderInfo &coder = f.Coders[f.UnpackCoder]; | |||
if (coder.MethodID == k_Delta) | ||||
{ | { | |||
m.Delta = (unsigned)coder.Props[0] + 1; | if (coder.Props.Size() == 1) | |||
m.Id = k_Delta; | { | |||
m.Delta = (unsigned)coder.Props[0] + 1; | ||||
m.Id = k_Delta; | ||||
} | ||||
} | ||||
else if (IsExeFilter(coder.MethodID)) | ||||
{ | ||||
m.Id = (UInt32)coder.MethodID; | ||||
if (m.Id == k_BCJ2) | ||||
m.Id = k_BCJ; | ||||
m.SetDelta(); | ||||
} | } | |||
} | ||||
else if (IsExeFilter(coder.MethodID)) | ||||
{ | ||||
m.Id = (UInt32)coder.MethodID; | ||||
if (m.Id == k_BCJ2) | ||||
m.Id = k_BCJ; | ||||
m.SetDelta(); | ||||
} | } | |||
return GetGroup(filters, m); | return GetGroup(filters, m); | |||
} | } | |||
static HRESULT WriteRange(IInStream *inStream, ISequentialOutStream *outStream, | static HRESULT WriteRange(IInStream *inStream, ISequentialOutStream *outStream, | |||
UInt64 position, UInt64 size, ICompressProgressInfo *progress) | UInt64 position, UInt64 size, ICompressProgressInfo *progress) | |||
{ | { | |||
RINOK(inStream->Seek(position, STREAM_SEEK_SET, 0)); | RINOK(inStream->Seek(position, STREAM_SEEK_SET, 0)); | |||
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream; | CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream; | |||
skipping to change at line 1601 | skipping to change at line 1605 | |||
// size_t totalSecureDataSize = (size_t)secureBlocks.GetTotalSizeInBytes(); | // size_t totalSecureDataSize = (size_t)secureBlocks.GetTotalSizeInBytes(); | |||
/* | /* | |||
CMyComPtr<IOutStream> outStream; | CMyComPtr<IOutStream> outStream; | |||
RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream)); | RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream)); | |||
if (!outStream) | if (!outStream) | |||
return E_NOTIMPL; | return E_NOTIMPL; | |||
*/ | */ | |||
UInt64 startBlockSize = db != 0 ? db->ArcInfo.StartPosition: 0; | UInt64 startBlockSize = db ? db->ArcInfo.StartPosition: 0; | |||
if (startBlockSize > 0 && !options.RemoveSfxBlock) | if (startBlockSize > 0 && !options.RemoveSfxBlock) | |||
{ | { | |||
RINOK(WriteRange(inStream, seqOutStream, 0, startBlockSize, NULL)); | RINOK(WriteRange(inStream, seqOutStream, 0, startBlockSize, NULL)); | |||
} | } | |||
CIntArr fileIndexToUpdateIndexMap; | CIntArr fileIndexToUpdateIndexMap; | |||
UInt64 complexity = 0; | UInt64 complexity = 0; | |||
UInt64 inSizeForReduce2 = 0; | UInt64 inSizeForReduce2 = 0; | |||
bool needEncryptedRepack = false; | bool needEncryptedRepack = false; | |||
CRecordVector<CFilterMode2> filters; | CRecordVector<CFilterMode2> filters; | |||
CObjectVector<CSolidGroup> groups; | CObjectVector<CSolidGroup> groups; | |||
bool thereAreRepacks = false; | bool thereAreRepacks = false; | |||
if (db != 0) | bool useFilters = options.UseFilters; | |||
if (useFilters) | ||||
{ | ||||
const CCompressionMethodMode &method = *options.Method; | ||||
FOR_VECTOR (i, method.Methods) | ||||
if (IsFilterMethod(method.Methods[i].Id)) | ||||
{ | ||||
useFilters = false; | ||||
break; | ||||
} | ||||
} | ||||
if (db) | ||||
{ | { | |||
fileIndexToUpdateIndexMap.Alloc(db->Files.Size()); | fileIndexToUpdateIndexMap.Alloc(db->Files.Size()); | |||
unsigned i; | unsigned i; | |||
for (i = 0; i < db->Files.Size(); i++) | for (i = 0; i < db->Files.Size(); i++) | |||
fileIndexToUpdateIndexMap[i] = -1; | fileIndexToUpdateIndexMap[i] = -1; | |||
for (i = 0; i < updateItems.Size(); i++) | for (i = 0; i < updateItems.Size(); i++) | |||
{ | { | |||
int index = updateItems[i].IndexInArchive; | int index = updateItems[i].IndexInArchive; | |||
skipping to change at line 1662 | skipping to change at line 1679 | |||
if (numCopyItems == 0) | if (numCopyItems == 0) | |||
continue; | continue; | |||
CFolderRepack rep; | CFolderRepack rep; | |||
rep.FolderIndex = i; | rep.FolderIndex = i; | |||
rep.NumCopyFiles = numCopyItems; | rep.NumCopyFiles = numCopyItems; | |||
CFolderEx f; | CFolderEx f; | |||
db->ParseFolderEx(i, f); | db->ParseFolderEx(i, f); | |||
bool isEncrypted = f.IsEncrypted(); | const bool isEncrypted = f.IsEncrypted(); | |||
const bool needCopy = (numCopyItems == numUnpackStreams); | ||||
const bool extractFilter = (useFilters || needCopy); | ||||
unsigned groupIndex = Get_FilterGroup_for_Folder(filters, f); | unsigned groupIndex = Get_FilterGroup_for_Folder(filters, f, extractFilter ); | |||
while (groupIndex >= groups.Size()) | while (groupIndex >= groups.Size()) | |||
groups.AddNew(); | groups.AddNew(); | |||
groups[groupIndex].folderRefs.Add(rep); | groups[groupIndex].folderRefs.Add(rep); | |||
if (numCopyItems == numUnpackStreams) | if (needCopy) | |||
complexity += db->GetFolderFullPackSize(i); | complexity += db->GetFolderFullPackSize(i); | |||
else | else | |||
{ | { | |||
thereAreRepacks = true; | thereAreRepacks = true; | |||
complexity += repackSize; | complexity += repackSize; | |||
if (inSizeForReduce2 < repackSize) | if (inSizeForReduce2 < repackSize) | |||
inSizeForReduce2 = repackSize; | inSizeForReduce2 = repackSize; | |||
if (isEncrypted) | if (isEncrypted) | |||
needEncryptedRepack = true; | needEncryptedRepack = true; | |||
} | } | |||
} | } | |||
} | } | |||
UInt64 inSizeForReduce = 0; | UInt64 inSizeForReduce = 0; | |||
unsigned i; | ||||
for (i = 0; i < updateItems.Size(); i++) | ||||
{ | { | |||
const CUpdateItem &ui = updateItems[i]; | FOR_VECTOR (i, updateItems) | |||
if (ui.NewData) | ||||
{ | { | |||
complexity += ui.Size; | const CUpdateItem &ui = updateItems[i]; | |||
if (numSolidFiles != 1) | if (ui.NewData) | |||
inSizeForReduce += ui.Size; | { | |||
else if (inSizeForReduce < ui.Size) | complexity += ui.Size; | |||
inSizeForReduce = ui.Size; | if (numSolidFiles != 1) | |||
inSizeForReduce += ui.Size; | ||||
else if (inSizeForReduce < ui.Size) | ||||
inSizeForReduce = ui.Size; | ||||
} | ||||
} | } | |||
} | } | |||
if (inSizeForReduce < inSizeForReduce2) | if (inSizeForReduce < inSizeForReduce2) | |||
inSizeForReduce = inSizeForReduce2; | inSizeForReduce = inSizeForReduce2; | |||
RINOK(updateCallback->SetTotal(complexity)); | RINOK(updateCallback->SetTotal(complexity)); | |||
CLocalProgress *lps = new CLocalProgress; | CLocalProgress *lps = new CLocalProgress; | |||
CMyComPtr<ICompressProgressInfo> progress = lps; | CMyComPtr<ICompressProgressInfo> progress = lps; | |||
skipping to change at line 1756 | skipping to change at line 1776 | |||
{ | { | |||
analysis.ParseExe = true; | analysis.ParseExe = true; | |||
if (options.AnalysisLevel >= 9) | if (options.AnalysisLevel >= 9) | |||
analysis.ParseAll = true; | analysis.ParseAll = true; | |||
} | } | |||
} | } | |||
} | } | |||
// ---------- Split files to groups ---------- | // ---------- Split files to groups ---------- | |||
bool useFilters = options.UseFilters; | ||||
const CCompressionMethodMode &method = *options.Method; | const CCompressionMethodMode &method = *options.Method; | |||
if (useFilters) | FOR_VECTOR (i, updateItems) | |||
for (i = 0; i < method.Methods.Size(); i++) | ||||
if (IsFilterMethod(method.Methods[i].Id)) | ||||
{ | ||||
useFilters = false; | ||||
break; | ||||
} | ||||
/* | ||||
if (!method.Bonds.IsEmpty()) | ||||
useFilters = false; | ||||
*/ | ||||
for (i = 0; i < updateItems.Size(); i++) | ||||
{ | { | |||
const CUpdateItem &ui = updateItems[i]; | const CUpdateItem &ui = updateItems[i]; | |||
if (!ui.NewData || !ui.HasStream()) | if (!ui.NewData || !ui.HasStream()) | |||
continue; | continue; | |||
CFilterMode2 fm; | CFilterMode2 fm; | |||
if (useFilters) | if (useFilters) | |||
{ | { | |||
RINOK(analysis.GetFilterGroup(i, ui, fm)); | RINOK(analysis.GetFilterGroup(i, ui, fm)); | |||
} | } | |||
skipping to change at line 1874 | skipping to change at line 1880 | |||
if (totalSecureDataSize != 0) | if (totalSecureDataSize != 0) | |||
newDatabase.SecureIDs.Add(secureID); | newDatabase.SecureIDs.Add(secureID); | |||
} | } | |||
*/ | */ | |||
{ | { | |||
/* ---------- Write non-AUX dirs and Empty files ---------- */ | /* ---------- Write non-AUX dirs and Empty files ---------- */ | |||
CUIntVector emptyRefs; | CUIntVector emptyRefs; | |||
unsigned i; | ||||
for (i = 0; i < updateItems.Size(); i++) | for (i = 0; i < updateItems.Size(); i++) | |||
{ | { | |||
const CUpdateItem &ui = updateItems[i]; | const CUpdateItem &ui = updateItems[i]; | |||
if (ui.NewData) | if (ui.NewData) | |||
{ | { | |||
if (ui.HasStream()) | if (ui.HasStream()) | |||
continue; | continue; | |||
} | } | |||
else if (ui.IndexInArchive != -1 && db->Files[ui.IndexInArchive].HasStream ) | else if (ui.IndexInArchive != -1 && db->Files[ui.IndexInArchive].HasStream ) | |||
continue; | continue; | |||
skipping to change at line 1936 | skipping to change at line 1944 | |||
filters[i].GroupIndex = i; | filters[i].GroupIndex = i; | |||
} | } | |||
filters.Sort2(); | filters.Sort2(); | |||
} | } | |||
for (unsigned groupIndex = 0; groupIndex < filters.Size(); groupIndex++) | for (unsigned groupIndex = 0; groupIndex < filters.Size(); groupIndex++) | |||
{ | { | |||
const CFilterMode2 &filterMode = filters[groupIndex]; | const CFilterMode2 &filterMode = filters[groupIndex]; | |||
CCompressionMethodMode method = *options.Method; | CCompressionMethodMode method = *options.Method; | |||
HRESULT res = MakeExeMethod(method, filterMode, | { | |||
HRESULT res = MakeExeMethod(method, filterMode, | ||||
#ifdef _7ZIP_ST | #ifdef _7ZIP_ST | |||
false | false | |||
#else | #else | |||
options.MaxFilter && options.MultiThreadMixer | options.MaxFilter && options.MultiThreadMixer | |||
#endif | #endif | |||
); | ); | |||
RINOK(res); | RINOK(res); | |||
} | ||||
if (filterMode.Encrypted) | if (filterMode.Encrypted) | |||
{ | { | |||
if (!method.PasswordIsDefined) | if (!method.PasswordIsDefined) | |||
{ | { | |||
#ifndef _NO_CRYPTO | #ifndef _NO_CRYPTO | |||
if (getPasswordSpec) | if (getPasswordSpec) | |||
method.Password = getPasswordSpec->Password; | method.Password = getPasswordSpec->Password; | |||
#endif | #endif | |||
method.PasswordIsDefined = true; | method.PasswordIsDefined = true; | |||
skipping to change at line 2177 | skipping to change at line 2187 | |||
&inSizeForReduce, | &inSizeForReduce, | |||
newDatabase.Folders.AddNew(), newDatabase.CoderUnpackSizes, curUnp ackSize, | newDatabase.Folders.AddNew(), newDatabase.CoderUnpackSizes, curUnp ackSize, | |||
archive.SeqStream, newDatabase.PackSizes, progress); | archive.SeqStream, newDatabase.PackSizes, progress); | |||
if (encodeRes == k_My_HRESULT_CRC_ERROR) | if (encodeRes == k_My_HRESULT_CRC_ERROR) | |||
return E_FAIL; | return E_FAIL; | |||
#ifndef _7ZIP_ST | #ifndef _7ZIP_ST | |||
if (options.MultiThreadMixer) | if (options.MultiThreadMixer) | |||
{ | { | |||
// 16.00: hang was fixed : for case if decoding was not finished. | ||||
// We close CBinderInStream and it calls CStreamBinder::CloseRead() | ||||
inStreamSizeCount.Release(); | ||||
sbInStream.Release(); | ||||
threadDecoder.WaitExecuteFinish(); | threadDecoder.WaitExecuteFinish(); | |||
HRESULT decodeRes = threadDecoder.Result; | HRESULT decodeRes = threadDecoder.Result; | |||
// if (res == k_My_HRESULT_CRC_ERROR) | // if (res == k_My_HRESULT_CRC_ERROR) | |||
if (decodeRes == S_FALSE) | if (decodeRes == S_FALSE) | |||
{ | { | |||
if (extractCallback) | if (extractCallback) | |||
{ | { | |||
RINOK(extractCallback->ReportExtractResult( | RINOK(extractCallback->ReportExtractResult( | |||
NEventIndexType::kInArcIndex, db->FolderStartFileIndex[folde rIndex], | NEventIndexType::kInArcIndex, db->FolderStartFileIndex[folde rIndex], | |||
// NEventIndexType::kBlockIndex, (UInt32)folderIndex, | // NEventIndexType::kBlockIndex, (UInt32)folderIndex, | |||
NExtract::NOperationResult::kDataError)); | NExtract::NOperationResult::kDataError)); | |||
skipping to change at line 2275 | skipping to change at line 2291 | |||
} | } | |||
// ---------- Compress files to new solid blocks ---------- | // ---------- Compress files to new solid blocks ---------- | |||
unsigned numFiles = group.Indices.Size(); | unsigned numFiles = group.Indices.Size(); | |||
if (numFiles == 0) | if (numFiles == 0) | |||
continue; | continue; | |||
CRecordVector<CRefItem> refItems; | CRecordVector<CRefItem> refItems; | |||
refItems.ClearAndSetSize(numFiles); | refItems.ClearAndSetSize(numFiles); | |||
bool sortByType = (options.UseTypeSorting && numSolidFiles > 1); | bool sortByType = (options.UseTypeSorting && numSolidFiles > 1); | |||
unsigned i; | ||||
for (i = 0; i < numFiles; i++) | for (i = 0; i < numFiles; i++) | |||
refItems[i] = CRefItem(group.Indices[i], updateItems[group.Indices[i]], so rtByType); | refItems[i] = CRefItem(group.Indices[i], updateItems[group.Indices[i]], so rtByType); | |||
CSortParam sortParam; | CSortParam sortParam; | |||
// sortParam.TreeFolders = &treeFolders; | // sortParam.TreeFolders = &treeFolders; | |||
sortParam.SortByType = sortByType; | sortParam.SortByType = sortByType; | |||
refItems.Sort(CompareUpdateItems, (void *)&sortParam); | refItems.Sort(CompareUpdateItems, (void *)&sortParam); | |||
CObjArray<UInt32> indices(numFiles); | CObjArray<UInt32> indices(numFiles); | |||
for (i = 0; i < numFiles; i++) | for (i = 0; i < numFiles; i++) | |||
{ | { | |||
UInt32 index = refItems[i].Index; | UInt32 index = refItems[i].Index; | |||
End of changes. 22 change blocks. | ||||
46 lines changed or deleted | 66 lines changed or added |