1370b324cSopenharmony_ci// MultiStream.h
2370b324cSopenharmony_ci
3370b324cSopenharmony_ci#ifndef ZIP7_INC_MULTI_STREAM_H
4370b324cSopenharmony_ci#define ZIP7_INC_MULTI_STREAM_H
5370b324cSopenharmony_ci
6370b324cSopenharmony_ci#include "../../../Common/MyCom.h"
7370b324cSopenharmony_ci#include "../../../Common/MyVector.h"
8370b324cSopenharmony_ci
9370b324cSopenharmony_ci#include "../../IStream.h"
10370b324cSopenharmony_ci#include "../../Archive/IArchive.h"
11370b324cSopenharmony_ci
12370b324cSopenharmony_ciZ7_CLASS_IMP_COM_1(
13370b324cSopenharmony_ci  CMultiStream
14370b324cSopenharmony_ci  , IInStream
15370b324cSopenharmony_ci)
16370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(ISequentialInStream)
17370b324cSopenharmony_ci
18370b324cSopenharmony_ci  unsigned _streamIndex;
19370b324cSopenharmony_ci  UInt64 _pos;
20370b324cSopenharmony_ci  UInt64 _totalLength;
21370b324cSopenharmony_ci
22370b324cSopenharmony_cipublic:
23370b324cSopenharmony_ci
24370b324cSopenharmony_ci  struct CSubStreamInfo
25370b324cSopenharmony_ci  {
26370b324cSopenharmony_ci    CMyComPtr<IInStream> Stream;
27370b324cSopenharmony_ci    UInt64 Size;
28370b324cSopenharmony_ci    UInt64 GlobalOffset;
29370b324cSopenharmony_ci    UInt64 LocalPos;
30370b324cSopenharmony_ci    CSubStreamInfo(): Size(0), GlobalOffset(0), LocalPos(0) {}
31370b324cSopenharmony_ci  };
32370b324cSopenharmony_ci
33370b324cSopenharmony_ci  CMyComPtr<IArchiveUpdateCallbackFile> updateCallbackFile;
34370b324cSopenharmony_ci  CObjectVector<CSubStreamInfo> Streams;
35370b324cSopenharmony_ci
36370b324cSopenharmony_ci  HRESULT Init()
37370b324cSopenharmony_ci  {
38370b324cSopenharmony_ci    UInt64 total = 0;
39370b324cSopenharmony_ci    FOR_VECTOR (i, Streams)
40370b324cSopenharmony_ci    {
41370b324cSopenharmony_ci      CSubStreamInfo &s = Streams[i];
42370b324cSopenharmony_ci      s.GlobalOffset = total;
43370b324cSopenharmony_ci      total += s.Size;
44370b324cSopenharmony_ci      s.LocalPos = 0;
45370b324cSopenharmony_ci      {
46370b324cSopenharmony_ci        // it was already set to start
47370b324cSopenharmony_ci        // RINOK(InStream_GetPos(s.Stream, s.LocalPos));
48370b324cSopenharmony_ci      }
49370b324cSopenharmony_ci    }
50370b324cSopenharmony_ci    _totalLength = total;
51370b324cSopenharmony_ci    _pos = 0;
52370b324cSopenharmony_ci    _streamIndex = 0;
53370b324cSopenharmony_ci    return S_OK;
54370b324cSopenharmony_ci  }
55370b324cSopenharmony_ci};
56370b324cSopenharmony_ci
57370b324cSopenharmony_ci/*
58370b324cSopenharmony_ciZ7_CLASS_IMP_COM_1(
59370b324cSopenharmony_ci  COutMultiStream,
60370b324cSopenharmony_ci  IOutStream
61370b324cSopenharmony_ci)
62370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(ISequentialOutStream)
63370b324cSopenharmony_ci
64370b324cSopenharmony_ci  unsigned _streamIndex; // required stream
65370b324cSopenharmony_ci  UInt64 _offsetPos; // offset from start of _streamIndex index
66370b324cSopenharmony_ci  UInt64 _absPos;
67370b324cSopenharmony_ci  UInt64 _length;
68370b324cSopenharmony_ci
69370b324cSopenharmony_ci  struct CSubStreamInfo
70370b324cSopenharmony_ci  {
71370b324cSopenharmony_ci    CMyComPtr<ISequentialOutStream> Stream;
72370b324cSopenharmony_ci    UInt64 Size;
73370b324cSopenharmony_ci    UInt64 Pos;
74370b324cSopenharmony_ci };
75370b324cSopenharmony_ci  CObjectVector<CSubStreamInfo> Streams;
76370b324cSopenharmony_cipublic:
77370b324cSopenharmony_ci  CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
78370b324cSopenharmony_ci  void Init()
79370b324cSopenharmony_ci  {
80370b324cSopenharmony_ci    _streamIndex = 0;
81370b324cSopenharmony_ci    _offsetPos = 0;
82370b324cSopenharmony_ci    _absPos = 0;
83370b324cSopenharmony_ci    _length = 0;
84370b324cSopenharmony_ci  }
85370b324cSopenharmony_ci};
86370b324cSopenharmony_ci*/
87370b324cSopenharmony_ci
88370b324cSopenharmony_ci#endif
89