2009-11-10 16:48:42 +01:00
|
|
|
#ifndef _RAR_ARCHIVE_
|
|
|
|
#define _RAR_ARCHIVE_
|
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
class PPack;
|
|
|
|
class RawRead;
|
|
|
|
class RawWrite;
|
2009-11-10 16:48:42 +01:00
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
enum NOMODIFY_FLAGS
|
|
|
|
{
|
|
|
|
NMDF_ALLOWLOCK=1,NMDF_ALLOWANYVOLUME=2,NMDF_ALLOWFIRSTVOLUME=4
|
|
|
|
};
|
|
|
|
|
|
|
|
enum RARFORMAT {RARFMT_NONE,RARFMT14,RARFMT15,RARFMT50,RARFMT_FUTURE};
|
|
|
|
|
|
|
|
enum ADDSUBDATA_FLAGS
|
|
|
|
{
|
|
|
|
ASDF_SPLIT = 1, // Allow to split archive just before header if necessary.
|
|
|
|
ASDF_COMPRESS = 2, // Allow to compress data following subheader.
|
|
|
|
ASDF_CRYPT = 4, // Encrypt data after subheader if password is set.
|
|
|
|
ASDF_CRYPTIFHEADERS = 8 // Encrypt data after subheader only in -hp mode.
|
|
|
|
};
|
|
|
|
|
|
|
|
// RAR5 headers must not exceed 2 MB.
|
|
|
|
#define MAX_HEADER_SIZE_RAR5 0x200000
|
2009-11-10 16:48:42 +01:00
|
|
|
|
|
|
|
class Archive:public File
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
void UpdateLatestTime(FileHeader *CurBlock);
|
|
|
|
void ConvertNameCase(wchar *Name);
|
2020-07-15 00:40:26 +02:00
|
|
|
void ConvertFileHeader(FileHeader *hd);
|
|
|
|
size_t ReadHeader14();
|
|
|
|
size_t ReadHeader15();
|
|
|
|
size_t ReadHeader50();
|
|
|
|
void ProcessExtra50(RawRead *Raw,size_t ExtraSize,BaseBlock *bb);
|
|
|
|
void RequestArcPassword();
|
2009-11-10 16:48:42 +01:00
|
|
|
void UnexpEndArcMsg();
|
2020-07-15 00:40:26 +02:00
|
|
|
void BrokenHeaderMsg();
|
|
|
|
void UnkEncVerMsg(const wchar *Name,const wchar *Info);
|
|
|
|
bool DoGetComment(Array<wchar> *CmtData);
|
|
|
|
bool ReadCommentData(Array<wchar> *CmtData);
|
2009-11-10 16:48:42 +01:00
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
#if !defined(RAR_NOCRYPT)
|
2009-11-10 16:48:42 +01:00
|
|
|
CryptData HeadersCrypt;
|
|
|
|
#endif
|
|
|
|
ComprDataIO SubDataIO;
|
2020-07-15 00:40:26 +02:00
|
|
|
bool DummyCmd;
|
|
|
|
RAROptions *Cmd;
|
2009-11-10 16:48:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
RarTime LatestTime;
|
|
|
|
int LastReadBlock;
|
2020-07-15 00:40:26 +02:00
|
|
|
HEADER_TYPE CurHeaderType;
|
2009-11-10 16:48:42 +01:00
|
|
|
|
|
|
|
bool SilentOpen;
|
2020-07-15 00:40:26 +02:00
|
|
|
#ifdef USE_QOPEN
|
|
|
|
QuickOpen QOpen;
|
|
|
|
bool ProhibitQOpen;
|
|
|
|
#endif
|
2009-11-10 16:48:42 +01:00
|
|
|
public:
|
|
|
|
Archive(RAROptions *InitCmd=NULL);
|
2020-07-15 00:40:26 +02:00
|
|
|
~Archive();
|
|
|
|
static RARFORMAT IsSignature(const byte *D,size_t Size);
|
2009-11-10 16:48:42 +01:00
|
|
|
bool IsArchive(bool EnableBroken);
|
2020-07-15 00:40:26 +02:00
|
|
|
size_t SearchBlock(HEADER_TYPE HeaderType);
|
|
|
|
size_t SearchSubBlock(const wchar *Type);
|
|
|
|
size_t SearchRR();
|
2009-11-10 16:48:42 +01:00
|
|
|
size_t ReadHeader();
|
|
|
|
void CheckArc(bool EnableBroken);
|
2020-07-15 00:40:26 +02:00
|
|
|
void CheckOpen(const wchar *Name);
|
|
|
|
bool WCheckOpen(const wchar *Name);
|
|
|
|
bool GetComment(Array<wchar> *CmtData);
|
2009-11-10 16:48:42 +01:00
|
|
|
void ViewComment();
|
|
|
|
void SetLatestTime(RarTime *NewTime);
|
|
|
|
void SeekToNext();
|
|
|
|
bool CheckAccess();
|
|
|
|
bool IsArcDir();
|
|
|
|
void ConvertAttributes();
|
|
|
|
void VolSubtractHeaderSize(size_t SubSize);
|
2020-07-15 00:40:26 +02:00
|
|
|
uint FullHeaderSize(size_t Size);
|
|
|
|
int64 GetStartPos();
|
|
|
|
void AddSubData(byte *SrcData,uint64 DataSize,File *SrcFile,
|
|
|
|
const wchar *Name,uint Flags);
|
|
|
|
bool ReadSubData(Array<byte> *UnpData,File *DestFile,bool TestMode);
|
|
|
|
HEADER_TYPE GetHeaderType() {return CurHeaderType;}
|
|
|
|
RAROptions* GetRAROptions() {return Cmd;}
|
2009-11-10 16:48:42 +01:00
|
|
|
void SetSilentOpen(bool Mode) {SilentOpen=Mode;}
|
2020-07-15 00:40:26 +02:00
|
|
|
#if 0
|
|
|
|
void GetRecoveryInfo(bool Required,int64 *Size,int *Percent);
|
|
|
|
#endif
|
|
|
|
#ifdef USE_QOPEN
|
|
|
|
bool Open(const wchar *Name,uint Mode=FMF_READ);
|
|
|
|
int Read(void *Data,size_t Size);
|
|
|
|
void Seek(int64 Offset,int Method);
|
|
|
|
int64 Tell();
|
|
|
|
void QOpenUnload() {QOpen.Unload();}
|
|
|
|
void SetProhibitQOpen(bool Mode) {ProhibitQOpen=Mode;}
|
|
|
|
#endif
|
2009-11-10 16:48:42 +01:00
|
|
|
|
|
|
|
BaseBlock ShortBlock;
|
2020-07-15 00:40:26 +02:00
|
|
|
MarkHeader MarkHead;
|
|
|
|
MainHeader MainHead;
|
|
|
|
CryptHeader CryptHead;
|
|
|
|
FileHeader FileHead;
|
2009-11-10 16:48:42 +01:00
|
|
|
EndArcHeader EndArcHead;
|
|
|
|
SubBlockHeader SubBlockHead;
|
|
|
|
FileHeader SubHead;
|
|
|
|
CommentHeader CommHead;
|
|
|
|
ProtectHeader ProtectHead;
|
|
|
|
UnixOwnersHeader UOHead;
|
|
|
|
EAHeader EAHead;
|
|
|
|
StreamHeader StreamHead;
|
|
|
|
|
|
|
|
int64 CurBlockPos;
|
|
|
|
int64 NextBlockPos;
|
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
RARFORMAT Format;
|
2009-11-10 16:48:42 +01:00
|
|
|
bool Solid;
|
|
|
|
bool Volume;
|
|
|
|
bool MainComment;
|
|
|
|
bool Locked;
|
|
|
|
bool Signed;
|
2020-07-15 00:40:26 +02:00
|
|
|
bool FirstVolume;
|
|
|
|
bool NewNumbering;
|
2009-11-10 16:48:42 +01:00
|
|
|
bool Protected;
|
|
|
|
bool Encrypted;
|
|
|
|
size_t SFXSize;
|
2020-07-15 00:40:26 +02:00
|
|
|
bool BrokenHeader;
|
|
|
|
bool FailedHeaderDecryption;
|
2009-11-10 16:48:42 +01:00
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
#if !defined(RAR_NOCRYPT)
|
|
|
|
byte ArcSalt[SIZE_SALT50];
|
|
|
|
#endif
|
2009-11-10 16:48:42 +01:00
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
bool Splitting;
|
2009-11-10 16:48:42 +01:00
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
uint VolNumber;
|
2009-11-10 16:48:42 +01:00
|
|
|
int64 VolWrite;
|
2020-07-15 00:40:26 +02:00
|
|
|
uint64 AddingFilesSize;
|
|
|
|
uint64 AddingHeadersSize;
|
2009-11-10 16:48:42 +01:00
|
|
|
|
|
|
|
bool NewArchive;
|
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
wchar FirstVolumeName[NM];
|
2009-11-10 16:48:42 +01:00
|
|
|
};
|
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
|
2009-11-10 16:48:42 +01:00
|
|
|
#endif
|