DatIO.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // Created by kikab on 04.06.2018.
  3. //
  4. #ifndef LOTRO_DAT_LIBRARY_DATIO_H
  5. #define LOTRO_DAT_LIBRARY_DATIO_H
  6. #include <utility>
  7. #include "DatOperationResult.h"
  8. extern "C++" {
  9. namespace LOTRO_DAT {
  10. class BinaryData;
  11. class DatFile;
  12. class SubDirectory;
  13. class SubFile;
  14. class DatIO {
  15. public:
  16. DatIO() = delete;
  17. DatIO(const DatIO &other) = delete;
  18. DatIO& operator=(const DatIO &other) = delete;
  19. ~DatIO() = default;
  20. explicit DatIO(DatFile *datFilePtr);
  21. DatOperationResult<> Init(const std::string &filename);
  22. DatOperationResult<> ReadData(BinaryData &data, long long size, long long offset = 0, long long data_offset = 0) const;
  23. DatOperationResult<> WriteData(const BinaryData &data, long long size, long long offset = 0, long long data_offset = 0);
  24. DatOperationResult<long long> GetActualDatSize();
  25. DatOperationResult<std::string> GetFilename();
  26. void PrintInformaion(FILE* file);
  27. DatOperationResult<> DeInit();
  28. private:
  29. //------------------------------------------------//
  30. // PRIVATE INIT SECTION
  31. //------------------------------------------------//
  32. DatOperationResult<> OpenDatFile();
  33. DatOperationResult<> ReadSuperBlock();
  34. //------------------------------------------------//
  35. // PRIVATE DEINIT SECTION
  36. //------------------------------------------------//
  37. DatOperationResult<> ModifyFragmentationJournal();
  38. DatOperationResult<> UpdateHeader();
  39. private:
  40. DatFile *dat;
  41. FILE *file_handler_;
  42. std::string filename_;
  43. public:
  44. long long constant1;
  45. long long constant2;
  46. long long file_size;
  47. long long version1;
  48. long long version2;
  49. long long fragmentation_journal_size;
  50. long long fragmentation_journal_end;
  51. long long root_directory_offset;
  52. long long fragmentation_journal_offset;
  53. long long free_dat_size;
  54. private:
  55. long long actual_dat_size_;
  56. };
  57. }
  58. };
  59. #endif //LOTRO_DAT_LIBRARY_DATIO_H