aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/Archive/ExtHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/7zip/Archive/ExtHandler.cpp49
1 files changed, 19 insertions, 30 deletions
diff --git a/CPP/7zip/Archive/ExtHandler.cpp b/CPP/7zip/Archive/ExtHandler.cpp
index f309485..5af2a92 100644
--- a/CPP/7zip/Archive/ExtHandler.cpp
+++ b/CPP/7zip/Archive/ExtHandler.cpp
@@ -20,6 +20,7 @@
20#include "../../../C/CpuArch.h" 20#include "../../../C/CpuArch.h"
21 21
22#include "../../Common/ComTry.h" 22#include "../../Common/ComTry.h"
23#include "../../Common/IntToString.h"
23#include "../../Common/MyLinux.h" 24#include "../../Common/MyLinux.h"
24#include "../../Common/StringConvert.h" 25#include "../../Common/StringConvert.h"
25#include "../../Common/UTFConvert.h" 26#include "../../Common/UTFConvert.h"
@@ -240,15 +241,6 @@ static const char * const g_NodeFlags[] =
240}; 241};
241 242
242 243
243static inline char GetHex(unsigned t) { return (char)(((t < 10) ? ('0' + t) : ('A' + (t - 10)))); }
244
245static inline void PrintHex(unsigned v, char *s)
246{
247 s[0] = GetHex((v >> 4) & 0xF);
248 s[1] = GetHex(v & 0xF);
249}
250
251
252enum 244enum
253{ 245{
254 k_Type_UNKNOWN, 246 k_Type_UNKNOWN,
@@ -1860,12 +1852,10 @@ Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value))
1860 1852
1861 case kpidId: 1853 case kpidId:
1862 { 1854 {
1863 if (!IsEmptyData(_h.Uuid, 16)) 1855 if (!IsEmptyData(_h.Uuid, sizeof(_h.Uuid)))
1864 { 1856 {
1865 char s[16 * 2 + 2]; 1857 char s[sizeof(_h.Uuid) * 2 + 2];
1866 for (unsigned i = 0; i < 16; i++) 1858 ConvertDataToHex_Lower(s, _h.Uuid, sizeof(_h.Uuid));
1867 PrintHex(_h.Uuid[i], s + i * 2);
1868 s[16 * 2] = 0;
1869 prop = s; 1859 prop = s;
1870 } 1860 }
1871 break; 1861 break;
@@ -2602,7 +2592,7 @@ HRESULT CHandler::GetStream_Node(unsigned nodeIndex, ISequentialInStream **strea
2602 2592
2603 CMyComPtr<IInStream> streamTemp; 2593 CMyComPtr<IInStream> streamTemp;
2604 2594
2605 UInt64 numBlocks64 = (node.FileSize + (UInt64)(((UInt32)1 << _h.BlockBits) - 1)) >> _h.BlockBits; 2595 const UInt64 numBlocks64 = (node.FileSize + (UInt64)(((UInt32)1 << _h.BlockBits) - 1)) >> _h.BlockBits;
2606 2596
2607 if (node.IsFlags_EXTENTS()) 2597 if (node.IsFlags_EXTENTS())
2608 { 2598 {
@@ -2729,27 +2719,25 @@ Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2729 totalSize += node.FileSize; 2719 totalSize += node.FileSize;
2730 } 2720 }
2731 2721
2732 extractCallback->SetTotal(totalSize); 2722 RINOK(extractCallback->SetTotal(totalSize))
2733 2723
2734 UInt64 totalPackSize; 2724 UInt64 totalPackSize;
2735 totalSize = totalPackSize = 0; 2725 totalSize = totalPackSize = 0;
2736 2726
2737 NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder(); 2727 CMyComPtr2_Create<ICompressProgressInfo, CLocalProgress> lps;
2738 CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
2739
2740 CLocalProgress *lps = new CLocalProgress;
2741 CMyComPtr<ICompressProgressInfo> progress = lps;
2742 lps->Init(extractCallback, false); 2728 lps->Init(extractCallback, false);
2729 CMyComPtr2_Create<ICompressCoder, NCompress::CCopyCoder> copyCoder;
2743 2730
2744 for (i = 0;; i++) 2731 for (i = 0;; i++)
2745 { 2732 {
2746 lps->InSize = totalPackSize; 2733 lps->InSize = totalPackSize;
2747 lps->OutSize = totalSize; 2734 lps->OutSize = totalSize;
2748 RINOK(lps->SetCur()) 2735 RINOK(lps->SetCur())
2749 2736 if (i >= numItems)
2750 if (i == numItems)
2751 break; 2737 break;
2752 2738
2739 int opRes;
2740 {
2753 CMyComPtr<ISequentialOutStream> outStream; 2741 CMyComPtr<ISequentialOutStream> outStream;
2754 const Int32 askMode = testMode ? 2742 const Int32 askMode = testMode ?
2755 NExtract::NAskMode::kTest : 2743 NExtract::NAskMode::kTest :
@@ -2786,7 +2774,7 @@ Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2786 continue; 2774 continue;
2787 RINOK(extractCallback->PrepareOperation(askMode)) 2775 RINOK(extractCallback->PrepareOperation(askMode))
2788 2776
2789 int res = NExtract::NOperationResult::kDataError; 2777 opRes = NExtract::NOperationResult::kDataError;
2790 { 2778 {
2791 CMyComPtr<ISequentialInStream> inSeqStream; 2779 CMyComPtr<ISequentialInStream> inSeqStream;
2792 HRESULT hres = GetStream(index, &inSeqStream); 2780 HRESULT hres = GetStream(index, &inSeqStream);
@@ -2794,21 +2782,21 @@ Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2794 { 2782 {
2795 if (hres == E_OUTOFMEMORY) 2783 if (hres == E_OUTOFMEMORY)
2796 return hres; 2784 return hres;
2797 res = NExtract::NOperationResult::kUnsupportedMethod; 2785 opRes = NExtract::NOperationResult::kUnsupportedMethod;
2798 } 2786 }
2799 else 2787 else
2800 { 2788 {
2801 RINOK(hres) 2789 RINOK(hres)
2802 { 2790 {
2803 hres = copyCoder->Code(inSeqStream, outStream, NULL, NULL, progress); 2791 hres = copyCoder.Interface()->Code(inSeqStream, outStream, NULL, NULL, lps);
2804 if (hres == S_OK) 2792 if (hres == S_OK)
2805 { 2793 {
2806 if (copyCoderSpec->TotalSize == unpackSize) 2794 if (copyCoder->TotalSize == unpackSize)
2807 res = NExtract::NOperationResult::kOK; 2795 opRes = NExtract::NOperationResult::kOK;
2808 } 2796 }
2809 else if (hres == E_NOTIMPL) 2797 else if (hres == E_NOTIMPL)
2810 { 2798 {
2811 res = NExtract::NOperationResult::kUnsupportedMethod; 2799 opRes = NExtract::NOperationResult::kUnsupportedMethod;
2812 } 2800 }
2813 else if (hres != S_FALSE) 2801 else if (hres != S_FALSE)
2814 { 2802 {
@@ -2817,7 +2805,8 @@ Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2817 } 2805 }
2818 } 2806 }
2819 } 2807 }
2820 RINOK(extractCallback->SetOperationResult(res)) 2808 }
2809 RINOK(extractCallback->SetOperationResult(opRes))
2821 } 2810 }
2822 2811
2823 return S_OK; 2812 return S_OK;