File: qopen.hpp

package info (click to toggle)
unrar-nonfree 1%3A7.1.8-1
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 1,952 kB
  • sloc: cpp: 26,394; makefile: 712; sh: 11
file content (61 lines) | stat: -rw-r--r-- 1,537 bytes parent folder | download | duplicates (2)
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
#ifndef _RAR_QOPEN_
#define _RAR_QOPEN_

struct QuickOpenItem
{
  byte *Header;
  size_t HeaderSize;
  uint64 ArcPos;
  QuickOpenItem *Next;
};


class Archive;
class RawRead;

class QuickOpen
{
  private:
    void Close();


    uint ReadBuffer();
    bool ReadRaw(RawRead &Raw);
    bool ReadNext();

    Archive *Arc;
    bool WriteMode;

    QuickOpenItem *ListStart;
    QuickOpenItem *ListEnd;
    
    byte *Buf; // Read quick open data here.
    static const size_t MaxBufSize=0x10000; // Buf size, must be multiple of CRYPT_BLOCK_SIZE.
    size_t CurBufSize; // Current size of buffered data in write mode.
#ifndef RAR_NOCRYPT // For shell extension.
    CryptData Crypt;
#endif

    bool Loaded;
    uint64 QOHeaderPos;  // Main QO header position.
    uint64 RawDataStart; // Start of QO data, just after the main header.
    uint64 RawDataSize;  // Size of entire QO data.
    uint64 RawDataPos;   // Current read position in QO data.
    size_t ReadBufSize;  // Size of Buf data currently read from QO.
    size_t ReadBufPos;   // Current read position in Buf data.
    std::vector<byte> LastReadHeader;
    uint64 LastReadHeaderPos;
    uint64 SeekPos;
    bool UnsyncSeekPos;  // QOpen SeekPos does not match an actual file pointer.
  public:
    QuickOpen();
    ~QuickOpen();
    void Init(Archive *Arc,bool WriteMode);
    void Load(uint64 BlockPos);
    void Unload() { Loaded=false; }
    bool Read(void *Data,size_t Size,size_t &Result);
    bool Seek(int64 Offset,int Method);
    bool Tell(int64 *Pos);
};

#endif