archive.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef _RAR_ARCHIVE_
  2. #define _RAR_ARCHIVE_
  3. class Pack;
  4. enum {EN_LOCK=1,EN_VOL=2,EN_FIRSTVOL=4};
  5. class Archive:public File
  6. {
  7. private:
  8. bool IsSignature(byte *D);
  9. void UpdateLatestTime(FileHeader *CurBlock);
  10. void ConvertNameCase(char *Name);
  11. void ConvertNameCase(wchar *Name);
  12. void ConvertUnknownHeader();
  13. size_t ReadOldHeader();
  14. void UnexpEndArcMsg();
  15. #if !defined(SHELL_EXT) && !defined(RAR_NOCRYPT)
  16. CryptData HeadersCrypt;
  17. byte HeadersSalt[SALT_SIZE];
  18. #endif
  19. #ifndef SHELL_EXT
  20. ComprDataIO SubDataIO;
  21. byte SubDataSalt[SALT_SIZE];
  22. #endif
  23. RAROptions *Cmd,DummyCmd;
  24. MarkHeader MarkHead;
  25. OldMainHeader OldMhd;
  26. int RecoverySectors;
  27. int64 RecoveryPos;
  28. bool FailedHeaderDecryption;
  29. RarTime LatestTime;
  30. int LastReadBlock;
  31. int CurHeaderType;
  32. bool SilentOpen;
  33. public:
  34. Archive(RAROptions *InitCmd=NULL);
  35. bool IsArchive(bool EnableBroken);
  36. size_t SearchBlock(int BlockType);
  37. size_t SearchSubBlock(const char *Type);
  38. int ReadBlock(int BlockType);
  39. void WriteBlock(int BlockType,BaseBlock *wb=NULL);
  40. int PrepareNamesToWrite(char *Name,wchar *NameW,char *DestName,byte *DestNameW);
  41. void SetLhdSize();
  42. size_t ReadHeader();
  43. void CheckArc(bool EnableBroken);
  44. void CheckOpen(const char *Name,const wchar *NameW=NULL);
  45. bool WCheckOpen(const char *Name,const wchar *NameW=NULL);
  46. bool GetComment(Array<byte> *CmtData,Array<wchar> *CmtDataW);
  47. void ViewComment();
  48. void ViewFileComment();
  49. void SetLatestTime(RarTime *NewTime);
  50. void SeekToNext();
  51. bool CheckAccess();
  52. bool IsArcDir();
  53. bool IsArcLabel();
  54. void ConvertAttributes();
  55. int GetRecoverySize(bool Required);
  56. void VolSubtractHeaderSize(size_t SubSize);
  57. void AddSubData(byte *SrcData,size_t DataSize,File *SrcFile,const char *Name,bool AllowSplit);
  58. bool ReadSubData(Array<byte> *UnpData,File *DestFile);
  59. int GetHeaderType() {return(CurHeaderType);};
  60. size_t ReadCommentData(Array<byte> *CmtData,Array<wchar> *CmtDataW);
  61. void WriteCommentData(byte *Data,size_t DataSize,bool FileComment);
  62. RAROptions* GetRAROptions() {return(Cmd);}
  63. void SetSilentOpen(bool Mode) {SilentOpen=Mode;}
  64. BaseBlock ShortBlock;
  65. MainHeader NewMhd;
  66. FileHeader NewLhd;
  67. EndArcHeader EndArcHead;
  68. SubBlockHeader SubBlockHead;
  69. FileHeader SubHead;
  70. CommentHeader CommHead;
  71. ProtectHeader ProtectHead;
  72. AVHeader AVHead;
  73. SignHeader SignHead;
  74. UnixOwnersHeader UOHead;
  75. MacFInfoHeader MACHead;
  76. EAHeader EAHead;
  77. StreamHeader StreamHead;
  78. int64 CurBlockPos;
  79. int64 NextBlockPos;
  80. bool OldFormat;
  81. bool Solid;
  82. bool Volume;
  83. bool MainComment;
  84. bool Locked;
  85. bool Signed;
  86. bool NotFirstVolume;
  87. bool Protected;
  88. bool Encrypted;
  89. size_t SFXSize;
  90. bool BrokenFileHeader;
  91. bool Splitting;
  92. ushort HeaderCRC;
  93. int64 VolWrite;
  94. int64 AddingFilesSize;
  95. size_t AddingHeadersSize;
  96. bool NewArchive;
  97. char FirstVolumeName[NM];
  98. wchar FirstVolumeNameW[NM];
  99. };
  100. #endif