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