recvol.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _RAR_RECVOL_
  2. #define _RAR_RECVOL_
  3. #define REV5_SIGN "Rar!\x1aRev"
  4. #define REV5_SIGN_SIZE 8
  5. class RecVolumes3
  6. {
  7. private:
  8. File *SrcFile[256];
  9. Array<byte> Buf;
  10. #ifdef RAR_SMP
  11. ThreadPool *RSThreadPool;
  12. #endif
  13. public:
  14. RecVolumes3(RAROptions *Cmd,bool TestOnly);
  15. ~RecVolumes3();
  16. void Make(RAROptions *Cmd,wchar *ArcName);
  17. bool Restore(RAROptions *Cmd,const wchar *Name,bool Silent);
  18. void Test(RAROptions *Cmd,const wchar *Name);
  19. };
  20. struct RecVolItem
  21. {
  22. File *f;
  23. wchar Name[NM];
  24. uint CRC;
  25. uint64 FileSize;
  26. bool New; // Newly created RAR volume.
  27. bool Valid; // If existing RAR volume is valid.
  28. };
  29. class RecVolumes5;
  30. struct RecRSThreadData
  31. {
  32. RecVolumes5 *RecRSPtr;
  33. RSCoder16 *RS;
  34. bool Encode;
  35. uint DataNum;
  36. const byte *Data;
  37. size_t StartPos;
  38. size_t Size;
  39. };
  40. class RecVolumes5
  41. {
  42. private:
  43. void ProcessRS(RAROptions *Cmd,uint DataNum,const byte *Data,uint MaxRead,bool Encode);
  44. void ProcessRS(RAROptions *Cmd,uint MaxRead,bool Encode);
  45. uint ReadHeader(File *RecFile,bool FirstRev);
  46. Array<RecVolItem> RecItems;
  47. byte *RealReadBuffer; // Real pointer returned by 'new'.
  48. byte *ReadBuffer; // Pointer aligned for SSE instructions.
  49. byte *RealBuf; // Real pointer returned by 'new'.
  50. byte *Buf; // Store ECC or recovered data here, aligned for SSE.
  51. size_t RecBufferSize; // Buffer area allocated for single volume.
  52. uint DataCount; // Number of archives.
  53. uint RecCount; // Number of recovery volumes.
  54. uint TotalCount; // Total number of archives and recovery volumes.
  55. bool *ValidFlags; // Volume validity flags for recovering.
  56. uint MissingVolumes; // Number of missing or bad RAR volumes.
  57. #ifdef RAR_SMP
  58. ThreadPool *RecThreadPool;
  59. #endif
  60. uint MaxUserThreads; // Maximum number of threads defined by user.
  61. RecRSThreadData *ThreadData; // Array to store thread parameters.
  62. public: // 'public' only because called from thread functions.
  63. void ProcessAreaRS(RecRSThreadData *td);
  64. public:
  65. RecVolumes5(RAROptions *Cmd,bool TestOnly);
  66. ~RecVolumes5();
  67. bool Restore(RAROptions *Cmd,const wchar *Name,bool Silent);
  68. void Test(RAROptions *Cmd,const wchar *Name);
  69. };
  70. bool RecVolumesRestore(RAROptions *Cmd,const wchar *Name,bool Silent);
  71. void RecVolumesTest(RAROptions *Cmd,Archive *Arc,const wchar *Name);
  72. #endif