aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/include/unrar/recvol.hpp
blob: 06510a211b1011b70906d8ea7eda7871b2efdbbe (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef _RAR_RECVOL_
#define _RAR_RECVOL_

#define REV5_SIGN      "Rar!\x1aRev"
#define REV5_SIGN_SIZE             8

class RecVolumes3
{
  private:
    File *SrcFile[256];
    Array<byte> Buf;

#ifdef RAR_SMP
    ThreadPool *RSThreadPool;
#endif
  public:
    RecVolumes3(RAROptions *Cmd,bool TestOnly);
    ~RecVolumes3();
    void Make(RAROptions *Cmd,wchar *ArcName);
    bool Restore(RAROptions *Cmd,const wchar *Name,bool Silent);
    void Test(RAROptions *Cmd,const wchar *Name);
};


struct RecVolItem
{
  File *f;
  wchar Name[NM];
  uint CRC;
  uint64 FileSize;
  bool New;   // Newly created RAR volume.
  bool Valid; // If existing RAR volume is valid.
};


class RecVolumes5;
struct RecRSThreadData
{
  RecVolumes5 *RecRSPtr;
  RSCoder16 *RS;
  bool Encode;
  uint DataNum;
  const byte *Data;
  size_t StartPos;
  size_t Size;
};

class RecVolumes5
{
  private:
    void ProcessRS(RAROptions *Cmd,uint DataNum,const byte *Data,uint MaxRead,bool Encode);
    void ProcessRS(RAROptions *Cmd,uint MaxRead,bool Encode);
    uint ReadHeader(File *RecFile,bool FirstRev);

    Array<RecVolItem> RecItems;

    byte *RealReadBuffer; // Real pointer returned by 'new'.
    byte *ReadBuffer;     // Pointer aligned for SSE instructions.

    byte *RealBuf;        // Real pointer returned by 'new'.
    byte *Buf;            // Store ECC or recovered data here, aligned for SSE.
    size_t RecBufferSize; // Buffer area allocated for single volume.

    uint DataCount;   // Number of archives.
    uint RecCount;    // Number of recovery volumes.
    uint TotalCount;  // Total number of archives and recovery volumes.

    bool *ValidFlags; // Volume validity flags for recovering.
    uint MissingVolumes; // Number of missing or bad RAR volumes.

#ifdef RAR_SMP
    ThreadPool *RecThreadPool;
#endif
    uint MaxUserThreads; // Maximum number of threads defined by user.
    RecRSThreadData *ThreadData; // Array to store thread parameters.
  public: // 'public' only because called from thread functions.
    void ProcessAreaRS(RecRSThreadData *td);
  public:
    RecVolumes5(RAROptions *Cmd,bool TestOnly);
    ~RecVolumes5();
    bool Restore(RAROptions *Cmd,const wchar *Name,bool Silent);
    void Test(RAROptions *Cmd,const wchar *Name);
};

bool RecVolumesRestore(RAROptions *Cmd,const wchar *Name,bool Silent);
void RecVolumesTest(RAROptions *Cmd,Archive *Arc,const wchar *Name);

#endif