MultiStream.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // MultiStream.h
  2. #ifndef __MULTISTREAM_H
  3. #define __MULTISTREAM_H
  4. #include "../../../Common/MyCom.h"
  5. #include "../../../Common/MyVector.h"
  6. #include "../../Archive/IArchive.h"
  7. class CMultiStream:
  8. public IInStream,
  9. public CMyUnknownImp
  10. {
  11. int _streamIndex;
  12. UInt64 _pos;
  13. UInt64 _seekPos;
  14. UInt64 _totalLength;
  15. public:
  16. struct CSubStreamInfo
  17. {
  18. CMyComPtr<IInStream> Stream;
  19. UInt64 Pos;
  20. UInt64 Size;
  21. };
  22. CObjectVector<CSubStreamInfo> Streams;
  23. void Init()
  24. {
  25. _streamIndex = 0;
  26. _pos = 0;
  27. _seekPos = 0;
  28. _totalLength = 0;
  29. for (int i = 0; i < Streams.Size(); i++)
  30. _totalLength += Streams[i].Size;
  31. }
  32. MY_UNKNOWN_IMP1(IInStream)
  33. STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  34. STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
  35. };
  36. /*
  37. class COutMultiStream:
  38. public IOutStream,
  39. public CMyUnknownImp
  40. {
  41. int _streamIndex; // required stream
  42. UInt64 _offsetPos; // offset from start of _streamIndex index
  43. UInt64 _absPos;
  44. UInt64 _length;
  45. struct CSubStreamInfo
  46. {
  47. CMyComPtr<ISequentialOutStream> Stream;
  48. UInt64 Size;
  49. UInt64 Pos;
  50. };
  51. CObjectVector<CSubStreamInfo> Streams;
  52. public:
  53. CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
  54. void Init()
  55. {
  56. _streamIndex = 0;
  57. _offsetPos = 0;
  58. _absPos = 0;
  59. _length = 0;
  60. }
  61. MY_UNKNOWN_IMP1(IOutStream)
  62. STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  63. STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
  64. };
  65. */
  66. #endif