1 #ifndef _RAR_DATAIO_
2 #define _RAR_DATAIO_
3 
4 class CmdAdd;
5 class Unpack;
6 
7 #if 0
8 // We use external i/o calls for Benchmark command.
9 #define COMPRDATAIO_EXTIO
10 #endif
11 
12 class ComprDataIO
13 {
14   private:
15     void ShowUnpRead(int64 ArcPos,int64 ArcSize);
16     void ShowUnpWrite();
17 
18 
19     bool UnpackFromMemory;
20     size_t UnpackFromMemorySize;
21     byte *UnpackFromMemoryAddr;
22 
23     bool UnpackToMemory;
24     size_t UnpackToMemorySize;
25     byte *UnpackToMemoryAddr;
26 
27     size_t UnpWrSize;
28     byte *UnpWrAddr;
29 
30     int64 UnpPackedSize;
31 
32     bool ShowProgress;
33     bool TestMode;
34     bool SkipUnpCRC;
35     bool NoFileHeader;
36 
37     File *SrcFile;
38     File *DestFile;
39 
40     CmdAdd *Command;
41 
42     FileHeader *SubHead;
43     int64 *SubHeadPos;
44 
45 #ifndef RAR_NOCRYPT
46     CryptData *Crypt;
47     CryptData *Decrypt;
48 #endif
49 
50 
51     int LastPercent;
52 
53     wchar CurrentCommand;
54 
55   public:
56     ComprDataIO();
57     ~ComprDataIO();
58     void Init();
59     int UnpRead(byte *Addr,size_t Count);
60     void UnpWrite(byte *Addr,size_t Count);
EnableShowProgress(bool Show)61     void EnableShowProgress(bool Show) {ShowProgress=Show;}
62     void GetUnpackedData(byte **Data,size_t *Size);
SetPackedSizeToRead(int64 Size)63     void SetPackedSizeToRead(int64 Size) {UnpPackedSize=Size;}
SetTestMode(bool Mode)64     void SetTestMode(bool Mode) {TestMode=Mode;}
SetSkipUnpCRC(bool Skip)65     void SetSkipUnpCRC(bool Skip) {SkipUnpCRC=Skip;}
SetNoFileHeader(bool Mode)66     void SetNoFileHeader(bool Mode) {NoFileHeader=Mode;}
67     void SetFiles(File *SrcFile,File *DestFile);
SetCommand(CmdAdd * Cmd)68     void SetCommand(CmdAdd *Cmd) {Command=Cmd;}
SetSubHeader(FileHeader * hd,int64 * Pos)69     void SetSubHeader(FileHeader *hd,int64 *Pos) {SubHead=hd;SubHeadPos=Pos;}
70     void SetEncryption(bool Encrypt,CRYPT_METHOD Method,SecPassword *Password,
71          const byte *Salt,const byte *InitV,uint Lg2Cnt,byte *HashKey,byte *PswCheck);
72     void SetAV15Encryption();
73     void SetCmt13Encryption();
74     void SetUnpackToMemory(byte *Addr,uint Size);
SetCurrentCommand(wchar Cmd)75     void SetCurrentCommand(wchar Cmd) {CurrentCommand=Cmd;}
76 
77 
78     bool PackVolume;
79     bool UnpVolume;
80     bool NextVolumeMissing;
81     int64 UnpArcSize;
82     int64 CurPackRead,CurPackWrite,CurUnpRead,CurUnpWrite;
83 
84 
85     // Size of already processed archives.
86     // Used to calculate the total operation progress.
87     int64 ProcessedArcSize;
88 
89     int64 TotalArcSize;
90 
91     DataHash PackedDataHash; // Packed write and unpack read hash.
92     DataHash PackHash; // Pack read hash.
93     DataHash UnpHash;  // Unpack write hash.
94 
95     bool Encryption;
96     bool Decryption;
97 };
98 
99 #endif
100