1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// 7zExtract.cpp
2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "StdAfx.h"
4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../../Common/ComTry.h"
6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../Common/ProgressUtils.h"
8baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "7zDecode.h"
10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// #include "7z1Decode.h"
11baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "7zFolderOutStream.h"
12baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "7zHandler.h"
13baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
14baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace NArchive {
15baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace N7z {
16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
17baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct CExtractFolderInfo
18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{
19baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  #ifdef _7Z_VOL
20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  int VolumeIndex;
21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  #endif
22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  CNum FileIndex;
23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  CNum FolderIndex;
24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  CBoolVector ExtractStatuses;
25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  UInt64 UnpackSize;
26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  CExtractFolderInfo(
27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #ifdef _7Z_VOL
28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    int volumeIndex,
29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #endif
30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    CNum fileIndex, CNum folderIndex):
31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #ifdef _7Z_VOL
32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    VolumeIndex(volumeIndex),
33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #endif
34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    FileIndex(fileIndex),
35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    FolderIndex(folderIndex),
36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    UnpackSize(0)
37baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  {
38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    if (fileIndex != kNumNoIndex)
39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    {
40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      ExtractStatuses.Reserve(1);
41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      ExtractStatuses.Add(true);
42baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    }
43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync};
45baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
46baa3858d3f5d128a5c8466b700098109edcad5f2repo syncSTDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    Int32 testModeSpec, IArchiveExtractCallback *extractCallbackSpec)
48baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{
49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  COM_TRY_BEGIN
50baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  bool testMode = (testModeSpec != 0);
51baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
52baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  UInt64 importantTotalUnpacked = 0;
53baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
54baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  bool allFilesMode = (numItems == (UInt32)-1);
55baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  if (allFilesMode)
56baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    numItems =
57baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #ifdef _7Z_VOL
58baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    _refs.Size();
59baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #else
60baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    _db.Files.Size();
61baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #endif
62baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
63baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  if(numItems == 0)
64baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    return S_OK;
65baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
66baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  /*
67baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  if(_volumes.Size() != 1)
68baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    return E_FAIL;
69baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  const CVolume &volume = _volumes.Front();
70baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  const CArchiveDatabaseEx &_db = volume.Database;
71baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  IInStream *_inStream = volume.Stream;
72baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  */
73baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
74baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  CObjectVector<CExtractFolderInfo> extractFolderInfoVector;
75baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  for (UInt32 ii = 0; ii < numItems; ii++)
76baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  {
77baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    // UInt32 fileIndex = allFilesMode ? indexIndex : indices[indexIndex];
78baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    UInt32 ref2Index = allFilesMode ? ii : indices[ii];
79baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    // const CRef2 &ref2 = _refs[ref2Index];
80baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
81baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    // for (UInt32 ri = 0; ri < ref2.Refs.Size(); ri++)
82baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    {
83baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      #ifdef _7Z_VOL
84baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      // const CRef &ref = ref2.Refs[ri];
85baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      const CRef &ref = _refs[ref2Index];
86baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
87baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      int volumeIndex = ref.VolumeIndex;
88baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      const CVolume &volume = _volumes[volumeIndex];
89baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      const CArchiveDatabaseEx &db = volume.Database;
90baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      UInt32 fileIndex = ref.ItemIndex;
91baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      #else
92baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      const CArchiveDatabaseEx &db = _db;
93baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      UInt32 fileIndex = ref2Index;
94baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      #endif
95baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
96baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      CNum folderIndex = db.FileIndexToFolderIndexMap[fileIndex];
97baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      if (folderIndex == kNumNoIndex)
98baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      {
99baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        extractFolderInfoVector.Add(CExtractFolderInfo(
100baa3858d3f5d128a5c8466b700098109edcad5f2repo sync            #ifdef _7Z_VOL
101baa3858d3f5d128a5c8466b700098109edcad5f2repo sync            volumeIndex,
102baa3858d3f5d128a5c8466b700098109edcad5f2repo sync            #endif
103baa3858d3f5d128a5c8466b700098109edcad5f2repo sync            fileIndex, kNumNoIndex));
104baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        continue;
105baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      }
106baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      if (extractFolderInfoVector.IsEmpty() ||
107baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        folderIndex != extractFolderInfoVector.Back().FolderIndex
108baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        #ifdef _7Z_VOL
109baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        || volumeIndex != extractFolderInfoVector.Back().VolumeIndex
110baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        #endif
111baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        )
112baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      {
113baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        extractFolderInfoVector.Add(CExtractFolderInfo(
114baa3858d3f5d128a5c8466b700098109edcad5f2repo sync            #ifdef _7Z_VOL
115baa3858d3f5d128a5c8466b700098109edcad5f2repo sync            volumeIndex,
116baa3858d3f5d128a5c8466b700098109edcad5f2repo sync            #endif
117baa3858d3f5d128a5c8466b700098109edcad5f2repo sync            kNumNoIndex, folderIndex));
118baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        const CFolder &folderInfo = db.Folders[folderIndex];
119baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        UInt64 unpackSize = folderInfo.GetUnpackSize();
120baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        importantTotalUnpacked += unpackSize;
121baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        extractFolderInfoVector.Back().UnpackSize = unpackSize;
122baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      }
123baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
124baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      CExtractFolderInfo &efi = extractFolderInfoVector.Back();
125baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
126baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      // const CFolderInfo &folderInfo = m_dam_Folders[folderIndex];
127baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      CNum startIndex = db.FolderStartFileIndex[folderIndex];
128baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      for (CNum index = efi.ExtractStatuses.Size();
129baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          index <= fileIndex - startIndex; index++)
130baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      {
131baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        // UInt64 unpackSize = _db.Files[startIndex + index].UnpackSize;
132baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        // Count partial_folder_size
133baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        // efi.UnpackSize += unpackSize;
134baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        // importantTotalUnpacked += unpackSize;
135baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        efi.ExtractStatuses.Add(index == fileIndex - startIndex);
136baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      }
137baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    }
138baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  }
139baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
140baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  RINOK(extractCallback->SetTotal(importantTotalUnpacked));
141baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
142baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  CDecoder decoder(
143baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #ifdef _ST_MODE
144baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    false
145baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #else
146baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    true
147baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #endif
148baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    );
149baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  // CDecoder1 decoder;
150baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
151baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  UInt64 totalPacked = 0;
152baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  UInt64 totalUnpacked = 0;
153baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  UInt64 curPacked, curUnpacked;
154baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
155baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  CLocalProgress *lps = new CLocalProgress;
156baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  CMyComPtr<ICompressProgressInfo> progress = lps;
157baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  lps->Init(extractCallback, false);
158baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
159baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  for (int i = 0;; i++, totalUnpacked += curUnpacked, totalPacked += curPacked)
160baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  {
161baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    lps->OutSize = totalUnpacked;
162baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    lps->InSize = totalPacked;
163baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    RINOK(lps->SetCur());
164baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
165baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    if (i >= extractFolderInfoVector.Size())
166baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      break;
167baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
168baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    const CExtractFolderInfo &efi = extractFolderInfoVector[i];
169baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    curUnpacked = efi.UnpackSize;
170baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    curPacked = 0;
171baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
172baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    CFolderOutStream *folderOutStream = new CFolderOutStream;
173baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    CMyComPtr<ISequentialOutStream> outStream(folderOutStream);
174baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
175baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #ifdef _7Z_VOL
176baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    const CVolume &volume = _volumes[efi.VolumeIndex];
177baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    const CArchiveDatabaseEx &db = volume.Database;
178baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #else
179baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    const CArchiveDatabaseEx &db = _db;
180baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #endif
181baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
182baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    CNum startIndex;
183baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    if (efi.FileIndex != kNumNoIndex)
184baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      startIndex = efi.FileIndex;
185baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    else
186baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      startIndex = db.FolderStartFileIndex[efi.FolderIndex];
187baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
188baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    HRESULT result = folderOutStream->Init(&db,
189baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        #ifdef _7Z_VOL
190baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        volume.StartRef2Index,
191baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        #else
192baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        0,
193baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        #endif
194baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        startIndex,
195baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        &efi.ExtractStatuses, extractCallback, testMode, _crcSize != 0);
196baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
197baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    RINOK(result);
198baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
199baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    if (efi.FileIndex != kNumNoIndex)
200baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      continue;
201baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
202baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    CNum folderIndex = efi.FolderIndex;
203baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    const CFolder &folderInfo = db.Folders[folderIndex];
204baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
205baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    curPacked = _db.GetFolderFullPackSize(folderIndex);
206baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
207baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    CNum packStreamIndex = db.FolderStartPackStreamIndex[folderIndex];
208baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    UInt64 folderStartPackPos = db.GetFolderStreamPos(folderIndex, 0);
209baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
210baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #ifndef _NO_CRYPTO
211baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    CMyComPtr<ICryptoGetTextPassword> getTextPassword;
212baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    if (extractCallback)
213baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      extractCallback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
214baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    #endif
215baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
216baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    try
217baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    {
218baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      #ifndef _NO_CRYPTO
219baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      bool passwordIsDefined;
220baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      #endif
221baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
222baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      HRESULT result = decoder.Decode(
223baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          EXTERNAL_CODECS_VARS
224baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          #ifdef _7Z_VOL
225baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          volume.Stream,
226baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          #else
227baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          _inStream,
228baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          #endif
229baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          folderStartPackPos,
230baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          &db.PackSizes[packStreamIndex],
231baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          folderInfo,
232baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          outStream,
233baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          progress
234baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          #ifndef _NO_CRYPTO
235baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          , getTextPassword, passwordIsDefined
236baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          #endif
237baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          #if !defined(_7ZIP_ST) && !defined(_SFX)
238baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          , true, _numThreads
239baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          #endif
240baa3858d3f5d128a5c8466b700098109edcad5f2repo sync          );
241baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
242baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      if (result == S_FALSE)
243baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      {
244baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError));
245baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        continue;
246baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      }
247baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      if (result == E_NOTIMPL)
248baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      {
249baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kUnSupportedMethod));
250baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        continue;
251baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      }
252baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      if (result != S_OK)
253baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        return result;
254baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      if (folderOutStream->WasWritingFinished() != S_OK)
255baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      {
256baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError));
257baa3858d3f5d128a5c8466b700098109edcad5f2repo sync        continue;
258baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      }
259baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    }
260baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    catch(...)
261baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    {
262baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError));
263baa3858d3f5d128a5c8466b700098109edcad5f2repo sync      continue;
264baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    }
265baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  }
266baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  return S_OK;
267baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  COM_TRY_END
268baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}
269baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
270baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}}
271