Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CabInBuffer.h « Cab « Archive « 7zip - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1b94f77f1469b28eb866d1e48d88b164f20996ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Archive/CabInBuffer.h

#ifndef __ARCHIVE_CAB_INBUFFER_H
#define __ARCHIVE_CAB_INBUFFER_H

#include "../../IStream.h"
#include "../../../Common/MyCom.h"

namespace NArchive {
namespace NCab {

class CInBuffer
{
  UInt64 m_ProcessedSize;
  UInt32 m_Pos;
  UInt32 m_NumReadBytesInBuffer;
  Byte *m_Buffer;
  CMyComPtr<ISequentialInStream> m_Stream;
  UInt32 m_BufferSize;
  
  UInt32 m_NumBlocks;
  UInt32 m_CurrentBlockIndex;
  UInt32 m_ReservedSize;

public:
  CInBuffer(): m_Buffer(0)  {}
  ~CInBuffer() { Free(); }
  bool Create(UInt32 bufferSize);
  void Free();
  
  void SetStream(ISequentialInStream *inStream) { m_Stream = inStream; }
  void ReleaseStream() { m_Stream.Release(); }

  void Init(Byte reservedSize, UInt32 numBlocks);
  void Init() {}

  bool ReadByte(Byte &b)
    {
      if(m_Pos >= m_NumReadBytesInBuffer)
        return false;
      b = m_Buffer[m_Pos++];
      return true;
    }
  Byte ReadByte()
    {
      if(m_Pos >= m_NumReadBytesInBuffer)
        return 0;
      return m_Buffer[m_Pos++];
    }
  /*
    void ReadBytes(void *data, UInt32 size, UInt32 &aProcessedSize)
    {
      Byte *aDataPointer = (Byte *)data;
      for(int i = 0; i < size; i++)
        if (!ReadByte(aDataPointer[i]))
          break;
      aProcessedSize = i;
    }
  */
  HRESULT ReadBlock(UInt32 &uncompressedSize, bool &dataAreCorrect);
  UInt64 GetProcessedSize() const { return m_ProcessedSize + m_Pos; }
};

}}

#endif