1
0

qopen.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef _RAR_QOPEN_
  2. #define _RAR_QOPEN_
  3. struct QuickOpenItem
  4. {
  5. byte *Header;
  6. size_t HeaderSize;
  7. uint64 ArcPos;
  8. QuickOpenItem *Next;
  9. };
  10. class Archive;
  11. class RawRead;
  12. class QuickOpen
  13. {
  14. private:
  15. void Close();
  16. uint ReadBuffer();
  17. bool ReadRaw(RawRead &Raw);
  18. bool ReadNext();
  19. Archive *Arc;
  20. bool WriteMode;
  21. QuickOpenItem *ListStart;
  22. QuickOpenItem *ListEnd;
  23. byte *Buf; // Read quick open data here.
  24. static const size_t MaxBufSize=0x10000; // Buf size, must be multiple of CRYPT_BLOCK_SIZE.
  25. size_t CurBufSize; // Current size of buffered data in write mode.
  26. #ifndef RAR_NOCRYPT // For shell extension.
  27. CryptData Crypt;
  28. #endif
  29. bool Loaded;
  30. uint64 QOHeaderPos; // Main QO header position.
  31. uint64 RawDataStart; // Start of QO data, just after the main header.
  32. uint64 RawDataSize; // Size of entire QO data.
  33. uint64 RawDataPos; // Current read position in QO data.
  34. size_t ReadBufSize; // Size of Buf data currently read from QO.
  35. size_t ReadBufPos; // Current read position in Buf data.
  36. Array<byte> LastReadHeader;
  37. uint64 LastReadHeaderPos;
  38. uint64 SeekPos;
  39. bool UnsyncSeekPos; // QOpen SeekPos does not match an actual file pointer.
  40. public:
  41. QuickOpen();
  42. ~QuickOpen();
  43. void Init(Archive *Arc,bool WriteMode);
  44. void Load(uint64 BlockPos);
  45. void Unload() { Loaded=false; }
  46. bool Read(void *Data,size_t Size,size_t &Result);
  47. bool Seek(int64 Offset,int Method);
  48. bool Tell(int64 *Pos);
  49. };
  50. #endif